@@ -15,27 +15,27 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ConstraintContainer |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var ConstraintInterface |
|
| 20 | - */ |
|
| 21 | - protected $constraint; |
|
| 18 | + /** |
|
| 19 | + * @var ConstraintInterface |
|
| 20 | + */ |
|
| 21 | + protected $constraint; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @return ConstraintInterface |
|
| 25 | - */ |
|
| 26 | - public function getConstraint() |
|
| 27 | - { |
|
| 28 | - return $this->constraint; |
|
| 29 | - } |
|
| 23 | + /** |
|
| 24 | + * @return ConstraintInterface |
|
| 25 | + */ |
|
| 26 | + public function getConstraint() |
|
| 27 | + { |
|
| 28 | + return $this->constraint; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param ConstraintInterface $constraint |
|
| 33 | - * @return $this |
|
| 34 | - */ |
|
| 35 | - public function setConstraint($constraint) |
|
| 36 | - { |
|
| 37 | - $this->constraint = $constraint; |
|
| 38 | - return $this; |
|
| 39 | - } |
|
| 31 | + /** |
|
| 32 | + * @param ConstraintInterface $constraint |
|
| 33 | + * @return $this |
|
| 34 | + */ |
|
| 35 | + public function setConstraint($constraint) |
|
| 36 | + { |
|
| 37 | + $this->constraint = $constraint; |
|
| 38 | + return $this; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | } |
@@ -16,22 +16,22 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class CanBeHiddenViewHelper extends AbstractViewHelper |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @return void |
|
| 21 | - */ |
|
| 22 | - public function initializeArguments() |
|
| 23 | - { |
|
| 24 | - $this->registerArgument('name', 'string', 'The column name', true); |
|
| 25 | - } |
|
| 19 | + /** |
|
| 20 | + * @return void |
|
| 21 | + */ |
|
| 22 | + public function initializeArguments() |
|
| 23 | + { |
|
| 24 | + $this->registerArgument('name', 'string', 'The column name', true); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Returns whether the column can be hidden or not. |
|
| 29 | - * |
|
| 30 | - * @return boolean |
|
| 31 | - */ |
|
| 32 | - public function render() |
|
| 33 | - { |
|
| 34 | - return Tca::grid()->canBeHidden($this->arguments['name']); |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * Returns whether the column can be hidden or not. |
|
| 29 | + * |
|
| 30 | + * @return boolean |
|
| 31 | + */ |
|
| 32 | + public function render() |
|
| 33 | + { |
|
| 34 | + return Tca::grid()->canBeHidden($this->arguments['name']); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
@@ -18,29 +18,29 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class ExtensionManagementUtility |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Returns the relative path to the extension as measured from the public web path |
|
| 23 | - * If the extension is not loaded the function will die with an error message |
|
| 24 | - * Useful for images and links from the frontend |
|
| 25 | - * |
|
| 26 | - * @param string $key Extension key |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public static function siteRelPath($key) |
|
| 30 | - { |
|
| 31 | - return self::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($key)); |
|
| 32 | - } |
|
| 21 | + /** |
|
| 22 | + * Returns the relative path to the extension as measured from the public web path |
|
| 23 | + * If the extension is not loaded the function will die with an error message |
|
| 24 | + * Useful for images and links from the frontend |
|
| 25 | + * |
|
| 26 | + * @param string $key Extension key |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public static function siteRelPath($key) |
|
| 30 | + { |
|
| 31 | + return self::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($key)); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Strip first part of a path, equal to the length of public web path including trailing slash |
|
| 36 | - * |
|
| 37 | - * @param string $path |
|
| 38 | - * @return string |
|
| 39 | - * @internal |
|
| 40 | - */ |
|
| 41 | - public static function stripPathSitePrefix($path) |
|
| 42 | - { |
|
| 43 | - return substr($path, strlen(Environment::getPublicPath() . '/')); |
|
| 44 | - } |
|
| 34 | + /** |
|
| 35 | + * Strip first part of a path, equal to the length of public web path including trailing slash |
|
| 36 | + * |
|
| 37 | + * @param string $path |
|
| 38 | + * @return string |
|
| 39 | + * @internal |
|
| 40 | + */ |
|
| 41 | + public static function stripPathSitePrefix($path) |
|
| 42 | + { |
|
| 43 | + return substr($path, strlen(Environment::getPublicPath() . '/')); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -19,33 +19,33 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class PidCheck extends AbstractComponentView |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Renders warnings if storagePid is not properly configured. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function render(): string |
|
| 28 | - { |
|
| 29 | - $errors = $this->getModulePidService()->validateConfiguredPid(); |
|
| 22 | + /** |
|
| 23 | + * Renders warnings if storagePid is not properly configured. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function render(): string |
|
| 28 | + { |
|
| 29 | + $errors = $this->getModulePidService()->validateConfiguredPid(); |
|
| 30 | 30 | |
| 31 | - return empty($errors) |
|
| 32 | - ? '' |
|
| 33 | - : $this->formatMessagePidIsNotValid($errors); |
|
| 34 | - } |
|
| 31 | + return empty($errors) |
|
| 32 | + ? '' |
|
| 33 | + : $this->formatMessagePidIsNotValid($errors); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Format a message whenever the storage is offline. |
|
| 38 | - * |
|
| 39 | - * @param array $errors |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - protected function formatMessagePidIsNotValid(array $errors): string |
|
| 43 | - { |
|
| 44 | - $configuredPid = $this->getModulePidService()->getConfiguredNewRecordPid(); |
|
| 36 | + /** |
|
| 37 | + * Format a message whenever the storage is offline. |
|
| 38 | + * |
|
| 39 | + * @param array $errors |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + protected function formatMessagePidIsNotValid(array $errors): string |
|
| 43 | + { |
|
| 44 | + $configuredPid = $this->getModulePidService()->getConfiguredNewRecordPid(); |
|
| 45 | 45 | |
| 46 | - $error = implode('<br />', $errors); |
|
| 47 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
| 48 | - $result = <<< EOF |
|
| 46 | + $error = implode('<br />', $errors); |
|
| 47 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
| 48 | + $result = <<< EOF |
|
| 49 | 49 | <div class="alert alert-warning"> |
| 50 | 50 | <div class="alert-title"> |
| 51 | 51 | Page id "{$configuredPid}" has found to be a wrong configuration for "{$dataType}" |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | </div> |
| 74 | 74 | EOF; |
| 75 | 75 | |
| 76 | - return $result; |
|
| 77 | - } |
|
| 76 | + return $result; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @return ModulePidService|object |
|
| 81 | - */ |
|
| 82 | - public function getModulePidService() |
|
| 83 | - { |
|
| 84 | - /** @var ModulePidService $modulePidService */ |
|
| 85 | - return GeneralUtility::makeInstance(ModulePidService::class); |
|
| 86 | - } |
|
| 79 | + /** |
|
| 80 | + * @return ModulePidService|object |
|
| 81 | + */ |
|
| 82 | + public function getModulePidService() |
|
| 83 | + { |
|
| 84 | + /** @var ModulePidService $modulePidService */ |
|
| 85 | + return GeneralUtility::makeInstance(ModulePidService::class); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | use Fab\Vidi\Domain\Model\Selection; |
| 5 | 5 | |
| 6 | 6 | return [ |
| 7 | - Selection::class => [ |
|
| 8 | - 'tableName' => 'tx_vidi_selection', |
|
| 9 | - ], |
|
| 7 | + Selection::class => [ |
|
| 8 | + 'tableName' => 'tx_vidi_selection', |
|
| 9 | + ], |
|
| 10 | 10 | ]; |
@@ -18,57 +18,57 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class ComponentsViewHelper extends AbstractViewHelper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function initializeArguments() |
|
| 25 | - { |
|
| 26 | - $this->registerArgument('part', 'string', 'Template part', true); |
|
| 27 | - } |
|
| 21 | + /** |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function initializeArguments() |
|
| 25 | + { |
|
| 26 | + $this->registerArgument('part', 'string', 'Template part', true); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function. |
|
| 31 | - * |
|
| 32 | - * @return mixed |
|
| 33 | - */ |
|
| 34 | - public function render() |
|
| 35 | - { |
|
| 36 | - return static::renderStatic( |
|
| 37 | - $this->arguments, |
|
| 38 | - $this->buildRenderChildrenClosure(), |
|
| 39 | - $this->renderingContext |
|
| 40 | - ); |
|
| 41 | - } |
|
| 29 | + /** |
|
| 30 | + * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function. |
|
| 31 | + * |
|
| 32 | + * @return mixed |
|
| 33 | + */ |
|
| 34 | + public function render() |
|
| 35 | + { |
|
| 36 | + return static::renderStatic( |
|
| 37 | + $this->arguments, |
|
| 38 | + $this->buildRenderChildrenClosure(), |
|
| 39 | + $this->renderingContext |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Applies strip_tags() on the specified value. |
|
| 45 | - * |
|
| 46 | - * @param array $arguments |
|
| 47 | - * @param \Closure $renderChildrenClosure |
|
| 48 | - * @param RenderingContextInterface $renderingContext |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
|
| 52 | - { |
|
| 53 | - /** @var ModuleLoader $moduleLoader */ |
|
| 54 | - $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 43 | + /** |
|
| 44 | + * Applies strip_tags() on the specified value. |
|
| 45 | + * |
|
| 46 | + * @param array $arguments |
|
| 47 | + * @param \Closure $renderChildrenClosure |
|
| 48 | + * @param RenderingContextInterface $renderingContext |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
|
| 52 | + { |
|
| 53 | + /** @var ModuleLoader $moduleLoader */ |
|
| 54 | + $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 55 | 55 | |
| 56 | - $part = $arguments['part']; |
|
| 56 | + $part = $arguments['part']; |
|
| 57 | 57 | |
| 58 | - $getComponents = 'get' . ucfirst($part) . 'Components'; |
|
| 59 | - $components = $moduleLoader->$getComponents(); |
|
| 58 | + $getComponents = 'get' . ucfirst($part) . 'Components'; |
|
| 59 | + $components = $moduleLoader->$getComponents(); |
|
| 60 | 60 | |
| 61 | - $result = ''; |
|
| 62 | - foreach ($components as $component) { |
|
| 63 | - $viewHelper = GeneralUtility::makeInstance($component); |
|
| 61 | + $result = ''; |
|
| 62 | + foreach ($components as $component) { |
|
| 63 | + $viewHelper = GeneralUtility::makeInstance($component); |
|
| 64 | 64 | |
| 65 | - // Get possible arguments but remove first one. |
|
| 66 | - $arguments = func_get_args(); |
|
| 67 | - array_shift($arguments); |
|
| 68 | - $result .= call_user_func_array(array($viewHelper, 'render'), $arguments); |
|
| 69 | - } |
|
| 65 | + // Get possible arguments but remove first one. |
|
| 66 | + $arguments = func_get_args(); |
|
| 67 | + array_shift($arguments); |
|
| 68 | + $result .= call_user_func_array(array($viewHelper, 'render'), $arguments); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return $result; |
|
| 72 | - } |
|
| 71 | + return $result; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $EM_CONF[$_EXTKEY] = [ |
| 4 | - 'title' => 'Versatile and Interactive Display - List Component', |
|
| 5 | - 'description' => 'Generic listing of records with versatile ways of interacting with the data, e.g. advanced filter, inline editing, mass editing, ... Veni, vidi, vici!', |
|
| 6 | - 'author' => 'Fabien Udriot', |
|
| 7 | - 'author_email' => '[email protected]', |
|
| 8 | - 'state' => 'stable', |
|
| 4 | + 'title' => 'Versatile and Interactive Display - List Component', |
|
| 5 | + 'description' => 'Generic listing of records with versatile ways of interacting with the data, e.g. advanced filter, inline editing, mass editing, ... Veni, vidi, vici!', |
|
| 6 | + 'author' => 'Fabien Udriot', |
|
| 7 | + 'author_email' => '[email protected]', |
|
| 8 | + 'state' => 'stable', |
|
| 9 | 9 | ]; |
@@ -23,116 +23,116 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class ContentObjectProcessor implements SingletonInterface |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @param ProcessContentDataSignalArguments $signalArguments |
|
| 28 | - * @return array |
|
| 29 | - */ |
|
| 30 | - public function processRelations(ProcessContentDataSignalArguments $signalArguments) |
|
| 31 | - { |
|
| 32 | - $contentObject = $signalArguments->getContentObject(); |
|
| 33 | - $fieldNameAndPath = $signalArguments->getFieldNameAndPath(); |
|
| 34 | - $contentData = $signalArguments->getContentData(); |
|
| 35 | - $savingBehavior = $signalArguments->getSavingBehavior(); |
|
| 36 | - |
|
| 37 | - if ($savingBehavior !== SavingBehavior::REPLACE) { |
|
| 38 | - $contentData = $this->appendOrRemoveRelations($contentObject, $fieldNameAndPath, $contentData, $savingBehavior); |
|
| 39 | - $signalArguments->setContentData($contentData); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - return array($signalArguments); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param Content $object |
|
| 47 | - * @param $fieldNameAndPath |
|
| 48 | - * @param array $contentData |
|
| 49 | - * @param string $savingBehavior |
|
| 50 | - * @return array |
|
| 51 | - */ |
|
| 52 | - protected function appendOrRemoveRelations(Content $object, $fieldNameAndPath, array $contentData, $savingBehavior) |
|
| 53 | - { |
|
| 54 | - foreach ($contentData as $fieldName => $values) { |
|
| 55 | - $resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath); |
|
| 56 | - |
|
| 57 | - if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) { |
|
| 58 | - // true means CSV values must be converted to array. |
|
| 59 | - if (!is_array($values)) { |
|
| 60 | - $values = GeneralUtility::trimExplode(',', $values); |
|
| 61 | - } |
|
| 62 | - $relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName); |
|
| 63 | - |
|
| 64 | - foreach ($values as $value) { |
|
| 65 | - $appendOrRemove = $savingBehavior . 'Relations'; |
|
| 66 | - $relatedValues = $this->$appendOrRemove($value, $relatedValues); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $contentData[$fieldName] = $relatedValues; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - return $contentData; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @param $value |
|
| 77 | - * @param array $relatedValues |
|
| 78 | - * @return array |
|
| 79 | - */ |
|
| 80 | - protected function appendRelations($value, array $relatedValues) |
|
| 81 | - { |
|
| 82 | - if (!in_array($value, $relatedValues)) { |
|
| 83 | - $relatedValues[] = $value; |
|
| 84 | - } |
|
| 85 | - return $relatedValues; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @param $value |
|
| 90 | - * @param array $relatedValues |
|
| 91 | - * @return array |
|
| 92 | - */ |
|
| 93 | - protected function removeRelations($value, array $relatedValues) |
|
| 94 | - { |
|
| 95 | - if (in_array($value, $relatedValues)) { |
|
| 96 | - $key = array_search($value, $relatedValues); |
|
| 97 | - unset($relatedValues[$key]); |
|
| 98 | - } |
|
| 99 | - return $relatedValues; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @param Content $object |
|
| 104 | - * @param string $fieldNameAndPath |
|
| 105 | - * @param string $fieldName |
|
| 106 | - * @return array |
|
| 107 | - */ |
|
| 108 | - protected function getRelatedValues(Content $object, $fieldNameAndPath, $fieldName) |
|
| 109 | - { |
|
| 110 | - $values = []; |
|
| 111 | - $relatedContentObjects = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, $fieldName); |
|
| 112 | - |
|
| 113 | - if (is_array($relatedContentObjects)) { |
|
| 114 | - /** @var Content $relatedContentObject */ |
|
| 115 | - foreach ($relatedContentObjects as $relatedContentObject) { |
|
| 116 | - $values[] = $relatedContentObject->getUid(); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return $values; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @return ContentObjectResolver|object |
|
| 125 | - */ |
|
| 126 | - protected function getContentObjectResolver() |
|
| 127 | - { |
|
| 128 | - return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return FieldPathResolver|object |
|
| 133 | - */ |
|
| 134 | - protected function getFieldPathResolver() |
|
| 135 | - { |
|
| 136 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 137 | - } |
|
| 26 | + /** |
|
| 27 | + * @param ProcessContentDataSignalArguments $signalArguments |
|
| 28 | + * @return array |
|
| 29 | + */ |
|
| 30 | + public function processRelations(ProcessContentDataSignalArguments $signalArguments) |
|
| 31 | + { |
|
| 32 | + $contentObject = $signalArguments->getContentObject(); |
|
| 33 | + $fieldNameAndPath = $signalArguments->getFieldNameAndPath(); |
|
| 34 | + $contentData = $signalArguments->getContentData(); |
|
| 35 | + $savingBehavior = $signalArguments->getSavingBehavior(); |
|
| 36 | + |
|
| 37 | + if ($savingBehavior !== SavingBehavior::REPLACE) { |
|
| 38 | + $contentData = $this->appendOrRemoveRelations($contentObject, $fieldNameAndPath, $contentData, $savingBehavior); |
|
| 39 | + $signalArguments->setContentData($contentData); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + return array($signalArguments); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param Content $object |
|
| 47 | + * @param $fieldNameAndPath |
|
| 48 | + * @param array $contentData |
|
| 49 | + * @param string $savingBehavior |
|
| 50 | + * @return array |
|
| 51 | + */ |
|
| 52 | + protected function appendOrRemoveRelations(Content $object, $fieldNameAndPath, array $contentData, $savingBehavior) |
|
| 53 | + { |
|
| 54 | + foreach ($contentData as $fieldName => $values) { |
|
| 55 | + $resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath); |
|
| 56 | + |
|
| 57 | + if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) { |
|
| 58 | + // true means CSV values must be converted to array. |
|
| 59 | + if (!is_array($values)) { |
|
| 60 | + $values = GeneralUtility::trimExplode(',', $values); |
|
| 61 | + } |
|
| 62 | + $relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName); |
|
| 63 | + |
|
| 64 | + foreach ($values as $value) { |
|
| 65 | + $appendOrRemove = $savingBehavior . 'Relations'; |
|
| 66 | + $relatedValues = $this->$appendOrRemove($value, $relatedValues); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $contentData[$fieldName] = $relatedValues; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + return $contentData; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @param $value |
|
| 77 | + * @param array $relatedValues |
|
| 78 | + * @return array |
|
| 79 | + */ |
|
| 80 | + protected function appendRelations($value, array $relatedValues) |
|
| 81 | + { |
|
| 82 | + if (!in_array($value, $relatedValues)) { |
|
| 83 | + $relatedValues[] = $value; |
|
| 84 | + } |
|
| 85 | + return $relatedValues; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @param $value |
|
| 90 | + * @param array $relatedValues |
|
| 91 | + * @return array |
|
| 92 | + */ |
|
| 93 | + protected function removeRelations($value, array $relatedValues) |
|
| 94 | + { |
|
| 95 | + if (in_array($value, $relatedValues)) { |
|
| 96 | + $key = array_search($value, $relatedValues); |
|
| 97 | + unset($relatedValues[$key]); |
|
| 98 | + } |
|
| 99 | + return $relatedValues; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @param Content $object |
|
| 104 | + * @param string $fieldNameAndPath |
|
| 105 | + * @param string $fieldName |
|
| 106 | + * @return array |
|
| 107 | + */ |
|
| 108 | + protected function getRelatedValues(Content $object, $fieldNameAndPath, $fieldName) |
|
| 109 | + { |
|
| 110 | + $values = []; |
|
| 111 | + $relatedContentObjects = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, $fieldName); |
|
| 112 | + |
|
| 113 | + if (is_array($relatedContentObjects)) { |
|
| 114 | + /** @var Content $relatedContentObject */ |
|
| 115 | + foreach ($relatedContentObjects as $relatedContentObject) { |
|
| 116 | + $values[] = $relatedContentObject->getUid(); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return $values; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @return ContentObjectResolver|object |
|
| 125 | + */ |
|
| 126 | + protected function getContentObjectResolver() |
|
| 127 | + { |
|
| 128 | + return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return FieldPathResolver|object |
|
| 133 | + */ |
|
| 134 | + protected function getFieldPathResolver() |
|
| 135 | + { |
|
| 136 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 137 | + } |
|
| 138 | 138 | } |
@@ -20,109 +20,109 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class MarkerProcessor implements SingletonInterface |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - protected $wellKnownMarkers = array( |
|
| 27 | - '{*}', |
|
| 28 | - '{counter}', |
|
| 29 | - '{date}', |
|
| 30 | - '{creation_date}' |
|
| 31 | - ); |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + protected $wellKnownMarkers = array( |
|
| 27 | + '{*}', |
|
| 28 | + '{counter}', |
|
| 29 | + '{date}', |
|
| 30 | + '{creation_date}' |
|
| 31 | + ); |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param ProcessContentDataSignalArguments $signalArguments |
|
| 35 | - * @return array |
|
| 36 | - */ |
|
| 37 | - public function processMarkers(ProcessContentDataSignalArguments $signalArguments) |
|
| 38 | - { |
|
| 39 | - $contentData = $signalArguments->getContentData(); |
|
| 40 | - $creationTime = $this->getCreationTime($signalArguments); |
|
| 33 | + /** |
|
| 34 | + * @param ProcessContentDataSignalArguments $signalArguments |
|
| 35 | + * @return array |
|
| 36 | + */ |
|
| 37 | + public function processMarkers(ProcessContentDataSignalArguments $signalArguments) |
|
| 38 | + { |
|
| 39 | + $contentData = $signalArguments->getContentData(); |
|
| 40 | + $creationTime = $this->getCreationTime($signalArguments); |
|
| 41 | 41 | |
| 42 | - // Process markers |
|
| 43 | - foreach ($signalArguments->getContentData() as $fieldName => $updateValue) { |
|
| 44 | - if (is_scalar($updateValue)) { |
|
| 45 | - $currentValue = $this->getContentObjectResolver()->getValue( |
|
| 46 | - $signalArguments->getContentObject(), |
|
| 47 | - $signalArguments->getFieldNameAndPath(), |
|
| 48 | - $fieldName, |
|
| 49 | - $signalArguments->getLanguage() |
|
| 50 | - ); |
|
| 51 | - $counter = $signalArguments->getCounter(); |
|
| 42 | + // Process markers |
|
| 43 | + foreach ($signalArguments->getContentData() as $fieldName => $updateValue) { |
|
| 44 | + if (is_scalar($updateValue)) { |
|
| 45 | + $currentValue = $this->getContentObjectResolver()->getValue( |
|
| 46 | + $signalArguments->getContentObject(), |
|
| 47 | + $signalArguments->getFieldNameAndPath(), |
|
| 48 | + $fieldName, |
|
| 49 | + $signalArguments->getLanguage() |
|
| 50 | + ); |
|
| 51 | + $counter = $signalArguments->getCounter(); |
|
| 52 | 52 | |
| 53 | - $updateValue = $this->searchAndReplace($updateValue, $currentValue); |
|
| 54 | - $updateValue = $this->replaceWellKnownMarkers($updateValue, $currentValue, $counter, $creationTime); |
|
| 53 | + $updateValue = $this->searchAndReplace($updateValue, $currentValue); |
|
| 54 | + $updateValue = $this->replaceWellKnownMarkers($updateValue, $currentValue, $counter, $creationTime); |
|
| 55 | 55 | |
| 56 | - $contentData[$fieldName] = $updateValue; |
|
| 57 | - } |
|
| 58 | - } |
|
| 56 | + $contentData[$fieldName] = $updateValue; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $signalArguments->setContentData($contentData); |
|
| 61 | - return array($signalArguments); |
|
| 62 | - } |
|
| 60 | + $signalArguments->setContentData($contentData); |
|
| 61 | + return array($signalArguments); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @param string $updateValue |
|
| 66 | - * @param string $currentValue |
|
| 67 | - * @param int $counter |
|
| 68 | - * @param $creationTime |
|
| 69 | - * @return string |
|
| 70 | - */ |
|
| 71 | - protected function replaceWellKnownMarkers($updateValue, $currentValue, $counter, $creationTime) |
|
| 72 | - { |
|
| 73 | - // Replaces values. |
|
| 74 | - $replaces = array( |
|
| 75 | - $currentValue, |
|
| 76 | - $counter, |
|
| 77 | - date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']), |
|
| 78 | - date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $creationTime), |
|
| 79 | - ); |
|
| 64 | + /** |
|
| 65 | + * @param string $updateValue |
|
| 66 | + * @param string $currentValue |
|
| 67 | + * @param int $counter |
|
| 68 | + * @param $creationTime |
|
| 69 | + * @return string |
|
| 70 | + */ |
|
| 71 | + protected function replaceWellKnownMarkers($updateValue, $currentValue, $counter, $creationTime) |
|
| 72 | + { |
|
| 73 | + // Replaces values. |
|
| 74 | + $replaces = array( |
|
| 75 | + $currentValue, |
|
| 76 | + $counter, |
|
| 77 | + date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']), |
|
| 78 | + date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $creationTime), |
|
| 79 | + ); |
|
| 80 | 80 | |
| 81 | - // Replace me! |
|
| 82 | - return str_replace($this->wellKnownMarkers, $replaces, $updateValue); |
|
| 83 | - } |
|
| 81 | + // Replace me! |
|
| 82 | + return str_replace($this->wellKnownMarkers, $replaces, $updateValue); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @param string $updateValue |
|
| 87 | - * @param string $currentValue |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - protected function searchAndReplace($updateValue, $currentValue) |
|
| 91 | - { |
|
| 92 | - if (strpos($updateValue, 's/') !== false) { |
|
| 93 | - $structure = explode('/', $updateValue); |
|
| 94 | - $search = $structure[1]; |
|
| 95 | - $replace = $structure[2]; |
|
| 85 | + /** |
|
| 86 | + * @param string $updateValue |
|
| 87 | + * @param string $currentValue |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + protected function searchAndReplace($updateValue, $currentValue) |
|
| 91 | + { |
|
| 92 | + if (strpos($updateValue, 's/') !== false) { |
|
| 93 | + $structure = explode('/', $updateValue); |
|
| 94 | + $search = $structure[1]; |
|
| 95 | + $replace = $structure[2]; |
|
| 96 | 96 | |
| 97 | - // Perhaps needs to be improved here if $search contains "/" precisely. |
|
| 98 | - $updateValue = preg_replace('/' . $search . '/isU', $replace, $currentValue); |
|
| 99 | - } |
|
| 100 | - return $updateValue; |
|
| 101 | - } |
|
| 97 | + // Perhaps needs to be improved here if $search contains "/" precisely. |
|
| 98 | + $updateValue = preg_replace('/' . $search . '/isU', $replace, $currentValue); |
|
| 99 | + } |
|
| 100 | + return $updateValue; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param ProcessContentDataSignalArguments $signalArguments |
|
| 105 | - * @return int |
|
| 106 | - */ |
|
| 107 | - protected function getCreationTime(ProcessContentDataSignalArguments $signalArguments) |
|
| 108 | - { |
|
| 109 | - $creationTime = 0; |
|
| 110 | - $creationTimeField = Tca::table($signalArguments->getContentObject()->getDataType())->getTimeCreationField(); |
|
| 111 | - if ($creationTimeField) { |
|
| 112 | - $creationTime = $this->getContentObjectResolver()->getValue( |
|
| 113 | - $signalArguments->getContentObject(), |
|
| 114 | - $signalArguments->getFieldNameAndPath(), |
|
| 115 | - $creationTimeField |
|
| 116 | - ); |
|
| 117 | - } |
|
| 118 | - return $creationTime; |
|
| 119 | - } |
|
| 103 | + /** |
|
| 104 | + * @param ProcessContentDataSignalArguments $signalArguments |
|
| 105 | + * @return int |
|
| 106 | + */ |
|
| 107 | + protected function getCreationTime(ProcessContentDataSignalArguments $signalArguments) |
|
| 108 | + { |
|
| 109 | + $creationTime = 0; |
|
| 110 | + $creationTimeField = Tca::table($signalArguments->getContentObject()->getDataType())->getTimeCreationField(); |
|
| 111 | + if ($creationTimeField) { |
|
| 112 | + $creationTime = $this->getContentObjectResolver()->getValue( |
|
| 113 | + $signalArguments->getContentObject(), |
|
| 114 | + $signalArguments->getFieldNameAndPath(), |
|
| 115 | + $creationTimeField |
|
| 116 | + ); |
|
| 117 | + } |
|
| 118 | + return $creationTime; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * @return ContentObjectResolver |
|
| 123 | - */ |
|
| 124 | - protected function getContentObjectResolver() |
|
| 125 | - { |
|
| 126 | - return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
| 127 | - } |
|
| 121 | + /** |
|
| 122 | + * @return ContentObjectResolver |
|
| 123 | + */ |
|
| 124 | + protected function getContentObjectResolver() |
|
| 125 | + { |
|
| 126 | + return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
| 127 | + } |
|
| 128 | 128 | } |