Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Build/phpunit/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
if (!getenv('TYPO3_PATH_ROOT')) {
putenv('TYPO3_PATH_ROOT=' . rtrim($testbase->getWebRoot(), '/'));
}

if (!getenv('TYPO3_PATH_WEB')) {
putenv('TYPO3_PATH_WEB=' . rtrim($testbase->getWebRoot(), '/'));
}
Expand Down
55 changes: 30 additions & 25 deletions Classes/Configuration/ExtConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,47 @@

namespace JWeiland\Pforum\Configuration;

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class ExtConf
*/
class ExtConf implements SingletonInterface
#[Autoconfigure(constructor: 'create')]
readonly class ExtConf implements SingletonInterface
{
protected string $emailFromAddress;
private const EXT_KEY = 'pforum';

protected string $emailFromName;
private const DEFAULT_SETTINGS = [
'emailFromAddress' => '',
'emailFromName' => '',
];

public function __construct()
public function __construct(
private string $emailFromAddress = self::DEFAULT_SETTINGS['emailFromAddress'],
private string $emailFromName = self::DEFAULT_SETTINGS['emailFromName'],
) {}

public static function create(ExtensionConfiguration $extensionConfiguration): self
{
// Get global configuration
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('pforum');
if (is_array($extConf)) {
// Call setter method foreach configuration entry
foreach ($extConf as $key => $value) {
$methodName = 'set' . ucfirst($key);
if (method_exists($this, $methodName)) {
$this->$methodName($value);
}
}
$extensionSettings = self::DEFAULT_SETTINGS;

// Overwrite default extension settings with values from EXT_CONF
try {
$extensionSettings = array_merge(
$extensionSettings,
$extensionConfiguration->get(self::EXT_KEY),
);
} catch (ExtensionConfigurationExtensionNotConfiguredException|ExtensionConfigurationPathDoesNotExistException) {
}

return new self(
emailFromAddress: (string)$extensionSettings['emailFromAddress'],
emailFromName: (string)$extensionSettings['emailFromName'],
);
}

/**
Expand All @@ -56,11 +71,6 @@ public function getEmailFromAddress(): string
return $this->emailFromAddress;
}

public function setEmailFromAddress(string $emailFromAddress): void
{
$this->emailFromAddress = $emailFromAddress;
}

/**
* @throws \InvalidArgumentException
*/
Expand All @@ -77,9 +87,4 @@ public function getEmailFromName(): string

return $this->emailFromName;
}

public function setEmailFromName(string $emailFromName): void
{
$this->emailFromName = $emailFromName;
}
}
11 changes: 6 additions & 5 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
class AbstractController extends ActionController
{
protected Arguments $arguments;

public function __construct(
protected readonly ExtConf $extConf,
protected readonly Session $session,
Expand All @@ -44,9 +46,7 @@ public function __construct(
protected readonly PersistenceManager $persistenceManager,
protected readonly FrontendGroupHelper $frontendGroupHelper,
) {
if ($this->arguments === null) {
$this->arguments = GeneralUtility::makeInstance(Arguments::class);
}
$this->arguments = GeneralUtility::makeInstance(Arguments::class);
}

public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
Expand Down Expand Up @@ -92,18 +92,19 @@ protected function checkForMisconfiguration(): void
empty($this->settings['emailIsMandatory'])
) {
throw new \RuntimeException(
'You can\'t hide topics at creation, deactivate admin activation and mark email as NOT mandatory.' .
"You can't hide topics at creation, deactivate admin activation and mark email as NOT mandatory." .
'This would produce hidden records which will never be visible',
1378371532,
);
}

if (
$this->settings['post']['hideAtCreation'] &&
empty($this->settings['post']['activateByAdmin']) &&
empty($this->settings['emailIsMandatory'])
) {
throw new \RuntimeException(
'You can\'t hide posts at creation, deactivate admin activation and mark email ' .
"You can't hide posts at creation, deactivate admin activation and mark email " .
'as NOT mandatory. This would produce hidden records which will never be visible',
1378371541,
);
Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/AdministrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected function createDocheaderActionButtons(): void
if (!in_array($this->actionMethodName, ['indexAction', 'listHiddenTopicsAction', 'listHiddenPostsAction'], true)) {
return;
}

$this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
$uriBuilder = $this->uriBuilder;
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public function initializeEditAction(): void

/**
* @param Post|null $post
* @param bool $isPreview
* @param bool $isNew We need the information if updateAction was called from createAction.
* If so we have to passthrough this information
*/
Expand Down
2 changes: 0 additions & 2 deletions Classes/Controller/TopicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ public function activateAction(Topic $topic): void

/**
* This is a workaround to help controller actions to find (hidden) topics.
*
* @param string $argumentName
*/
protected function registerTopicFromRequest(string $argumentName): void
{
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public function setFrontendUser(FrontendUser $frontendUser): void
*/
public function getUser(): User
{
if (!empty($this->anonymousUser)) {
if ($this->anonymousUser instanceof AnonymousUser) {
$user = $this->getAnonymousUser();
} elseif (!empty($this->frontendUser)) {
} elseif ($this->frontendUser instanceof FrontendUser) {
$user = $this->getFrontendUser();
} else {
$user = null;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public function setFrontendUser(FrontendUser $frontendUser): void
*/
public function getUser(): User
{
if (!empty($this->anonymousUser)) {
if ($this->anonymousUser instanceof AnonymousUser) {
$user = $this->getAnonymousUser();
} elseif (!empty($this->frontendUser)) {
} elseif ($this->frontendUser instanceof FrontendUser) {
$user = $this->getFrontendUser();
} else {
$user = null;
Expand Down
1 change: 0 additions & 1 deletion Classes/Domain/Repository/TopicRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function findAllHidden(): QueryResultInterface

/**
* @param mixed $value
* @param string $property
* @return Topic|null
*/
public function findHiddenObject($value, string $property = 'uid'): ?Topic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function setTypeConverterForProperty(
$controllerActionEvent->getSettings(),
);

if ($persistedFiles !== null) {
if ($persistedFiles instanceof ObjectStorage) {
$this->addOptionToUploadFilesConverter(
$propertyMappingConfiguration,
'IMAGES',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function setTypeConverterForProperty(
$controllerActionEvent->getSettings(),
);

if ($persistedFiles !== null) {
if ($persistedFiles instanceof ObjectStorage) {
$this->addOptionToUploadFilesConverter(
$propertyMappingConfiguration,
'IMAGES',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function convertFrom(

continue;
}

// Check if uploaded file returns an error
if (!$uploadedFile['error'] === 0) {
return new Error(
Expand Down Expand Up @@ -161,7 +162,7 @@ public function convertFrom(

protected function initialize(?PropertyMappingConfigurationInterface $configuration): void
{
if ($configuration === null) {
if (!$configuration instanceof PropertyMappingConfigurationInterface) {
throw new \Exception(
'Missing PropertyMapper configuration in UploadMultipleFilesConverter',
1666698966,
Expand Down Expand Up @@ -246,7 +247,7 @@ protected function isValidUploadFile(array $uploadedFile): bool
*/
protected function deleteFile(?FileReference $fileReference): void
{
if ($fileReference !== null) {
if ($fileReference instanceof FileReference) {
$fileReference = $fileReference->getOriginalResource();

if ($fileReference->getStorage()->isWithinFolder($this->uploadFolder, $fileReference)) {
Expand Down
4 changes: 1 addition & 3 deletions Classes/ViewHelper/IsCreateButtonAllowedViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class IsCreateButtonAllowedViewHelper extends AbstractViewHelper
{
public function initializeArguments(): void
{
parent::initializeArguments();

$this->registerArgument('authType', 'int', 'The authentication type. 1 = None, 2 = Needs authentication.');
$this->registerArgument('userGroupUid', 'int', 'The usergroup UID.');
}
Expand All @@ -48,7 +46,7 @@ public function render(): bool
$userGroupUid = (int)$this->arguments['userGroupUid'];

$userAspect = self::getUserAspect();
if ($userAspect === null) {
if (!$userAspect instanceof UserAspect) {
return false;
}

Expand Down
22 changes: 9 additions & 13 deletions Configuration/FlexForms/Forum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@
<sheets>
<sDEFAULT>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:pforum/Resources/Private/Language/FlexForms.xlf:sheetGeneral</sheetTitle>
</TCEforms>
<sheetTitle>LLL:EXT:pforum/Resources/Private/Language/FlexForms.xlf:sheetGeneral</sheetTitle>
<type>array</type>
<el>
<settings.pidOfDetailPage>
<TCEforms>
<label>LLL:EXT:pforum/Resources/Private/Language/FlexForms.xlf:pidOfDetailPage</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
</config>
</TCEforms>
<label>LLL:EXT:pforum/Resources/Private/Language/FlexForms.xlf:pidOfDetailPage</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
</config>
</settings.pidOfDetailPage>
</el>
</ROOT>
Expand Down
2 changes: 2 additions & 0 deletions Configuration/Sets/PForum/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: jweiland/pforum-default
label: PForum Set
2 changes: 2 additions & 0 deletions Configuration/Sets/PForum/page.tsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Add CType Preview
mod.web_layout.tt_content.preview.pforum_forum = EXT:pforum/Resources/Private/Templates/PluginPreview/Forum.html
Loading