Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 0 additions & 2 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ enabled:
- whitespace_after_comma_in_array
- function_typehint_space
- hash_to_slash_comment
- no_alias_functions
- lowercase_cast
- no_leading_namespace_whitespace
- native_function_casing
- no_empty_statement
- self_accessor
- no_short_bool_cast
- no_unneeded_control_parentheses

Expand Down
2 changes: 1 addition & 1 deletion Classes/ConfigurationObjectMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function convert($source, $targetType, PropertyMappingConfigurationInterf
$this->configurationObjectConversionDTO = new ConfigurationObjectConversionDTO($this->rootTargetType, $this->serviceFactory);
$this->getTypeConverterDTO = new GetTypeConverterDTO($this->rootTargetType, $this->serviceFactory);

$result = call_user_func_array(['parent', 'convert'], func_get_args());
$result = parent::convert($source, $targetType, $configuration);

unset($this->configurationObjectConversionDTO);
unset($this->getTypeConverterDTO);
Expand Down
2 changes: 0 additions & 2 deletions Classes/Core/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ public function injectParentsUtility(ParentsUtility $parentsUtility)
*/
public function getCacheService()
{
$this->cacheService->registerInternalCache();

return $this->cacheService;
}

Expand Down
88 changes: 1 addition & 87 deletions Classes/Core/Service/CacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,107 +13,21 @@

namespace Romm\ConfigurationObject\Core\Service;

use TYPO3\CMS\Core\Cache\Backend\FileBackend;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class CacheService implements SingletonInterface
{
const CACHE_IDENTIFIER = 'cache_configuration_object';
const CACHE_IDENTIFIER = 'configuration_object';
const CACHE_TAG_DYNAMIC_CACHE = 'dynamic-cache';

/**
* Options for the internal cache.
*
* @var array
*/
protected $cacheOptions = [
'backend' => FileBackend::class,
'frontend' => VariableFrontend::class,
'groups' => ['all', 'system']
];

/**
* @var CacheManager
*/
protected $cacheManager;

/**
* Function called from `ext_localconf` file which will register the
* internal cache earlier.
*
* @internal
*/
public function registerInternalCache()
{
$cacheManager = $this->getCacheManager();

if (false === $cacheManager->hasCache(self::CACHE_IDENTIFIER)) {
$cacheManager->setCacheConfigurations([self::CACHE_IDENTIFIER => $this->cacheOptions]);
}
}

/**
* This function will take care of initializing all caches that were defined
* previously by the `CacheService` which allows dynamic caches to be used
* for every configuration object type.
*
* @see \Romm\ConfigurationObject\Service\Items\Cache\CacheService::initialize()
* @internal
*/
public function registerDynamicCaches()
{
$dynamicCaches = $this->getCache()->getByTag(self::CACHE_TAG_DYNAMIC_CACHE);

foreach ($dynamicCaches as $cacheData) {
$identifier = $cacheData['identifier'];
$options = $cacheData['options'];

$this->registerCacheInternal($identifier, $options);
}
}

/**
* Registers a new dynamic cache: the cache will be added to the cache
* manager after this function is executed. Its configuration will also be
* remembered so the cache will be registered properly during the cache
* framework initialization in further requests.
*
* @param string $identifier
* @param array $options
*/
public function registerDynamicCache($identifier, array $options)
{
if (false === $this->getCache()->has($identifier)) {
$this->getCache()->set(
$identifier,
[
'identifier' => $identifier,
'options' => $options
],
[self::CACHE_TAG_DYNAMIC_CACHE]
);
}

$this->registerCacheInternal($identifier, $options);
}

/**
* @param string $identifier
* @param array $options
*/
protected function registerCacheInternal($identifier, array $options)
{
$cacheManager = $this->getCacheManager();

if (false === $cacheManager->hasCache($identifier)) {
$cacheManager->setCacheConfigurations([$identifier => $options]);
}
}

/**
* @return FrontendInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Legacy/Reflection/ClassSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function hasProperty($propertyName)
}

/**
* Sets the property marked as uuid of an object with @uuid
* Sets the property marked as uuid of an object with \@uuid
*
* @param string $propertyName
* @throws \InvalidArgumentException
Expand Down
6 changes: 4 additions & 2 deletions Classes/Legacy/Reflection/DocCommentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* The TYPO3 project - inspiring people to share!
*/

use function chr;

/**
* A little parser which creates tag objects from doc comments
*/
Expand All @@ -40,12 +42,12 @@ public function parseDocComment($docComment)
{
$this->description = '';
$this->tags = [];
$lines = explode(LF, $docComment);
$lines = explode(chr(10), $docComment);
foreach ($lines as $line) {
if ($line !== '' && strpos($line, '@') !== false) {
$this->parseTag(substr($line, strpos($line, '@')));
} elseif (empty($this->tags)) {
$this->description .= preg_replace('#\\s*/?[*/]*(.*)$#', '$1', $line) . LF;
$this->description .= preg_replace('#\\s*/?[*/]*(.*)$#', '$1', $line) . chr(10);
}
}
$this->description = trim($this->description);
Expand Down
Loading