@@ -18,51 +18,51 @@ |
||
| 18 | 18 | abstract class AbstractTool implements ToolInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $templateNameAndPath |
|
| 23 | - * @return StandaloneView |
|
| 24 | - * @throws \InvalidArgumentException |
|
| 25 | - */ |
|
| 26 | - protected function initializeStandaloneView($templateNameAndPath) |
|
| 27 | - { |
|
| 21 | + /** |
|
| 22 | + * @param string $templateNameAndPath |
|
| 23 | + * @return StandaloneView |
|
| 24 | + * @throws \InvalidArgumentException |
|
| 25 | + */ |
|
| 26 | + protected function initializeStandaloneView($templateNameAndPath) |
|
| 27 | + { |
|
| 28 | 28 | |
| 29 | - $templateNameAndPath = GeneralUtility::getFileAbsFileName($templateNameAndPath); |
|
| 29 | + $templateNameAndPath = GeneralUtility::getFileAbsFileName($templateNameAndPath); |
|
| 30 | 30 | |
| 31 | - /** @var StandaloneView $view */ |
|
| 32 | - $view = $this->getObjectManager()->get(StandaloneView::class); |
|
| 31 | + /** @var StandaloneView $view */ |
|
| 32 | + $view = $this->getObjectManager()->get(StandaloneView::class); |
|
| 33 | 33 | |
| 34 | - $view->setTemplatePathAndFilename($templateNameAndPath); |
|
| 35 | - return $view; |
|
| 36 | - } |
|
| 34 | + $view->setTemplatePathAndFilename($templateNameAndPath); |
|
| 35 | + return $view; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Returns an instance of the current Backend User. |
|
| 40 | - * |
|
| 41 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 42 | - */ |
|
| 43 | - protected function getBackendUser() |
|
| 44 | - { |
|
| 45 | - return $GLOBALS['BE_USER']; |
|
| 46 | - } |
|
| 38 | + /** |
|
| 39 | + * Returns an instance of the current Backend User. |
|
| 40 | + * |
|
| 41 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 42 | + */ |
|
| 43 | + protected function getBackendUser() |
|
| 44 | + { |
|
| 45 | + return $GLOBALS['BE_USER']; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @return ObjectManager |
|
| 50 | - * @throws \InvalidArgumentException |
|
| 51 | - */ |
|
| 52 | - protected function getObjectManager() |
|
| 53 | - { |
|
| 54 | - return GeneralUtility::makeInstance(ObjectManager::class); |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * @return ObjectManager |
|
| 50 | + * @throws \InvalidArgumentException |
|
| 51 | + */ |
|
| 52 | + protected function getObjectManager() |
|
| 53 | + { |
|
| 54 | + return GeneralUtility::makeInstance(ObjectManager::class); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Get the Vidi Module Loader. |
|
| 59 | - * |
|
| 60 | - * @return ModuleLoader |
|
| 61 | - * @throws \InvalidArgumentException |
|
| 62 | - */ |
|
| 63 | - protected function getModuleLoader() |
|
| 64 | - { |
|
| 65 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 66 | - } |
|
| 57 | + /** |
|
| 58 | + * Get the Vidi Module Loader. |
|
| 59 | + * |
|
| 60 | + * @return ModuleLoader |
|
| 61 | + * @throws \InvalidArgumentException |
|
| 62 | + */ |
|
| 63 | + protected function getModuleLoader() |
|
| 64 | + { |
|
| 65 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | } |
@@ -24,174 +24,174 @@ |
||
| 24 | 24 | class FindOneViewHelper extends AbstractViewHelper implements CompilableInterface |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @return void |
|
| 29 | - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception |
|
| 30 | - */ |
|
| 31 | - public function initializeArguments() |
|
| 32 | - { |
|
| 33 | - parent::initializeArguments(); |
|
| 34 | - |
|
| 35 | - $this->registerArgument('type', 'string', 'The content type', true, ''); |
|
| 36 | - $this->registerArgument('matches', 'array', 'Key / value array to be used as filter. The key corresponds to a field name.', false, []); |
|
| 37 | - $this->registerArgument('identifier', 'int', 'The identifier of the object to be fetched.', false, 0); |
|
| 38 | - $this->registerArgument('argumentName', 'string', 'The parameter name where to retrieve the identifier', false, 'tx_vidifrontend_pi1|uid'); |
|
| 39 | - $this->registerArgument('as', 'string', 'The alias object', false, 'object'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @return string Rendered string |
|
| 44 | - * @throws \Fab\Vidi\Exception\NotExistingClassException |
|
| 45 | - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException |
|
| 46 | - * @throws \InvalidArgumentException |
|
| 47 | - * @api |
|
| 48 | - */ |
|
| 49 | - public function render() |
|
| 50 | - { |
|
| 51 | - return static::renderStatic( |
|
| 52 | - $this->arguments, |
|
| 53 | - $this->buildRenderChildrenClosure(), |
|
| 54 | - $this->renderingContext |
|
| 55 | - ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @param array $arguments |
|
| 60 | - * @param \Closure $renderChildrenClosure |
|
| 61 | - * @param RenderingContextInterface $renderingContext |
|
| 62 | - * |
|
| 63 | - * @return string |
|
| 64 | - * @throws \Fab\Vidi\Exception\NotExistingClassException |
|
| 65 | - * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException |
|
| 66 | - * @throws \InvalidArgumentException |
|
| 67 | - */ |
|
| 68 | - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
|
| 69 | - { |
|
| 70 | - |
|
| 71 | - // Fetch the object |
|
| 72 | - $matches = self::computeMatches($arguments); |
|
| 73 | - $matcher = self::getMatcher($arguments['type'], $matches); |
|
| 74 | - |
|
| 75 | - $contentRepository = ContentRepositoryFactory::getInstance($arguments['type']); |
|
| 76 | - $object = $contentRepository->findOneBy($matcher); |
|
| 77 | - |
|
| 78 | - $output = ''; |
|
| 79 | - if ($object) { |
|
| 80 | - // Render children with "as" variable. |
|
| 81 | - $templateVariableContainer = $renderingContext->getTemplateVariableContainer(); |
|
| 82 | - $templateVariableContainer->add($arguments['as'], $object); |
|
| 83 | - $output = $renderChildrenClosure(); |
|
| 84 | - $templateVariableContainer->remove($arguments['as']); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return $output; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param array $arguments |
|
| 92 | - * @return array |
|
| 93 | - */ |
|
| 94 | - protected static function computeMatches(array $arguments) |
|
| 95 | - { |
|
| 96 | - |
|
| 97 | - $matches = []; |
|
| 98 | - |
|
| 99 | - $argumentValue = self::getArgumentValue($arguments['argumentName']); |
|
| 100 | - if ($argumentValue > 0) { |
|
| 101 | - $matches['uid'] = $argumentValue; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - if ($arguments['matches']) { |
|
| 105 | - $matches = $arguments['matches']; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if ($arguments['identifier'] > 0) { |
|
| 109 | - $matches['uid'] = $arguments['identifier']; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // We want a default value in any case. |
|
| 113 | - if (!$matches) { |
|
| 114 | - $matches['uid'] = 0; |
|
| 115 | - } |
|
| 116 | - return $matches; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Returns a matcher object. |
|
| 121 | - * |
|
| 122 | - * @param string $dataType |
|
| 123 | - * @param array $matches |
|
| 124 | - * @return Matcher |
|
| 125 | - * @throws \Fab\Vidi\Exception\NotExistingClassException |
|
| 126 | - * @throws \InvalidArgumentException |
|
| 127 | - */ |
|
| 128 | - protected static function getMatcher($dataType, array $matches = []) |
|
| 129 | - { |
|
| 130 | - |
|
| 131 | - /** @var $matcher Matcher */ |
|
| 132 | - $matcher = GeneralUtility::makeInstance(Matcher::class, [], $dataType); |
|
| 133 | - |
|
| 134 | - foreach ($matches as $fieldNameAndPath => $value) { |
|
| 135 | - |
|
| 136 | - // CSV values should be considered as "in" operator in Query, otherwise "equals". |
|
| 137 | - $explodedValues = GeneralUtility::trimExplode(',', $value, true); |
|
| 138 | - |
|
| 139 | - // The matching value contains a "1,2" as example |
|
| 140 | - if (count($explodedValues) > 1) { |
|
| 141 | - |
|
| 142 | - $resolvedDataType = self::getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType); |
|
| 143 | - $resolvedFieldName = self::getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType); |
|
| 144 | - |
|
| 145 | - // "equals" if in presence of a relation. |
|
| 146 | - // "in" if not a relation. |
|
| 147 | - if (Tca::table($resolvedDataType)->field($resolvedFieldName)->hasRelation()) { |
|
| 148 | - foreach ($explodedValues as $explodedValue) { |
|
| 149 | - $matcher->equals($fieldNameAndPath, $explodedValue); |
|
| 150 | - } |
|
| 151 | - } else { |
|
| 152 | - $matcher->in($fieldNameAndPath, $explodedValues); |
|
| 153 | - } |
|
| 154 | - } else { |
|
| 155 | - $matcher->equals($fieldNameAndPath, $explodedValues[0]); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - return $matcher; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @return FieldPathResolver |
|
| 164 | - * @throws \InvalidArgumentException |
|
| 165 | - */ |
|
| 166 | - protected static function getFieldPathResolver() |
|
| 167 | - { |
|
| 168 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @param string $argumentName |
|
| 173 | - * @return int |
|
| 174 | - */ |
|
| 175 | - protected static function getArgumentValue($argumentName) |
|
| 176 | - { |
|
| 177 | - |
|
| 178 | - $value = ''; // default value |
|
| 179 | - |
|
| 180 | - // Merge parameters |
|
| 181 | - $parameters = GeneralUtility::_GET(); |
|
| 182 | - $post = GeneralUtility::_POST(); |
|
| 183 | - ArrayUtility::mergeRecursiveWithOverrule($parameters, $post); |
|
| 184 | - |
|
| 185 | - // Traverse argument parts and retrieve value. |
|
| 186 | - $argumentParts = GeneralUtility::trimExplode('|', $argumentName); |
|
| 187 | - foreach ($argumentParts as $argumentPart) { |
|
| 188 | - if (isset($parameters[$argumentPart])) { |
|
| 189 | - $value = $parameters[$argumentPart]; |
|
| 190 | - $parameters = $value; |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - return (int)$value; |
|
| 195 | - } |
|
| 27 | + /** |
|
| 28 | + * @return void |
|
| 29 | + * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception |
|
| 30 | + */ |
|
| 31 | + public function initializeArguments() |
|
| 32 | + { |
|
| 33 | + parent::initializeArguments(); |
|
| 34 | + |
|
| 35 | + $this->registerArgument('type', 'string', 'The content type', true, ''); |
|
| 36 | + $this->registerArgument('matches', 'array', 'Key / value array to be used as filter. The key corresponds to a field name.', false, []); |
|
| 37 | + $this->registerArgument('identifier', 'int', 'The identifier of the object to be fetched.', false, 0); |
|
| 38 | + $this->registerArgument('argumentName', 'string', 'The parameter name where to retrieve the identifier', false, 'tx_vidifrontend_pi1|uid'); |
|
| 39 | + $this->registerArgument('as', 'string', 'The alias object', false, 'object'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @return string Rendered string |
|
| 44 | + * @throws \Fab\Vidi\Exception\NotExistingClassException |
|
| 45 | + * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException |
|
| 46 | + * @throws \InvalidArgumentException |
|
| 47 | + * @api |
|
| 48 | + */ |
|
| 49 | + public function render() |
|
| 50 | + { |
|
| 51 | + return static::renderStatic( |
|
| 52 | + $this->arguments, |
|
| 53 | + $this->buildRenderChildrenClosure(), |
|
| 54 | + $this->renderingContext |
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @param array $arguments |
|
| 60 | + * @param \Closure $renderChildrenClosure |
|
| 61 | + * @param RenderingContextInterface $renderingContext |
|
| 62 | + * |
|
| 63 | + * @return string |
|
| 64 | + * @throws \Fab\Vidi\Exception\NotExistingClassException |
|
| 65 | + * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException |
|
| 66 | + * @throws \InvalidArgumentException |
|
| 67 | + */ |
|
| 68 | + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
|
| 69 | + { |
|
| 70 | + |
|
| 71 | + // Fetch the object |
|
| 72 | + $matches = self::computeMatches($arguments); |
|
| 73 | + $matcher = self::getMatcher($arguments['type'], $matches); |
|
| 74 | + |
|
| 75 | + $contentRepository = ContentRepositoryFactory::getInstance($arguments['type']); |
|
| 76 | + $object = $contentRepository->findOneBy($matcher); |
|
| 77 | + |
|
| 78 | + $output = ''; |
|
| 79 | + if ($object) { |
|
| 80 | + // Render children with "as" variable. |
|
| 81 | + $templateVariableContainer = $renderingContext->getTemplateVariableContainer(); |
|
| 82 | + $templateVariableContainer->add($arguments['as'], $object); |
|
| 83 | + $output = $renderChildrenClosure(); |
|
| 84 | + $templateVariableContainer->remove($arguments['as']); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + return $output; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @param array $arguments |
|
| 92 | + * @return array |
|
| 93 | + */ |
|
| 94 | + protected static function computeMatches(array $arguments) |
|
| 95 | + { |
|
| 96 | + |
|
| 97 | + $matches = []; |
|
| 98 | + |
|
| 99 | + $argumentValue = self::getArgumentValue($arguments['argumentName']); |
|
| 100 | + if ($argumentValue > 0) { |
|
| 101 | + $matches['uid'] = $argumentValue; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + if ($arguments['matches']) { |
|
| 105 | + $matches = $arguments['matches']; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if ($arguments['identifier'] > 0) { |
|
| 109 | + $matches['uid'] = $arguments['identifier']; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // We want a default value in any case. |
|
| 113 | + if (!$matches) { |
|
| 114 | + $matches['uid'] = 0; |
|
| 115 | + } |
|
| 116 | + return $matches; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Returns a matcher object. |
|
| 121 | + * |
|
| 122 | + * @param string $dataType |
|
| 123 | + * @param array $matches |
|
| 124 | + * @return Matcher |
|
| 125 | + * @throws \Fab\Vidi\Exception\NotExistingClassException |
|
| 126 | + * @throws \InvalidArgumentException |
|
| 127 | + */ |
|
| 128 | + protected static function getMatcher($dataType, array $matches = []) |
|
| 129 | + { |
|
| 130 | + |
|
| 131 | + /** @var $matcher Matcher */ |
|
| 132 | + $matcher = GeneralUtility::makeInstance(Matcher::class, [], $dataType); |
|
| 133 | + |
|
| 134 | + foreach ($matches as $fieldNameAndPath => $value) { |
|
| 135 | + |
|
| 136 | + // CSV values should be considered as "in" operator in Query, otherwise "equals". |
|
| 137 | + $explodedValues = GeneralUtility::trimExplode(',', $value, true); |
|
| 138 | + |
|
| 139 | + // The matching value contains a "1,2" as example |
|
| 140 | + if (count($explodedValues) > 1) { |
|
| 141 | + |
|
| 142 | + $resolvedDataType = self::getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType); |
|
| 143 | + $resolvedFieldName = self::getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType); |
|
| 144 | + |
|
| 145 | + // "equals" if in presence of a relation. |
|
| 146 | + // "in" if not a relation. |
|
| 147 | + if (Tca::table($resolvedDataType)->field($resolvedFieldName)->hasRelation()) { |
|
| 148 | + foreach ($explodedValues as $explodedValue) { |
|
| 149 | + $matcher->equals($fieldNameAndPath, $explodedValue); |
|
| 150 | + } |
|
| 151 | + } else { |
|
| 152 | + $matcher->in($fieldNameAndPath, $explodedValues); |
|
| 153 | + } |
|
| 154 | + } else { |
|
| 155 | + $matcher->equals($fieldNameAndPath, $explodedValues[0]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + return $matcher; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @return FieldPathResolver |
|
| 164 | + * @throws \InvalidArgumentException |
|
| 165 | + */ |
|
| 166 | + protected static function getFieldPathResolver() |
|
| 167 | + { |
|
| 168 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @param string $argumentName |
|
| 173 | + * @return int |
|
| 174 | + */ |
|
| 175 | + protected static function getArgumentValue($argumentName) |
|
| 176 | + { |
|
| 177 | + |
|
| 178 | + $value = ''; // default value |
|
| 179 | + |
|
| 180 | + // Merge parameters |
|
| 181 | + $parameters = GeneralUtility::_GET(); |
|
| 182 | + $post = GeneralUtility::_POST(); |
|
| 183 | + ArrayUtility::mergeRecursiveWithOverrule($parameters, $post); |
|
| 184 | + |
|
| 185 | + // Traverse argument parts and retrieve value. |
|
| 186 | + $argumentParts = GeneralUtility::trimExplode('|', $argumentName); |
|
| 187 | + foreach ($argumentParts as $argumentPart) { |
|
| 188 | + if (isset($parameters[$argumentPart])) { |
|
| 189 | + $value = $parameters[$argumentPart]; |
|
| 190 | + $parameters = $value; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + return (int)$value; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | } |
@@ -20,35 +20,35 @@ |
||
| 20 | 20 | class EditButton extends AbstractComponentView |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Renders a "edit" button to be placed in the grid. |
|
| 25 | - * |
|
| 26 | - * @param Content $object |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function render(Content $object = null) |
|
| 30 | - { |
|
| 31 | - $editUri = $this->getUriRenderer()->render($object); |
|
| 23 | + /** |
|
| 24 | + * Renders a "edit" button to be placed in the grid. |
|
| 25 | + * |
|
| 26 | + * @param Content $object |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function render(Content $object = null) |
|
| 30 | + { |
|
| 31 | + $editUri = $this->getUriRenderer()->render($object); |
|
| 32 | 32 | |
| 33 | - return $this->makeLinkButton() |
|
| 34 | - ->setHref($editUri) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - ]) |
|
| 39 | - ->setClasses('btn-edit') |
|
| 40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:edit')) |
|
| 41 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)) |
|
| 42 | - ->render(); |
|
| 43 | - } |
|
| 33 | + return $this->makeLinkButton() |
|
| 34 | + ->setHref($editUri) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + ]) |
|
| 39 | + ->setClasses('btn-edit') |
|
| 40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:edit')) |
|
| 41 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)) |
|
| 42 | + ->render(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return \Fab\Vidi\View\Uri\EditUri |
|
| 47 | - * @throws \InvalidArgumentException |
|
| 48 | - */ |
|
| 49 | - protected function getUriRenderer() |
|
| 50 | - { |
|
| 51 | - return GeneralUtility::makeInstance(EditUri::class); |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * @return \Fab\Vidi\View\Uri\EditUri |
|
| 47 | + * @throws \InvalidArgumentException |
|
| 48 | + */ |
|
| 49 | + protected function getUriRenderer() |
|
| 50 | + { |
|
| 51 | + return GeneralUtility::makeInstance(EditUri::class); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -19,47 +19,47 @@ |
||
| 19 | 19 | class DeleteButton extends AbstractComponentView |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Renders a "delete" button to be placed in the grid. |
|
| 24 | - * |
|
| 25 | - * @param Content $object |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function render(Content $object = null) |
|
| 29 | - { |
|
| 30 | - $labelField = Tca::table($object->getDataType())->getLabelField(); |
|
| 31 | - $label = $object[$labelField] ? $object[$labelField] : $object->getUid(); |
|
| 22 | + /** |
|
| 23 | + * Renders a "delete" button to be placed in the grid. |
|
| 24 | + * |
|
| 25 | + * @param Content $object |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function render(Content $object = null) |
|
| 29 | + { |
|
| 30 | + $labelField = Tca::table($object->getDataType())->getLabelField(); |
|
| 31 | + $label = $object[$labelField] ? $object[$labelField] : $object->getUid(); |
|
| 32 | 32 | |
| 33 | - return $this->makeLinkButton() |
|
| 34 | - ->setHref($this->getDeleteUri($object)) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - 'label' => $label, |
|
| 39 | - ]) |
|
| 40 | - ->setClasses('btn-delete') |
|
| 41 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:delete')) |
|
| 42 | - ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
| 43 | - ->render(); |
|
| 44 | - } |
|
| 33 | + return $this->makeLinkButton() |
|
| 34 | + ->setHref($this->getDeleteUri($object)) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + 'label' => $label, |
|
| 39 | + ]) |
|
| 40 | + ->setClasses('btn-delete') |
|
| 41 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:delete')) |
|
| 42 | + ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
| 43 | + ->render(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param Content $object |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - protected function getDeleteUri(Content $object) |
|
| 51 | - { |
|
| 52 | - $additionalParameters = array( |
|
| 53 | - $this->getModuleLoader()->getParameterPrefix() => array( |
|
| 54 | - 'controller' => 'Content', |
|
| 55 | - 'action' => 'delete', |
|
| 56 | - 'format' => 'json', |
|
| 57 | - 'matches' => array( |
|
| 58 | - 'uid' => $object->getUid(), |
|
| 59 | - ), |
|
| 60 | - ), |
|
| 61 | - ); |
|
| 62 | - return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
| 63 | - } |
|
| 46 | + /** |
|
| 47 | + * @param Content $object |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + protected function getDeleteUri(Content $object) |
|
| 51 | + { |
|
| 52 | + $additionalParameters = array( |
|
| 53 | + $this->getModuleLoader()->getParameterPrefix() => array( |
|
| 54 | + 'controller' => 'Content', |
|
| 55 | + 'action' => 'delete', |
|
| 56 | + 'format' => 'json', |
|
| 57 | + 'matches' => array( |
|
| 58 | + 'uid' => $object->getUid(), |
|
| 59 | + ), |
|
| 60 | + ), |
|
| 61 | + ); |
|
| 62 | + return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -19,15 +19,15 @@ |
||
| 19 | 19 | class ButtonsSystem extends AbstractComponentView |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Rendering buttons in the grids given a Content object. |
|
| 24 | - * |
|
| 25 | - * @param Content $object |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function render(Content $object = null) |
|
| 29 | - { |
|
| 30 | - return ''; |
|
| 31 | - } |
|
| 22 | + /** |
|
| 23 | + * Rendering buttons in the grids given a Content object. |
|
| 24 | + * |
|
| 25 | + * @param Content $object |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function render(Content $object = null) |
|
| 29 | + { |
|
| 30 | + return ''; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | } |
@@ -18,15 +18,15 @@ |
||
| 18 | 18 | class CheckboxSystem extends AbstractComponentView |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Returns a checkbox for the grids. |
|
| 23 | - * |
|
| 24 | - * @param Content $object |
|
| 25 | - * @param int $offset |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function render(Content $object = null, $offset = 0) |
|
| 29 | - { |
|
| 30 | - return ''; |
|
| 31 | - } |
|
| 21 | + /** |
|
| 22 | + * Returns a checkbox for the grids. |
|
| 23 | + * |
|
| 24 | + * @param Content $object |
|
| 25 | + * @param int $offset |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function render(Content $object = null, $offset = 0) |
|
| 29 | + { |
|
| 30 | + return ''; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -18,35 +18,35 @@ |
||
| 18 | 18 | class EditUri extends AbstractComponentView |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Renders a "edit" button to be placed in the grid. |
|
| 23 | - * |
|
| 24 | - * @param Content $object |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function render(Content $object = null) |
|
| 28 | - { |
|
| 29 | - $uri = BackendUtility::getModuleUrl( |
|
| 30 | - 'record_edit', |
|
| 31 | - array( |
|
| 32 | - $this->getEditParameterName($object) => 'edit', |
|
| 33 | - 'returnUrl' => $this->getModuleLoader()->getModuleUrl() |
|
| 34 | - ) |
|
| 35 | - ); |
|
| 36 | - return $uri; |
|
| 37 | - } |
|
| 21 | + /** |
|
| 22 | + * Renders a "edit" button to be placed in the grid. |
|
| 23 | + * |
|
| 24 | + * @param Content $object |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function render(Content $object = null) |
|
| 28 | + { |
|
| 29 | + $uri = BackendUtility::getModuleUrl( |
|
| 30 | + 'record_edit', |
|
| 31 | + array( |
|
| 32 | + $this->getEditParameterName($object) => 'edit', |
|
| 33 | + 'returnUrl' => $this->getModuleLoader()->getModuleUrl() |
|
| 34 | + ) |
|
| 35 | + ); |
|
| 36 | + return $uri; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param Content $object |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - protected function getEditParameterName(Content $object) |
|
| 44 | - { |
|
| 45 | - return sprintf( |
|
| 46 | - 'edit[%s][%s]', |
|
| 47 | - $object->getDataType(), |
|
| 48 | - $object->getUid() |
|
| 49 | - ); |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * @param Content $object |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + protected function getEditParameterName(Content $object) |
|
| 44 | + { |
|
| 45 | + return sprintf( |
|
| 46 | + 'edit[%s][%s]', |
|
| 47 | + $object->getDataType(), |
|
| 48 | + $object->getUid() |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | } |
@@ -17,102 +17,102 @@ |
||
| 17 | 17 | class Property |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - static protected $currentProperty; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - static protected $currentTable; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var array |
|
| 32 | - */ |
|
| 33 | - protected $storage = []; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @param string $propertyName |
|
| 37 | - * @return $this |
|
| 38 | - * @throws \InvalidArgumentException |
|
| 39 | - */ |
|
| 40 | - static public function name($propertyName) |
|
| 41 | - { |
|
| 42 | - self::$currentProperty = $propertyName; |
|
| 43 | - self::$currentTable = ''; // reset the table name value. |
|
| 44 | - return GeneralUtility::makeInstance(self::class); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param string|Content $tableNameOrContentObject |
|
| 49 | - * @return $this |
|
| 50 | - */ |
|
| 51 | - public function of($tableNameOrContentObject) |
|
| 52 | - { |
|
| 53 | - // Resolve the table name. |
|
| 54 | - self::$currentTable = $tableNameOrContentObject instanceof Content ? |
|
| 55 | - $tableNameOrContentObject->getDataType() : |
|
| 56 | - $tableNameOrContentObject; |
|
| 57 | - return $this; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - public function toFieldName() |
|
| 64 | - { |
|
| 65 | - |
|
| 66 | - $propertyName = $this->getPropertyName(); |
|
| 67 | - $tableName = $this->getTableName(); |
|
| 68 | - |
|
| 69 | - if (empty($this->storage[$tableName][$propertyName])) { |
|
| 70 | - if ($this->storage[$tableName]) { |
|
| 71 | - $this->storage[$tableName] = []; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - // Default case |
|
| 75 | - $fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName); |
|
| 76 | - |
|
| 77 | - // Special case in case the field name does not follow the conventions "field_name" => "fieldName" |
|
| 78 | - // There is the chance to make some mapping |
|
| 79 | - if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'])) { |
|
| 80 | - $key = array_search($propertyName, $GLOBALS['TCA'][$tableName]['vidi']['mappings']); |
|
| 81 | - if ($key !== false) { |
|
| 82 | - $fieldName = $key; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $this->storage[$tableName][$propertyName] = $fieldName; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - return $this->storage[$tableName][$propertyName]; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @return string |
|
| 94 | - * @throws \RuntimeException |
|
| 95 | - */ |
|
| 96 | - protected function getPropertyName() |
|
| 97 | - { |
|
| 98 | - $propertyName = self::$currentProperty; |
|
| 99 | - if (empty($propertyName)) { |
|
| 100 | - throw new \RuntimeException('I could not find a field name value.', 1403203290); |
|
| 101 | - } |
|
| 102 | - return $propertyName; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return string |
|
| 107 | - * @throws \RuntimeException |
|
| 108 | - */ |
|
| 109 | - protected function getTableName() |
|
| 110 | - { |
|
| 111 | - $tableName = self::$currentTable; |
|
| 112 | - if (empty($tableName)) { |
|
| 113 | - throw new \RuntimeException('I could not find a table name value.', 1403203291); |
|
| 114 | - } |
|
| 115 | - return $tableName; |
|
| 116 | - } |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + static protected $currentProperty; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + static protected $currentTable; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var array |
|
| 32 | + */ |
|
| 33 | + protected $storage = []; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @param string $propertyName |
|
| 37 | + * @return $this |
|
| 38 | + * @throws \InvalidArgumentException |
|
| 39 | + */ |
|
| 40 | + static public function name($propertyName) |
|
| 41 | + { |
|
| 42 | + self::$currentProperty = $propertyName; |
|
| 43 | + self::$currentTable = ''; // reset the table name value. |
|
| 44 | + return GeneralUtility::makeInstance(self::class); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param string|Content $tableNameOrContentObject |
|
| 49 | + * @return $this |
|
| 50 | + */ |
|
| 51 | + public function of($tableNameOrContentObject) |
|
| 52 | + { |
|
| 53 | + // Resolve the table name. |
|
| 54 | + self::$currentTable = $tableNameOrContentObject instanceof Content ? |
|
| 55 | + $tableNameOrContentObject->getDataType() : |
|
| 56 | + $tableNameOrContentObject; |
|
| 57 | + return $this; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + public function toFieldName() |
|
| 64 | + { |
|
| 65 | + |
|
| 66 | + $propertyName = $this->getPropertyName(); |
|
| 67 | + $tableName = $this->getTableName(); |
|
| 68 | + |
|
| 69 | + if (empty($this->storage[$tableName][$propertyName])) { |
|
| 70 | + if ($this->storage[$tableName]) { |
|
| 71 | + $this->storage[$tableName] = []; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + // Default case |
|
| 75 | + $fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName); |
|
| 76 | + |
|
| 77 | + // Special case in case the field name does not follow the conventions "field_name" => "fieldName" |
|
| 78 | + // There is the chance to make some mapping |
|
| 79 | + if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'])) { |
|
| 80 | + $key = array_search($propertyName, $GLOBALS['TCA'][$tableName]['vidi']['mappings']); |
|
| 81 | + if ($key !== false) { |
|
| 82 | + $fieldName = $key; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $this->storage[$tableName][$propertyName] = $fieldName; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + return $this->storage[$tableName][$propertyName]; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @return string |
|
| 94 | + * @throws \RuntimeException |
|
| 95 | + */ |
|
| 96 | + protected function getPropertyName() |
|
| 97 | + { |
|
| 98 | + $propertyName = self::$currentProperty; |
|
| 99 | + if (empty($propertyName)) { |
|
| 100 | + throw new \RuntimeException('I could not find a field name value.', 1403203290); |
|
| 101 | + } |
|
| 102 | + return $propertyName; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return string |
|
| 107 | + * @throws \RuntimeException |
|
| 108 | + */ |
|
| 109 | + protected function getTableName() |
|
| 110 | + { |
|
| 111 | + $tableName = self::$currentTable; |
|
| 112 | + if (empty($tableName)) { |
|
| 113 | + throw new \RuntimeException('I could not find a table name value.', 1403203291); |
|
| 114 | + } |
|
| 115 | + return $tableName; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | } |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | { |
| 59 | 59 | // Resolve the table name. |
| 60 | 60 | self::$currentTable = $tableNameOrContentObject instanceof Content ? |
| 61 | - $tableNameOrContentObject->getDataType() : |
|
| 62 | - $tableNameOrContentObject; |
|
| 61 | + $tableNameOrContentObject->getDataType() : $tableNameOrContentObject; |
|
| 63 | 62 | return $this; |
| 64 | 63 | } |
| 65 | 64 | |
@@ -16,32 +16,32 @@ |
||
| 16 | 16 | class ResultSetStorage implements SingletonInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var array |
|
| 21 | - */ |
|
| 22 | - protected $resultSets = []; |
|
| 19 | + /** |
|
| 20 | + * @var array |
|
| 21 | + */ |
|
| 22 | + protected $resultSets = []; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param string $querySignature |
|
| 26 | - * @return array |
|
| 27 | - */ |
|
| 28 | - public function get($querySignature) |
|
| 29 | - { |
|
| 30 | - $resultSet = null; |
|
| 31 | - if (isset($this->resultSets[$querySignature])) { |
|
| 32 | - $resultSet = $this->resultSets[$querySignature]; |
|
| 33 | - } |
|
| 34 | - return $resultSet; |
|
| 35 | - } |
|
| 24 | + /** |
|
| 25 | + * @param string $querySignature |
|
| 26 | + * @return array |
|
| 27 | + */ |
|
| 28 | + public function get($querySignature) |
|
| 29 | + { |
|
| 30 | + $resultSet = null; |
|
| 31 | + if (isset($this->resultSets[$querySignature])) { |
|
| 32 | + $resultSet = $this->resultSets[$querySignature]; |
|
| 33 | + } |
|
| 34 | + return $resultSet; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param $querySignature |
|
| 39 | - * @param array $resultSet |
|
| 40 | - * @internal param array $resultSets |
|
| 41 | - */ |
|
| 42 | - public function set($querySignature, array $resultSet) |
|
| 43 | - { |
|
| 44 | - $this->resultSets[$querySignature] = $resultSet; |
|
| 45 | - } |
|
| 37 | + /** |
|
| 38 | + * @param $querySignature |
|
| 39 | + * @param array $resultSet |
|
| 40 | + * @internal param array $resultSets |
|
| 41 | + */ |
|
| 42 | + public function set($querySignature, array $resultSet) |
|
| 43 | + { |
|
| 44 | + $this->resultSets[$querySignature] = $resultSet; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |