Skip to content

Commit

Permalink
Merge pull request #4 from portrino/typo3-v12
Browse files Browse the repository at this point in the history
TYPO3 v12 Compatibility
  • Loading branch information
EvilBMP authored Sep 24, 2024
2 parents f75bc74 + 27a4a7c commit c96568e
Show file tree
Hide file tree
Showing 21 changed files with 307 additions and 182 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
pull_request:
schedule:
- cron: '5 5 * * *'

jobs:
testsuite:
name: all tests
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: composer:v2
- name: "Composer Install"
run: "composer install"
- name: "Run Static Code Analysis"
run: "composer ci:static"
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2', '8.3' ]
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/
.Build/
Build/phpunit/.phpunit.result.cache
Build/testing-docker/.env
var/
.env
.php-cs-fixer.cache
config
composer.lock
2 changes: 2 additions & 0 deletions Build/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Order deny,allow
Deny from all
3 changes: 3 additions & 0 deletions Build/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/*.min.css
**/Dist/
**/Vendor/
15 changes: 15 additions & 0 deletions Build/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": [
"stylelint-config-twbs-bootstrap/scss"
],
"rules": {
"property-blacklist": [
"border-radius",
"border-top-left-radius",
"border-top-right-radius",
"border-bottom-right-radius",
"border-bottom-left-radius",
"transition"
]
}
}
5 changes: 5 additions & 0 deletions Build/php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$config = \TYPO3\CodingStandards\CsFixerConfig::create();
$config->getFinder()->exclude(['node_modules', 'var'])->in(__DIR__ . '/..');
return $config;
13 changes: 13 additions & 0 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
includes:
- %currentWorkingDirectory%/.Build/vendor/phpstan/phpstan-strict-rules/rules.neon
- %currentWorkingDirectory%/.Build/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- %currentWorkingDirectory%/.Build/vendor/friendsoftypo3/phpstan-typo3/extension.neon

parameters:
level: 5

paths:
- %currentWorkingDirectory%/Classes
excludePaths:
analyse:
- %currentWorkingDirectory%/Classes/Reflection/ClassSchema.php
16 changes: 16 additions & 0 deletions Build/typoscript-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
paths:
- Configuration/TypoScript

sniffs:
- class: Indentation
parameters:
useSpaces: true
indentPerLevel: 4
- class: DeadCode
disabled: true
- class: EmptySection
disabled: true
- class: RepeatingRValue
disabled: true
- class: NestingConsistency
disabled: true
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# PxValidation Changelog

#### 2024-04-22
* [!!!][WIP] updates several classes for TYPO3 v12 compatibility
* [TASK] adds .github/workflow
* [CLEANUP] updates CHANGELOG and README

#### 2023-03-03
* [TASK] updates several classes and configuration files to be compatible with TYPO3 v12 core
* [TASK] adds TYPO3 v12 to allowed typo3/cms-core dependency

3.0.0 - 2023-03-17
------------------
* [CLEANUP] updates CHANGELOG and README
Expand Down
32 changes: 9 additions & 23 deletions Classes/Domain/Validator/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,32 @@
use Portrino\PxValidation\Validation\ValidatorResolver;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation\Validate;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException;
use TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator;

