Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
[FEATURE] Add logging for language label usage.
[FEATURE] Add module for displaying evaluated log data of language labels.
[FEATURE] Replace LocalizationService with new LocalizationUtility. LocalizationService is still available for compatibility reasons!
[TASK] Apply CGL rules.
[TASK] Deprecate LocalizationService.
[TASK] Improve display of log data in locallang module.
[TASK] Improve performance of LocalizationService/LocalizationUtility.
[TASK] Remove redundant PHPDoc comments.
[TASK] Set version to 2.2.0.
[BUGFIX] Placeholders in localized strings were replaced in ViewHelper context only.
  • Loading branch information
phantasie-schmiede authored Mar 8, 2024
1 parent 71c147b commit 657c85d
Show file tree
Hide file tree
Showing 100 changed files with 1,708 additions and 2,267 deletions.
6 changes: 0 additions & 6 deletions Classes/Attribute/ModuleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
#[Attribute(Attribute::TARGET_METHOD)]
class ModuleAction extends AbstractAttribute
{
/**
* @param bool $default
*/
public function __construct(
/** Marks the default action of the controller (executed, when no specific action is given in a request). */
protected bool $default = false,
) {
}

/**
* @return bool
*/
public function isDefault(): bool
{
return $this->default;
Expand Down
10 changes: 0 additions & 10 deletions Classes/Attribute/PluginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#[Attribute(Attribute::TARGET_METHOD)]
class PluginAction extends AbstractAttribute
{
/**
* @param bool $default
* @param bool $uncached
*/
public function __construct(
/** Marks the default action of the controller (executed, when no specific action is given in a request). */
protected bool $default = false,
Expand All @@ -34,17 +30,11 @@ public function __construct(
) {
}

/**
* @return bool
*/
public function isDefault(): bool
{
return $this->default;
}

/**
* @return bool
*/
public function isUncached(): bool
{
return $this->uncached;
Expand Down
3 changes: 0 additions & 3 deletions Classes/Attribute/TCA/AbstractTcaAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
*/
abstract class AbstractTcaAttribute extends AbstractAttribute
{
/**
* @var TcaService
*/
protected TcaService $tcaService;

public function __construct()
Expand Down
3 changes: 0 additions & 3 deletions Classes/Attribute/TCA/ColumnType/AbstractColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ abstract class AbstractColumnType extends AbstractAttribute implements ColumnTyp
{
/**
* Returns the short class name (lower case) for ['config']['type'].
*
* @return string
*/
public function getType(): string
{
Expand All @@ -33,7 +31,6 @@ public function getType(): string
}

/**
* @return array
* @throws ReflectionException
*/
public function toArray(): array
Expand Down
21 changes: 6 additions & 15 deletions Classes/Attribute/TCA/ColumnType/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
class Category extends AbstractColumnType
{
/**
* @var TcaService
*/
protected TcaService $tcaService;

/**
Expand Down Expand Up @@ -63,32 +60,22 @@ public function __construct(
$this->tcaService = GeneralUtility::makeInstance(TcaService::class);
}

/**
* @return string
*/
public function getDatabaseDefinition(): string
{
return DefinitionUtility::int(unsigned: true);
}

/**
* @return string|null
*/
public function getExclusiveKeys(): ?string
{
return $this->exclusiveKeys ? implode(', ', $this->exclusiveKeys) : null;
}

/**
* @return string
*/
public function getRelationship(): string
{
return $this->relationship->value;
}

/**
* @return array|null
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
Expand All @@ -112,15 +99,19 @@ public function getTreeConfig(): ?array
}

if (null !== $this->treeConfigChildrenField) {
$configuration['childrenField'] = $this->tcaService->convertPropertyNameToColumnName($this->treeConfigChildrenField);
$configuration['childrenField'] = $this->tcaService->convertPropertyNameToColumnName(
$this->treeConfigChildrenField
);
}

if (null !== $this->treeConfigDataProvider) {
$configuration['dataProvider'] = $this->treeConfigDataProvider;
}

if (null !== $this->treeConfigParentField) {
$configuration['parentField'] = $this->tcaService->convertPropertyNameToColumnName($this->treeConfigParentField);
$configuration['parentField'] = $this->tcaService->convertPropertyNameToColumnName(
$this->treeConfigParentField
);
}

if (!empty($this->treeConfigStartingPoints)) {
Expand Down
65 changes: 15 additions & 50 deletions Classes/Attribute/TCA/ColumnType/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
use JsonException;
use PSB\PsbFoundation\Enum\CheckboxRenderType;
use PSB\PsbFoundation\Exceptions\MisconfiguredTcaException;
use PSB\PsbFoundation\Service\LocalizationService;
use PSB\PsbFoundation\Utility\ArrayUtility;
use PSB\PsbFoundation\Utility\Configuration\FilePathUtility;
use PSB\PsbFoundation\Utility\Database\DefinitionUtility;
use PSB\PsbFoundation\Utility\LocalizationUtility;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use function is_array;

/**
* Class Check
Expand All @@ -39,7 +40,7 @@ class Check extends AbstractColumnType implements ColumnTypeWithItemsInterface
*
* @param int|string $cols https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Check/Properties/Cols.html
* @param string $eval https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Check/Properties/Eval.html
* @param false|boolean $invertStateDisplay https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Check/Properties/InvertStateDisplay.html
* @param false|bool $invertStateDisplay https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Check/Properties/InvertStateDisplay.html
* @param array $items https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Check/Properties/Items.html
* @param int $maximumRecordsChecked
* @param int $maximumRecordsCheckedInPid
Expand All @@ -63,25 +64,16 @@ public function __construct(
}
}

/**
* @return int|string
*/
public function getCols(): int|string
{
return $this->cols;
}

/**
* @return string
*/
public function getDatabaseDefinition(): string
{
return DefinitionUtility::tinyint(unsigned: true);
}

/**
* @return string|null
*/
public function getEval(): ?string
{
$validation = null;
Expand All @@ -101,17 +93,11 @@ public function getEval(): ?string
return $validation ? implode(', ', $validation) : null;
}

/**
* @return array
*/
public function getItems(): array
{
return $this->items;
}

/**
* @return string|null
*/
public function getRenderType(): ?string
{
if (CheckboxRenderType::default === $this->renderType) {
Expand All @@ -121,9 +107,6 @@ public function getRenderType(): ?string
return $this->renderType->value;
}

/**
* @return array|null
*/
public function getValidation(): ?array
{
$validation = null;
Expand All @@ -139,63 +122,48 @@ public function getValidation(): ?array
return $validation;
}

/**
* @return bool
*/
public function isInvertStateDisplay(): bool
{
return $this->invertStateDisplay;
}

/**
* @param LocalizationService $localizationService
* @param string $labelPath
*
* @return void
* @throws ContainerExceptionInterface
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
* @throws InvalidConfigurationTypeException
* @throws JsonException
* @throws NotFoundExceptionInterface
*/
public function processItems(LocalizationService $localizationService, string $labelPath = ''): void
public function processItems(string $labelPath = ''): void
{
if (!is_array($this->items)) {
return;
}

// $items already has TCA format
if (ArrayUtility::isMultiDimensionalArray($this->items)) {
$this->processTcaFormat($localizationService);
$this->processTcaFormat();
}

// $items has to be transformed into TCA format
$this->processSimpleFormat($localizationService, $labelPath);
$this->processSimpleFormat($labelPath);
}

/**
* @param LocalizationService $localizationService
* @param string $labelPath
*
* @return void
* @throws ContainerExceptionInterface
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
* @throws InvalidConfigurationTypeException
* @throws JsonException
* @throws NotFoundExceptionInterface
*/
private function processSimpleFormat(LocalizationService $localizationService, string $labelPath = ''): void
private function processSimpleFormat(string $labelPath = ''): void
{
$selectItems = [];

foreach ($this->items as $key => $value) {
if (!is_string($key)
&& (is_string($value)
|| is_numeric($value)
)
) {
if (!is_string($key) && (is_string($value) || is_numeric($value))) {
$label = (string)$value;
} else {
$label = (string)$key;
Expand All @@ -206,7 +174,7 @@ private function processSimpleFormat(LocalizationService $localizationService, s
}

if (str_starts_with($label, FilePathUtility::LANGUAGE_LABEL_PREFIX)) {
$localizationService->translationExists($label);
LocalizationUtility::translationExists($label);
}

$selectItems[] = [
Expand All @@ -218,26 +186,23 @@ private function processSimpleFormat(LocalizationService $localizationService, s
}

/**
* @param LocalizationService $localizationService
*
* @return void
* @throws ContainerExceptionInterface
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
* @throws InvalidConfigurationTypeException
* @throws JsonException
* @throws NotFoundExceptionInterface
*/
private function processTcaFormat(LocalizationService $localizationService): void
private function processTcaFormat(): void
{
foreach ($this->items as $item) {
foreach ([
'label',
'labelChecked',
'labelUnchecked',
] as $key) {
'label',
'labelChecked',
'labelUnchecked',
] as $key) {
if (!empty($item[$key]) && str_starts_with($item[$key], FilePathUtility::LANGUAGE_LABEL_PREFIX)) {
$localizationService->translationExists($item[$key]);
LocalizationUtility::translationExists($item[$key]);
}
}
}
Expand Down
Loading

0 comments on commit 657c85d

Please sign in to comment.