@@ -22,121 +22,121 @@ |
||
| 22 | 22 | class ContentObjectProcessor implements SingletonInterface |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param ProcessContentDataSignalArguments $signalArguments |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function processRelations(ProcessContentDataSignalArguments $signalArguments) |
|
| 30 | - { |
|
| 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 \Fab\Vidi\Domain\Model\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 | - |
|
| 55 | - foreach ($contentData as $fieldName => $values) { |
|
| 56 | - |
|
| 57 | - $resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath); |
|
| 58 | - |
|
| 59 | - if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) { |
|
| 60 | - |
|
| 61 | - // true means CSV values must be converted to array. |
|
| 62 | - if (!is_array($values)) { |
|
| 63 | - $values = GeneralUtility::trimExplode(',', $values); |
|
| 64 | - } |
|
| 65 | - $relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName); |
|
| 66 | - |
|
| 67 | - foreach ($values as $value) { |
|
| 68 | - $appendOrRemove = $savingBehavior . 'Relations'; |
|
| 69 | - $relatedValues = $this->$appendOrRemove($value, $relatedValues); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $contentData[$fieldName] = $relatedValues; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - return $contentData; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @param $value |
|
| 80 | - * @param array $relatedValues |
|
| 81 | - * @return array |
|
| 82 | - */ |
|
| 83 | - protected function appendRelations($value, array $relatedValues) |
|
| 84 | - { |
|
| 85 | - if (!in_array($value, $relatedValues)) { |
|
| 86 | - $relatedValues[] = $value; |
|
| 87 | - } |
|
| 88 | - return $relatedValues; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @param $value |
|
| 93 | - * @param array $relatedValues |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 96 | - protected function removeRelations($value, array $relatedValues) |
|
| 97 | - { |
|
| 98 | - if (in_array($value, $relatedValues)) { |
|
| 99 | - $key = array_search($value, $relatedValues); |
|
| 100 | - unset($relatedValues[$key]); |
|
| 101 | - } |
|
| 102 | - return $relatedValues; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @param \Fab\Vidi\Domain\Model\Content $object |
|
| 107 | - * @param string $fieldNameAndPath |
|
| 108 | - * @param string $fieldName |
|
| 109 | - * @return array |
|
| 110 | - */ |
|
| 111 | - protected function getRelatedValues(Content $object, $fieldNameAndPath, $fieldName) |
|
| 112 | - { |
|
| 113 | - |
|
| 114 | - $values = []; |
|
| 115 | - $relatedContentObjects = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, $fieldName); |
|
| 116 | - |
|
| 117 | - if (is_array($relatedContentObjects)) { |
|
| 118 | - /** @var Content $relatedContentObject */ |
|
| 119 | - foreach ($relatedContentObjects as $relatedContentObject) { |
|
| 120 | - $values[] = $relatedContentObject->getUid(); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $values; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @return \Fab\Vidi\Resolver\ContentObjectResolver|object |
|
| 129 | - */ |
|
| 130 | - protected function getContentObjectResolver() |
|
| 131 | - { |
|
| 132 | - return GeneralUtility::makeInstance(\Fab\Vidi\Resolver\ContentObjectResolver::class); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @return \Fab\Vidi\Resolver\FieldPathResolver|object |
|
| 137 | - */ |
|
| 138 | - protected function getFieldPathResolver() |
|
| 139 | - { |
|
| 140 | - return GeneralUtility::makeInstance(\Fab\Vidi\Resolver\FieldPathResolver::class); |
|
| 141 | - } |
|
| 25 | + /** |
|
| 26 | + * @param ProcessContentDataSignalArguments $signalArguments |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function processRelations(ProcessContentDataSignalArguments $signalArguments) |
|
| 30 | + { |
|
| 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 \Fab\Vidi\Domain\Model\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 | + |
|
| 55 | + foreach ($contentData as $fieldName => $values) { |
|
| 56 | + |
|
| 57 | + $resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath); |
|
| 58 | + |
|
| 59 | + if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) { |
|
| 60 | + |
|
| 61 | + // true means CSV values must be converted to array. |
|
| 62 | + if (!is_array($values)) { |
|
| 63 | + $values = GeneralUtility::trimExplode(',', $values); |
|
| 64 | + } |
|
| 65 | + $relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName); |
|
| 66 | + |
|
| 67 | + foreach ($values as $value) { |
|
| 68 | + $appendOrRemove = $savingBehavior . 'Relations'; |
|
| 69 | + $relatedValues = $this->$appendOrRemove($value, $relatedValues); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $contentData[$fieldName] = $relatedValues; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + return $contentData; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @param $value |
|
| 80 | + * @param array $relatedValues |
|
| 81 | + * @return array |
|
| 82 | + */ |
|
| 83 | + protected function appendRelations($value, array $relatedValues) |
|
| 84 | + { |
|
| 85 | + if (!in_array($value, $relatedValues)) { |
|
| 86 | + $relatedValues[] = $value; |
|
| 87 | + } |
|
| 88 | + return $relatedValues; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @param $value |
|
| 93 | + * @param array $relatedValues |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | + protected function removeRelations($value, array $relatedValues) |
|
| 97 | + { |
|
| 98 | + if (in_array($value, $relatedValues)) { |
|
| 99 | + $key = array_search($value, $relatedValues); |
|
| 100 | + unset($relatedValues[$key]); |
|
| 101 | + } |
|
| 102 | + return $relatedValues; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @param \Fab\Vidi\Domain\Model\Content $object |
|
| 107 | + * @param string $fieldNameAndPath |
|
| 108 | + * @param string $fieldName |
|
| 109 | + * @return array |
|
| 110 | + */ |
|
| 111 | + protected function getRelatedValues(Content $object, $fieldNameAndPath, $fieldName) |
|
| 112 | + { |
|
| 113 | + |
|
| 114 | + $values = []; |
|
| 115 | + $relatedContentObjects = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, $fieldName); |
|
| 116 | + |
|
| 117 | + if (is_array($relatedContentObjects)) { |
|
| 118 | + /** @var Content $relatedContentObject */ |
|
| 119 | + foreach ($relatedContentObjects as $relatedContentObject) { |
|
| 120 | + $values[] = $relatedContentObject->getUid(); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $values; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @return \Fab\Vidi\Resolver\ContentObjectResolver|object |
|
| 129 | + */ |
|
| 130 | + protected function getContentObjectResolver() |
|
| 131 | + { |
|
| 132 | + return GeneralUtility::makeInstance(\Fab\Vidi\Resolver\ContentObjectResolver::class); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @return \Fab\Vidi\Resolver\FieldPathResolver|object |
|
| 137 | + */ |
|
| 138 | + protected function getFieldPathResolver() |
|
| 139 | + { |
|
| 140 | + return GeneralUtility::makeInstance(\Fab\Vidi\Resolver\FieldPathResolver::class); |
|
| 141 | + } |
|
| 142 | 142 | } |
@@ -20,87 +20,87 @@ |
||
| 20 | 20 | class ContentObjectResolver implements SingletonInterface |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @param Content $object |
|
| 25 | - * @param string $fieldNameAndPath |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function getDataType(Content $object, $fieldNameAndPath) |
|
| 29 | - { |
|
| 30 | - |
|
| 31 | - // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
| 32 | - $relationalFieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
| 33 | - |
|
| 34 | - // Handle case when field name leads to a relation. |
|
| 35 | - if ($object[$relationalFieldName] instanceof Content) { |
|
| 36 | - $resolvedDataType = $object[$relationalFieldName]->getDataType(); |
|
| 37 | - } else { |
|
| 38 | - $resolvedDataType = $object->getDataType(); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - return $resolvedDataType; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Fetch the value of an object according to a field path. |
|
| 46 | - * The returned value can be a string, int or array of Content objects. |
|
| 47 | - * |
|
| 48 | - * @param Content $object |
|
| 49 | - * @param string $fieldNameAndPath |
|
| 50 | - * @param string $fieldName |
|
| 51 | - * @param int $language |
|
| 52 | - * @return mixed |
|
| 53 | - */ |
|
| 54 | - public function getValue(Content $object, $fieldNameAndPath, $fieldName, $language = 0) |
|
| 55 | - { |
|
| 56 | - |
|
| 57 | - $resolvedContentObject = $this->getObject($object, $fieldNameAndPath); |
|
| 58 | - $resolvedValue = $resolvedContentObject[$fieldName]; |
|
| 59 | - |
|
| 60 | - if (is_scalar($resolvedValue) && $language > 0) { |
|
| 61 | - $resolvedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedContentObject, $language, $fieldName); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - return $resolvedValue; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Fetch the value of an object according to a field name and path. |
|
| 69 | - * The returned value is a Content object. |
|
| 70 | - * |
|
| 71 | - * @param Content $object |
|
| 72 | - * @param string $fieldNameAndPath |
|
| 73 | - * @return Content |
|
| 74 | - */ |
|
| 75 | - public function getObject(Content $object, $fieldNameAndPath) |
|
| 76 | - { |
|
| 77 | - |
|
| 78 | - // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
| 79 | - $fieldPath = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
| 80 | - |
|
| 81 | - // Handle case when field name leads to a relation. |
|
| 82 | - if ($object[$fieldPath] instanceof Content) { |
|
| 83 | - $resolvedObject = $object[$fieldPath]; |
|
| 84 | - } else { |
|
| 85 | - $resolvedObject = $object; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return $resolvedObject; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return \Fab\Vidi\Resolver\FieldPathResolver|object |
|
| 93 | - */ |
|
| 94 | - protected function getFieldPathResolver() |
|
| 95 | - { |
|
| 96 | - return GeneralUtility::makeInstance(\Fab\Vidi\Resolver\FieldPathResolver::class); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @return \Fab\Vidi\Language\LanguageService|object |
|
| 101 | - */ |
|
| 102 | - protected function getLanguageService() |
|
| 103 | - { |
|
| 104 | - return GeneralUtility::makeInstance(\Fab\Vidi\Language\LanguageService::class); |
|
| 105 | - } |
|
| 23 | + /** |
|
| 24 | + * @param Content $object |
|
| 25 | + * @param string $fieldNameAndPath |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function getDataType(Content $object, $fieldNameAndPath) |
|
| 29 | + { |
|
| 30 | + |
|
| 31 | + // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
| 32 | + $relationalFieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
| 33 | + |
|
| 34 | + // Handle case when field name leads to a relation. |
|
| 35 | + if ($object[$relationalFieldName] instanceof Content) { |
|
| 36 | + $resolvedDataType = $object[$relationalFieldName]->getDataType(); |
|
| 37 | + } else { |
|
| 38 | + $resolvedDataType = $object->getDataType(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + return $resolvedDataType; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Fetch the value of an object according to a field path. |
|
| 46 | + * The returned value can be a string, int or array of Content objects. |
|
| 47 | + * |
|
| 48 | + * @param Content $object |
|
| 49 | + * @param string $fieldNameAndPath |
|
| 50 | + * @param string $fieldName |
|
| 51 | + * @param int $language |
|
| 52 | + * @return mixed |
|
| 53 | + */ |
|
| 54 | + public function getValue(Content $object, $fieldNameAndPath, $fieldName, $language = 0) |
|
| 55 | + { |
|
| 56 | + |
|
| 57 | + $resolvedContentObject = $this->getObject($object, $fieldNameAndPath); |
|
| 58 | + $resolvedValue = $resolvedContentObject[$fieldName]; |
|
| 59 | + |
|
| 60 | + if (is_scalar($resolvedValue) && $language > 0) { |
|
| 61 | + $resolvedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedContentObject, $language, $fieldName); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + return $resolvedValue; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Fetch the value of an object according to a field name and path. |
|
| 69 | + * The returned value is a Content object. |
|
| 70 | + * |
|
| 71 | + * @param Content $object |
|
| 72 | + * @param string $fieldNameAndPath |
|
| 73 | + * @return Content |
|
| 74 | + */ |
|
| 75 | + public function getObject(Content $object, $fieldNameAndPath) |
|
| 76 | + { |
|
| 77 | + |
|
| 78 | + // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
| 79 | + $fieldPath = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
| 80 | + |
|
| 81 | + // Handle case when field name leads to a relation. |
|
| 82 | + if ($object[$fieldPath] instanceof Content) { |
|
| 83 | + $resolvedObject = $object[$fieldPath]; |
|
| 84 | + } else { |
|
| 85 | + $resolvedObject = $object; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return $resolvedObject; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return \Fab\Vidi\Resolver\FieldPathResolver|object |
|
| 93 | + */ |
|
| 94 | + protected function getFieldPathResolver() |
|
| 95 | + { |
|
| 96 | + return GeneralUtility::makeInstance(\Fab\Vidi\Resolver\FieldPathResolver::class); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @return \Fab\Vidi\Language\LanguageService|object |
|
| 101 | + */ |
|
| 102 | + protected function getLanguageService() |
|
| 103 | + { |
|
| 104 | + return GeneralUtility::makeInstance(\Fab\Vidi\Language\LanguageService::class); |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -18,69 +18,69 @@ |
||
| 18 | 18 | class UserPreferencesController extends ActionController |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $key |
|
| 23 | - * @param string $value |
|
| 24 | - * @param string $preferenceSignature |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function saveAction($key, $value, $preferenceSignature) |
|
| 28 | - { |
|
| 21 | + /** |
|
| 22 | + * @param string $key |
|
| 23 | + * @param string $value |
|
| 24 | + * @param string $preferenceSignature |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function saveAction($key, $value, $preferenceSignature) |
|
| 28 | + { |
|
| 29 | 29 | |
| 30 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
| 30 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
| 31 | 31 | |
| 32 | - $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_' . $key; |
|
| 33 | - $this->getCacheInstance()->set($key, $value, [], 0); |
|
| 32 | + $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_' . $key; |
|
| 33 | + $this->getCacheInstance()->set($key, $value, [], 0); |
|
| 34 | 34 | |
| 35 | - $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_signature'; |
|
| 36 | - $this->getCacheInstance()->set($key, $preferenceSignature, [], 0); |
|
| 35 | + $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_signature'; |
|
| 36 | + $this->getCacheInstance()->set($key, $preferenceSignature, [], 0); |
|
| 37 | 37 | |
| 38 | - return 'OK'; |
|
| 39 | - } |
|
| 38 | + return 'OK'; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @return int |
|
| 43 | - */ |
|
| 44 | - protected function getBackendUserIdentifier() |
|
| 45 | - { |
|
| 46 | - return $this->getBackendUser()->user['uid']; |
|
| 47 | - } |
|
| 41 | + /** |
|
| 42 | + * @return int |
|
| 43 | + */ |
|
| 44 | + protected function getBackendUserIdentifier() |
|
| 45 | + { |
|
| 46 | + return $this->getBackendUser()->user['uid']; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Returns an instance of the current Backend User. |
|
| 51 | - * |
|
| 52 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 53 | - */ |
|
| 54 | - protected function getBackendUser() |
|
| 55 | - { |
|
| 56 | - return $GLOBALS['BE_USER']; |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * Returns an instance of the current Backend User. |
|
| 51 | + * |
|
| 52 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 53 | + */ |
|
| 54 | + protected function getBackendUser() |
|
| 55 | + { |
|
| 56 | + return $GLOBALS['BE_USER']; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Get the Vidi Module Loader. |
|
| 61 | - * |
|
| 62 | - * @return ModuleLoader |
|
| 63 | - */ |
|
| 64 | - protected function getModuleLoader() |
|
| 65 | - { |
|
| 66 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * Get the Vidi Module Loader. |
|
| 61 | + * |
|
| 62 | + * @return ModuleLoader |
|
| 63 | + */ |
|
| 64 | + protected function getModuleLoader() |
|
| 65 | + { |
|
| 66 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @return \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend |
|
| 71 | - */ |
|
| 72 | - protected function getCacheInstance() |
|
| 73 | - { |
|
| 74 | - return $this->getCacheManager()->getCache('vidi'); |
|
| 75 | - } |
|
| 69 | + /** |
|
| 70 | + * @return \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend |
|
| 71 | + */ |
|
| 72 | + protected function getCacheInstance() |
|
| 73 | + { |
|
| 74 | + return $this->getCacheManager()->getCache('vidi'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Return the Cache Manager |
|
| 79 | - * |
|
| 80 | - * @return \TYPO3\CMS\Core\Cache\CacheManager |
|
| 81 | - */ |
|
| 82 | - protected function getCacheManager() |
|
| 83 | - { |
|
| 84 | - return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); |
|
| 85 | - } |
|
| 77 | + /** |
|
| 78 | + * Return the Cache Manager |
|
| 79 | + * |
|
| 80 | + * @return \TYPO3\CMS\Core\Cache\CacheManager |
|
| 81 | + */ |
|
| 82 | + protected function getCacheManager() |
|
| 83 | + { |
|
| 84 | + return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -23,59 +23,59 @@ |
||
| 23 | 23 | class VidiCommandController extends Command |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Configure the command by defining the name, options and arguments |
|
| 28 | - */ |
|
| 29 | - protected function configure() |
|
| 30 | - { |
|
| 31 | - $this->setDescription('Check TCA configuration for relations used in grid.') |
|
| 32 | - ->addOption( |
|
| 33 | - 'table', |
|
| 34 | - 'c', |
|
| 35 | - InputOption::VALUE_NONE, |
|
| 36 | - 'The table name. If not defined check for every table.' |
|
| 37 | - ); |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * Configure the command by defining the name, options and arguments |
|
| 28 | + */ |
|
| 29 | + protected function configure() |
|
| 30 | + { |
|
| 31 | + $this->setDescription('Check TCA configuration for relations used in grid.') |
|
| 32 | + ->addOption( |
|
| 33 | + 'table', |
|
| 34 | + 'c', |
|
| 35 | + InputOption::VALUE_NONE, |
|
| 36 | + 'The table name. If not defined check for every table.' |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Executes the command for removing the lock file |
|
| 42 | - * |
|
| 43 | - * @param InputInterface $input |
|
| 44 | - * @param OutputInterface $output |
|
| 45 | - */ |
|
| 46 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 47 | - { |
|
| 48 | - $io = new SymfonyStyle($input, $output); |
|
| 49 | - foreach ($GLOBALS['TCA'] as $tableName => $TCA) { |
|
| 50 | - $table = $input->getOption('table'); |
|
| 51 | - if ($table !== '' && $table !== $tableName) { |
|
| 52 | - continue; |
|
| 53 | - } |
|
| 40 | + /** |
|
| 41 | + * Executes the command for removing the lock file |
|
| 42 | + * |
|
| 43 | + * @param InputInterface $input |
|
| 44 | + * @param OutputInterface $output |
|
| 45 | + */ |
|
| 46 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 47 | + { |
|
| 48 | + $io = new SymfonyStyle($input, $output); |
|
| 49 | + foreach ($GLOBALS['TCA'] as $tableName => $TCA) { |
|
| 50 | + $table = $input->getOption('table'); |
|
| 51 | + if ($table !== '' && $table !== $tableName) { |
|
| 52 | + continue; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $fields = Tca::grid($tableName)->getFields(); |
|
| 56 | - if (!empty($fields)) { |
|
| 55 | + $fields = Tca::grid($tableName)->getFields(); |
|
| 56 | + if (!empty($fields)) { |
|
| 57 | 57 | |
| 58 | - $relations = $this->getGridAnalyserService()->checkRelationForTable($tableName); |
|
| 59 | - if (!empty($relations)) { |
|
| 58 | + $relations = $this->getGridAnalyserService()->checkRelationForTable($tableName); |
|
| 59 | + if (!empty($relations)) { |
|
| 60 | 60 | |
| 61 | - $io->text(''); |
|
| 62 | - $io->text('--------------------------------------------------------------------'); |
|
| 63 | - $io->text(''); |
|
| 64 | - $io->text(sprintf('Relations for "%s"', $tableName)); |
|
| 65 | - $io->text(''); |
|
| 66 | - $io->text(implode("\n", $relations)); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 61 | + $io->text(''); |
|
| 62 | + $io->text('--------------------------------------------------------------------'); |
|
| 63 | + $io->text(''); |
|
| 64 | + $io->text(sprintf('Relations for "%s"', $tableName)); |
|
| 65 | + $io->text(''); |
|
| 66 | + $io->text(implode("\n", $relations)); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Get the Vidi Module Loader. |
|
| 74 | - * |
|
| 75 | - * @return \Fab\Vidi\Grid\GridAnalyserService|object |
|
| 76 | - */ |
|
| 77 | - protected function getGridAnalyserService() |
|
| 78 | - { |
|
| 79 | - return GeneralUtility::makeInstance(\Fab\Vidi\Grid\GridAnalyserService::class); |
|
| 80 | - } |
|
| 72 | + /** |
|
| 73 | + * Get the Vidi Module Loader. |
|
| 74 | + * |
|
| 75 | + * @return \Fab\Vidi\Grid\GridAnalyserService|object |
|
| 76 | + */ |
|
| 77 | + protected function getGridAnalyserService() |
|
| 78 | + { |
|
| 79 | + return GeneralUtility::makeInstance(\Fab\Vidi\Grid\GridAnalyserService::class); |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -18,83 +18,83 @@ |
||
| 18 | 18 | class ClipboardService implements SingletonInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Get the Matcher object of the clipboard. |
|
| 23 | - * |
|
| 24 | - * @return Matcher |
|
| 25 | - */ |
|
| 26 | - public function getMatcher() |
|
| 27 | - { |
|
| 28 | - $matcher = $this->getBackendUser()->getModuleData($this->getDataKey()); |
|
| 29 | - if (!$matcher) { |
|
| 30 | - /** @var $matcher Matcher */ |
|
| 31 | - $matcher = GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Matcher::class); |
|
| 32 | - } |
|
| 33 | - return $matcher; |
|
| 34 | - } |
|
| 21 | + /** |
|
| 22 | + * Get the Matcher object of the clipboard. |
|
| 23 | + * |
|
| 24 | + * @return Matcher |
|
| 25 | + */ |
|
| 26 | + public function getMatcher() |
|
| 27 | + { |
|
| 28 | + $matcher = $this->getBackendUser()->getModuleData($this->getDataKey()); |
|
| 29 | + if (!$matcher) { |
|
| 30 | + /** @var $matcher Matcher */ |
|
| 31 | + $matcher = GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Matcher::class); |
|
| 32 | + } |
|
| 33 | + return $matcher; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Tell whether the clipboard has items or not. |
|
| 38 | - * |
|
| 39 | - * @return bool |
|
| 40 | - */ |
|
| 41 | - public function hasItems() |
|
| 42 | - { |
|
| 43 | - $matcher = $this->getMatcher(); |
|
| 36 | + /** |
|
| 37 | + * Tell whether the clipboard has items or not. |
|
| 38 | + * |
|
| 39 | + * @return bool |
|
| 40 | + */ |
|
| 41 | + public function hasItems() |
|
| 42 | + { |
|
| 43 | + $matcher = $this->getMatcher(); |
|
| 44 | 44 | |
| 45 | - $inCriteria = $matcher->getIn(); |
|
| 46 | - $likeCriteria = $matcher->getLike(); |
|
| 47 | - $searchTerm = $matcher->getSearchTerm(); |
|
| 45 | + $inCriteria = $matcher->getIn(); |
|
| 46 | + $likeCriteria = $matcher->getLike(); |
|
| 47 | + $searchTerm = $matcher->getSearchTerm(); |
|
| 48 | 48 | |
| 49 | - $hasItems = !empty($inCriteria) || !empty($likeCriteria) || !empty($searchTerm); |
|
| 50 | - return $hasItems; |
|
| 51 | - } |
|
| 49 | + $hasItems = !empty($inCriteria) || !empty($likeCriteria) || !empty($searchTerm); |
|
| 50 | + return $hasItems; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Save data into the clipboard. |
|
| 55 | - * |
|
| 56 | - * @param Matcher $matches |
|
| 57 | - */ |
|
| 58 | - public function save(Matcher $matches) |
|
| 59 | - { |
|
| 60 | - $this->getBackendUser()->pushModuleData($this->getDataKey(), $matches); |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Save data into the clipboard. |
|
| 55 | + * |
|
| 56 | + * @param Matcher $matches |
|
| 57 | + */ |
|
| 58 | + public function save(Matcher $matches) |
|
| 59 | + { |
|
| 60 | + $this->getBackendUser()->pushModuleData($this->getDataKey(), $matches); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Completely empty the clipboard for a data type. |
|
| 65 | - * |
|
| 66 | - * @return void |
|
| 67 | - */ |
|
| 68 | - public function flush() |
|
| 69 | - { |
|
| 70 | - $this->getBackendUser()->pushModuleData($this->getDataKey(), null); |
|
| 71 | - } |
|
| 63 | + /** |
|
| 64 | + * Completely empty the clipboard for a data type. |
|
| 65 | + * |
|
| 66 | + * @return void |
|
| 67 | + */ |
|
| 68 | + public function flush() |
|
| 69 | + { |
|
| 70 | + $this->getBackendUser()->pushModuleData($this->getDataKey(), null); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 76 | - protected function getDataKey() |
|
| 77 | - { |
|
| 78 | - return 'vidi_clipboard_' . $this->getModuleLoader()->getDataType(); |
|
| 79 | - } |
|
| 73 | + /** |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | + protected function getDataKey() |
|
| 77 | + { |
|
| 78 | + return 'vidi_clipboard_' . $this->getModuleLoader()->getDataType(); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Get the Vidi Module Loader. |
|
| 83 | - * |
|
| 84 | - * @return \Fab\Vidi\Module\ModuleLoader|object |
|
| 85 | - */ |
|
| 86 | - protected function getModuleLoader() |
|
| 87 | - { |
|
| 88 | - return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class); |
|
| 89 | - } |
|
| 81 | + /** |
|
| 82 | + * Get the Vidi Module Loader. |
|
| 83 | + * |
|
| 84 | + * @return \Fab\Vidi\Module\ModuleLoader|object |
|
| 85 | + */ |
|
| 86 | + protected function getModuleLoader() |
|
| 87 | + { |
|
| 88 | + return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleLoader::class); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Returns an instance of the current Backend User. |
|
| 93 | - * |
|
| 94 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 95 | - */ |
|
| 96 | - protected function getBackendUser() |
|
| 97 | - { |
|
| 98 | - return $GLOBALS['BE_USER']; |
|
| 99 | - } |
|
| 91 | + /** |
|
| 92 | + * Returns an instance of the current Backend User. |
|
| 93 | + * |
|
| 94 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 95 | + */ |
|
| 96 | + protected function getBackendUser() |
|
| 97 | + { |
|
| 98 | + return $GLOBALS['BE_USER']; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -16,54 +16,54 @@ |
||
| 16 | 16 | class BackendUserPreferenceService |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Returns a class instance |
|
| 21 | - * |
|
| 22 | - * @return \Fab\Vidi\Service\BackendUserPreferenceService|object |
|
| 23 | - */ |
|
| 24 | - static public function getInstance() |
|
| 25 | - { |
|
| 26 | - return GeneralUtility::makeInstance(\Fab\Vidi\Service\BackendUserPreferenceService::class); |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * Returns a class instance |
|
| 21 | + * |
|
| 22 | + * @return \Fab\Vidi\Service\BackendUserPreferenceService|object |
|
| 23 | + */ |
|
| 24 | + static public function getInstance() |
|
| 25 | + { |
|
| 26 | + return GeneralUtility::makeInstance(\Fab\Vidi\Service\BackendUserPreferenceService::class); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Returns a configuration key for the current BE User. |
|
| 31 | - * |
|
| 32 | - * @param string $key |
|
| 33 | - * @return mixed |
|
| 34 | - */ |
|
| 35 | - public function get($key) |
|
| 36 | - { |
|
| 37 | - $result = ''; |
|
| 38 | - if ($this->getBackendUser() && !empty($this->getBackendUser()->uc[$key])) { |
|
| 39 | - $result = $this->getBackendUser()->uc[$key]; |
|
| 29 | + /** |
|
| 30 | + * Returns a configuration key for the current BE User. |
|
| 31 | + * |
|
| 32 | + * @param string $key |
|
| 33 | + * @return mixed |
|
| 34 | + */ |
|
| 35 | + public function get($key) |
|
| 36 | + { |
|
| 37 | + $result = ''; |
|
| 38 | + if ($this->getBackendUser() && !empty($this->getBackendUser()->uc[$key])) { |
|
| 39 | + $result = $this->getBackendUser()->uc[$key]; |
|
| 40 | 40 | |
| 41 | - } |
|
| 42 | - return $result; |
|
| 43 | - } |
|
| 41 | + } |
|
| 42 | + return $result; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Set a configuration for the current BE User. |
|
| 47 | - * |
|
| 48 | - * @param string $key |
|
| 49 | - * @param mixed $value |
|
| 50 | - * @return void |
|
| 51 | - */ |
|
| 52 | - public function set($key, $value) |
|
| 53 | - { |
|
| 54 | - if ($this->getBackendUser()) { |
|
| 55 | - $this->getBackendUser()->uc[$key] = $value; |
|
| 56 | - $this->getBackendUser()->writeUC(); |
|
| 57 | - } |
|
| 58 | - } |
|
| 45 | + /** |
|
| 46 | + * Set a configuration for the current BE User. |
|
| 47 | + * |
|
| 48 | + * @param string $key |
|
| 49 | + * @param mixed $value |
|
| 50 | + * @return void |
|
| 51 | + */ |
|
| 52 | + public function set($key, $value) |
|
| 53 | + { |
|
| 54 | + if ($this->getBackendUser()) { |
|
| 55 | + $this->getBackendUser()->uc[$key] = $value; |
|
| 56 | + $this->getBackendUser()->writeUC(); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Returns an instance of the current Backend User. |
|
| 62 | - * |
|
| 63 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 64 | - */ |
|
| 65 | - protected function getBackendUser() |
|
| 66 | - { |
|
| 67 | - return $GLOBALS['BE_USER']; |
|
| 68 | - } |
|
| 60 | + /** |
|
| 61 | + * Returns an instance of the current Backend User. |
|
| 62 | + * |
|
| 63 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 64 | + */ |
|
| 65 | + protected function getBackendUser() |
|
| 66 | + { |
|
| 67 | + return $GLOBALS['BE_USER']; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -17,48 +17,48 @@ |
||
| 17 | 17 | class PagerObjectFactory implements SingletonInterface |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Gets a singleton instance of this class. |
|
| 22 | - * |
|
| 23 | - * @return \Fab\Vidi\Persistence\PagerObjectFactory|object |
|
| 24 | - */ |
|
| 25 | - static public function getInstance() |
|
| 26 | - { |
|
| 27 | - return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\PagerObjectFactory::class); |
|
| 28 | - } |
|
| 20 | + /** |
|
| 21 | + * Gets a singleton instance of this class. |
|
| 22 | + * |
|
| 23 | + * @return \Fab\Vidi\Persistence\PagerObjectFactory|object |
|
| 24 | + */ |
|
| 25 | + static public function getInstance() |
|
| 26 | + { |
|
| 27 | + return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\PagerObjectFactory::class); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Returns a pager object. |
|
| 32 | - * |
|
| 33 | - * @return \Fab\Vidi\Persistence\Pager |
|
| 34 | - */ |
|
| 35 | - public function getPager() |
|
| 36 | - { |
|
| 30 | + /** |
|
| 31 | + * Returns a pager object. |
|
| 32 | + * |
|
| 33 | + * @return \Fab\Vidi\Persistence\Pager |
|
| 34 | + */ |
|
| 35 | + public function getPager() |
|
| 36 | + { |
|
| 37 | 37 | |
| 38 | - /** @var $pager \Fab\Vidi\Persistence\Pager */ |
|
| 39 | - $pager = GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Pager::class); |
|
| 38 | + /** @var $pager \Fab\Vidi\Persistence\Pager */ |
|
| 39 | + $pager = GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Pager::class); |
|
| 40 | 40 | |
| 41 | - // Set items per page |
|
| 42 | - if (GeneralUtility::_GET('length') !== null) { |
|
| 43 | - $limit = (int)GeneralUtility::_GET('length'); |
|
| 44 | - $pager->setLimit($limit); |
|
| 45 | - } |
|
| 41 | + // Set items per page |
|
| 42 | + if (GeneralUtility::_GET('length') !== null) { |
|
| 43 | + $limit = (int)GeneralUtility::_GET('length'); |
|
| 44 | + $pager->setLimit($limit); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // Set offset |
|
| 48 | - $offset = 0; |
|
| 49 | - if (GeneralUtility::_GET('start') !== null) { |
|
| 50 | - $offset = (int)GeneralUtility::_GET('start'); |
|
| 51 | - } |
|
| 52 | - $pager->setOffset($offset); |
|
| 47 | + // Set offset |
|
| 48 | + $offset = 0; |
|
| 49 | + if (GeneralUtility::_GET('start') !== null) { |
|
| 50 | + $offset = (int)GeneralUtility::_GET('start'); |
|
| 51 | + } |
|
| 52 | + $pager->setOffset($offset); |
|
| 53 | 53 | |
| 54 | - // set page |
|
| 55 | - $page = 1; |
|
| 56 | - if ($pager->getLimit() > 0) { |
|
| 57 | - $page = round($pager->getOffset() / $pager->getLimit()); |
|
| 58 | - } |
|
| 59 | - $pager->setPage($page); |
|
| 54 | + // set page |
|
| 55 | + $page = 1; |
|
| 56 | + if ($pager->getLimit() > 0) { |
|
| 57 | + $page = round($pager->getOffset() / $pager->getLimit()); |
|
| 58 | + } |
|
| 59 | + $pager->setPage($page); |
|
| 60 | 60 | |
| 61 | - return $pager; |
|
| 62 | - } |
|
| 61 | + return $pager; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | } |
@@ -18,43 +18,43 @@ |
||
| 18 | 18 | class OrderObjectFactory implements SingletonInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Gets a singleton instance of this class. |
|
| 23 | - * |
|
| 24 | - * @return \Fab\Vidi\Persistence\OrderObjectFactory|object |
|
| 25 | - */ |
|
| 26 | - static public function getInstance() |
|
| 27 | - { |
|
| 28 | - return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\OrderObjectFactory::class); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Returns an order object. |
|
| 33 | - * |
|
| 34 | - * @param string $dataType |
|
| 35 | - * @return \Fab\Vidi\Persistence\Order|object |
|
| 36 | - */ |
|
| 37 | - public function getOrder($dataType = '') |
|
| 38 | - { |
|
| 39 | - |
|
| 40 | - // Default ordering |
|
| 41 | - $order = Tca::table($dataType)->getDefaultOrderings(); |
|
| 42 | - |
|
| 43 | - // Retrieve a possible id of the column from the request |
|
| 44 | - $orderings = GeneralUtility::_GP('order'); |
|
| 45 | - |
|
| 46 | - if (is_array($orderings) && isset($orderings[0])) { |
|
| 47 | - $columnPosition = $orderings[0]['column']; |
|
| 48 | - $direction = $orderings[0]['dir']; |
|
| 49 | - |
|
| 50 | - if ($columnPosition > 0) { |
|
| 51 | - $field = Tca::grid()->getFieldNameByPosition($columnPosition); |
|
| 52 | - |
|
| 53 | - $order = array( |
|
| 54 | - $field => strtoupper($direction) |
|
| 55 | - ); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Order::class, $order); |
|
| 59 | - } |
|
| 21 | + /** |
|
| 22 | + * Gets a singleton instance of this class. |
|
| 23 | + * |
|
| 24 | + * @return \Fab\Vidi\Persistence\OrderObjectFactory|object |
|
| 25 | + */ |
|
| 26 | + static public function getInstance() |
|
| 27 | + { |
|
| 28 | + return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\OrderObjectFactory::class); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Returns an order object. |
|
| 33 | + * |
|
| 34 | + * @param string $dataType |
|
| 35 | + * @return \Fab\Vidi\Persistence\Order|object |
|
| 36 | + */ |
|
| 37 | + public function getOrder($dataType = '') |
|
| 38 | + { |
|
| 39 | + |
|
| 40 | + // Default ordering |
|
| 41 | + $order = Tca::table($dataType)->getDefaultOrderings(); |
|
| 42 | + |
|
| 43 | + // Retrieve a possible id of the column from the request |
|
| 44 | + $orderings = GeneralUtility::_GP('order'); |
|
| 45 | + |
|
| 46 | + if (is_array($orderings) && isset($orderings[0])) { |
|
| 47 | + $columnPosition = $orderings[0]['column']; |
|
| 48 | + $direction = $orderings[0]['dir']; |
|
| 49 | + |
|
| 50 | + if ($columnPosition > 0) { |
|
| 51 | + $field = Tca::grid()->getFieldNameByPosition($columnPosition); |
|
| 52 | + |
|
| 53 | + $order = array( |
|
| 54 | + $field => strtoupper($direction) |
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Order::class, $order); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -18,68 +18,68 @@ |
||
| 18 | 18 | class ConfigurationUtility implements SingletonInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $extensionKey = 'vidi'; |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $extensionKey = 'vidi'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - protected $configuration = []; |
|
| 26 | + /** |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + protected $configuration = []; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Returns a class instance. |
|
| 33 | - * |
|
| 34 | - * @return ConfigurationUtility|object |
|
| 35 | - * @throws \InvalidArgumentException |
|
| 36 | - */ |
|
| 37 | - static public function getInstance() |
|
| 38 | - { |
|
| 39 | - return GeneralUtility::makeInstance(self::class); |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * Returns a class instance. |
|
| 33 | + * |
|
| 34 | + * @return ConfigurationUtility|object |
|
| 35 | + * @throws \InvalidArgumentException |
|
| 36 | + */ |
|
| 37 | + static public function getInstance() |
|
| 38 | + { |
|
| 39 | + return GeneralUtility::makeInstance(self::class); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Constructor |
|
| 44 | - */ |
|
| 45 | - public function __construct() |
|
| 46 | - { |
|
| 47 | - $configuration = $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get($this->extensionKey); |
|
| 42 | + /** |
|
| 43 | + * Constructor |
|
| 44 | + */ |
|
| 45 | + public function __construct() |
|
| 46 | + { |
|
| 47 | + $configuration = $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get($this->extensionKey); |
|
| 48 | 48 | |
| 49 | - // Fill up configuration array with relevant values. |
|
| 50 | - foreach ($configuration as $key => $value) { |
|
| 51 | - $this->configuration[$key] = $value; |
|
| 52 | - } |
|
| 53 | - } |
|
| 49 | + // Fill up configuration array with relevant values. |
|
| 50 | + foreach ($configuration as $key => $value) { |
|
| 51 | + $this->configuration[$key] = $value; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Returns a setting key. |
|
| 57 | - * |
|
| 58 | - * @param string $key |
|
| 59 | - * @return array |
|
| 60 | - */ |
|
| 61 | - public function get($key) |
|
| 62 | - { |
|
| 63 | - return isset($this->configuration[$key]) ? $this->configuration[$key] : null; |
|
| 64 | - } |
|
| 55 | + /** |
|
| 56 | + * Returns a setting key. |
|
| 57 | + * |
|
| 58 | + * @param string $key |
|
| 59 | + * @return array |
|
| 60 | + */ |
|
| 61 | + public function get($key) |
|
| 62 | + { |
|
| 63 | + return isset($this->configuration[$key]) ? $this->configuration[$key] : null; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Set a setting key. |
|
| 68 | - * |
|
| 69 | - * @param string $key |
|
| 70 | - * @param mixed $value |
|
| 71 | - * @return void |
|
| 72 | - */ |
|
| 73 | - public function set($key, $value) |
|
| 74 | - { |
|
| 75 | - $this->configuration[$key] = $value; |
|
| 76 | - } |
|
| 66 | + /** |
|
| 67 | + * Set a setting key. |
|
| 68 | + * |
|
| 69 | + * @param string $key |
|
| 70 | + * @param mixed $value |
|
| 71 | + * @return void |
|
| 72 | + */ |
|
| 73 | + public function set($key, $value) |
|
| 74 | + { |
|
| 75 | + $this->configuration[$key] = $value; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - public function getConfiguration() |
|
| 82 | - { |
|
| 83 | - return $this->configuration; |
|
| 84 | - } |
|
| 78 | + /** |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + public function getConfiguration() |
|
| 82 | + { |
|
| 83 | + return $this->configuration; |
|
| 84 | + } |
|
| 85 | 85 | } |