/**
* Class AbstractValidator
*
* @package Portrino\PxValidation\Domain\Validator
*/
abstract class AbstractValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator
{

/**
* Contains the settings of the current extension
*
* @var array
*/
protected $settings;
protected $settings = [];

/**
* Contains the settings of the current extension
*
* @var array
*/
protected $validationFields;
protected $validationFields = [];

/**
* @var ConfigurationManager
* @var ConfigurationManagerInterface
*/
protected $configurationManager;

Expand All @@ -68,13 +64,11 @@ abstract class AbstractValidator extends \TYPO3\CMS\Extbase\Validation\Validator
*/
protected $validatorResolver;

public function __construct(array $options = [])
public function __construct()
{
parent::__construct($options);

$this->configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
$this->settings = $this->configurationManager->getConfiguration(
ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
'PxValidation'
);
$this->validatorResolver = GeneralUtility::makeInstance(ValidatorResolver::class);
Expand All @@ -85,12 +79,9 @@ public function __construct(array $options = [])
*
* @param mixed $object
* @throws Exception
*
* @return bool
*/
public function isValid($object)
protected function isValid(mixed $object): void
{
$result = true;
$this->validationFields = $this->getValidationFields();

$objectValidators = new ObjectStorage();
Expand All @@ -111,7 +102,7 @@ public function isValid($object)
);
if ($newValidator === null) {
throw new NoSuchValidatorException(
'Invalid typoscript validation rule in ' . $object . '::' . $validationRule . ': Could not resolve class name for validator "' . $validatorConfiguration['validatorName'] . '".',
'Invalid typoscript validation rule in ' . $object . '::' . $validationRule . ': Could not resolve class name for validator "' . $validateAnnotation['validatorName'] . '".',
1241098027
);
}
Expand All @@ -124,7 +115,6 @@ public function isValid($object)
if (array_key_exists('propertyValidators', $this->validationFields) &&
is_array($this->validationFields['propertyValidators'])) {
foreach ($this->validationFields['propertyValidators'] as $validationField => $validationRules) {

/**
* if the property to validate is a child property then create a new $typoScriptChildValidator
* with the validation config of the child
Expand Down Expand Up @@ -169,6 +159,7 @@ public function isValid($object)
}
}
}
unset($objectValidator);

foreach ($objectValidators as $objectValidator) {
if ($objectValidator instanceof TypoScriptChildValidator) {
Expand All @@ -178,18 +169,13 @@ public function isValid($object)
} else {
$this->result->merge($objectValidator->validate($object));
}

if ($this->result->hasErrors()) {
$result = false;
}
}
return $result;
}

/**
* returns the array of validation fields from typoScript
*
* @return array
*/
abstract protected function getValidationFields();
abstract protected function getValidationFields(): array;
}
15 changes: 6 additions & 9 deletions Classes/Domain/Validator/TypoScriptChildValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@

/**
* Class TypoScriptChildValidator
* @package Portrino\PxValidation\Domain\Validator
*/
class TypoScriptChildValidator extends \Portrino\PxValidation\Domain\Validator\TypoScriptValidator
{

/**
* the child property name which will be validated
*
* @var mixed
*/
protected $childPropertyName;


/**
* the child object to validate
*
Expand All @@ -51,7 +48,7 @@ class TypoScriptChildValidator extends \Portrino\PxValidation\Domain\Validator\T
/**
* @param array $validationFields
*/
public function setValidationFields($validationFields)
public function setValidationFields(array $validationFields): void
{
$this->validationFields = $validationFields;
}
Expand All @@ -61,39 +58,39 @@ public function setValidationFields($validationFields)
*
* @return array
*/
protected function getValidationFields()
protected function getValidationFields(): array
{
return $this->validationFields;
}

/**
* @return mixed
*/
public function getChildPropertyName()
public function getChildPropertyName(): mixed
{
return $this->childPropertyName;
}

/**
* @param mixed $childPropertyName
*/
public function setChildPropertyName($childPropertyName)
public function setChildPropertyName(mixed $childPropertyName): void
{
$this->childPropertyName = $childPropertyName;
}

/**
* @return mixed
*/
public function getChildObject()
public function getChildObject(): mixed
{
return $this->childObject;
}

/**
* @param mixed $childObject
*/
public function setChildObject($childObject)
public function setChildObject(mixed $childObject): void
{
$this->childObject = $childObject;
}
Expand Down
15 changes: 6 additions & 9 deletions Classes/Domain/Validator/TypoScriptValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@

/**
* Class TypoScriptValidator
*
* @package Portrino\PxValidation\Domain\Validator
*/
class TypoScriptValidator extends \Portrino\PxValidation\Domain\Validator\AbstractValidator
{

/**
* @var array
*/
Expand All @@ -44,16 +41,16 @@ class TypoScriptValidator extends \Portrino\PxValidation\Domain\Validator\Abstra
'overwriteDefaultValidation' => [
'',
'If TRUE the validation rules defined in the property, model or controller are overwritten (will not be executed).',
'boolean'
]
'boolean',
],
];

/**
* returns the array of validation fields from typoscript
*
* @return array
*/
protected function getValidationFields()
protected function getValidationFields(): array
{
$result = [];
$className = $this->options['className'];
Expand All @@ -68,10 +65,10 @@ protected function getValidationFields()
}

/**
* @return boolean
* @return bool
*/
public function overwriteDefaultValidation()
public function overwriteDefaultValidation(): bool
{
return (boolean)$this->options['overwriteDefaultValidation'];
return (bool)$this->options['overwriteDefaultValidation'];
}
}
Loading

0 comments on commit c96568e

Please sign in to comment.