@@ -21,212 +21,212 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class ModulePidService |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * The data type (table) |
|
| 26 | - * |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - protected $dataType = ''; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * A collection of speaking error messages why the pid is invalid. |
|
| 33 | - * |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $errors = []; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * ModulePidService constructor. |
|
| 40 | - */ |
|
| 41 | - public function __construct() |
|
| 42 | - { |
|
| 43 | - $this->dataType = $this->getModuleLoader()->getDataType(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Returns a class instance |
|
| 48 | - * |
|
| 49 | - * @return \Fab\Vidi\Module\ModulePidService|object |
|
| 50 | - */ |
|
| 51 | - public static function getInstance() |
|
| 52 | - { |
|
| 53 | - return GeneralUtility::makeInstance(self::class); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - public function isConfiguredPidValid(): bool |
|
| 60 | - { |
|
| 61 | - $errors = $this->validateConfiguredPid(); |
|
| 62 | - return empty($errors); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @return array |
|
| 67 | - */ |
|
| 68 | - public function validateConfiguredPid(): array |
|
| 69 | - { |
|
| 70 | - $configuredPid = $this->getConfiguredNewRecordPid(); |
|
| 71 | - $this->validateRootLevel($configuredPid); |
|
| 72 | - $this->validatePageExist($configuredPid); |
|
| 73 | - $this->validateDoktype($configuredPid); |
|
| 74 | - return $this->errors; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Return the default configured pid. |
|
| 79 | - * |
|
| 80 | - * @return int |
|
| 81 | - */ |
|
| 82 | - public function getConfiguredNewRecordPid(): int |
|
| 83 | - { |
|
| 84 | - if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 85 | - $configuredPid = (int)GeneralUtility::_GP(Parameter::PID); |
|
| 86 | - } else { |
|
| 87 | - // Get pid from User TSConfig if any. |
|
| 88 | - $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->dataType); |
|
| 89 | - $result = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 90 | - $configuredPid = isset($result['value']) |
|
| 91 | - ? $configuredPid = (int)$result['value'] |
|
| 92 | - : $this->getModuleLoader()->getDefaultPid(); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - return $configuredPid; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Check if pid is 0 and given table is allowed on root level. |
|
| 100 | - * |
|
| 101 | - * @param int $configuredPid |
|
| 102 | - * @return void |
|
| 103 | - */ |
|
| 104 | - protected function validateRootLevel(int $configuredPid): void |
|
| 105 | - { |
|
| 106 | - if ($configuredPid > 0) { |
|
| 107 | - return; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $isRootLevel = (bool)Tca::table()->get('rootLevel'); |
|
| 111 | - if (!$isRootLevel) { |
|
| 112 | - $this->errors[] = sprintf( |
|
| 113 | - 'You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;', |
|
| 114 | - $this->dataType |
|
| 115 | - ); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Check if a page exists for the configured pid |
|
| 121 | - * |
|
| 122 | - * @param int $configuredPid |
|
| 123 | - * @return void |
|
| 124 | - */ |
|
| 125 | - protected function validatePageExist(int $configuredPid): void |
|
| 126 | - { |
|
| 127 | - if ($configuredPid === 0) { |
|
| 128 | - return; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $page = $this->getPage($configuredPid); |
|
| 132 | - if (empty($page)) { |
|
| 133 | - $this->errors[] = sprintf( |
|
| 134 | - 'No page found for the configured page id "%s".', |
|
| 135 | - $configuredPid |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Check if configured page is a sysfolder and if it is allowed. |
|
| 142 | - * |
|
| 143 | - * @param int $configuredPid |
|
| 144 | - * @return void |
|
| 145 | - */ |
|
| 146 | - protected function validateDoktype(int $configuredPid): void |
|
| 147 | - { |
|
| 148 | - if ($configuredPid === 0) { |
|
| 149 | - return; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $page = $this->getPage($configuredPid); |
|
| 153 | - if (!empty($page) |
|
| 154 | - && (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER |
|
| 155 | - && !$this->isTableAllowedOnStandardPages() |
|
| 156 | - && $this->getModuleLoader()->hasComponentInDocHeader(NewButton::class)) { |
|
| 157 | - $this->errors[] = sprintf( |
|
| 158 | - 'The page with the id "%s" either has to be of the type "folder" (doktype=254) or the table "%s" has to be allowed on standard pages.', |
|
| 159 | - $configuredPid, |
|
| 160 | - $this->dataType |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Check if given table is allowed on standard pages |
|
| 167 | - * |
|
| 168 | - * @return bool |
|
| 169 | - * @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages() |
|
| 170 | - */ |
|
| 171 | - protected function isTableAllowedOnStandardPages(): bool |
|
| 172 | - { |
|
| 173 | - $allowedTables = explode(',', $GLOBALS['PAGES_TYPES']['default']['allowedTables']); |
|
| 174 | - return in_array($this->dataType, $allowedTables, true); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Returns the page record of the configured pid |
|
| 179 | - * |
|
| 180 | - * @param int $configuredPid |
|
| 181 | - * @return array |
|
| 182 | - */ |
|
| 183 | - protected function getPage(int $configuredPid): ?array |
|
| 184 | - { |
|
| 185 | - $query = $this->getQueryBuilder('pages'); |
|
| 186 | - $query->getRestrictions()->removeAll(); // we are in BE context. |
|
| 187 | - |
|
| 188 | - $page = $query->select('doktype') |
|
| 189 | - ->from('pages') |
|
| 190 | - ->where( |
|
| 191 | - 'deleted = 0', |
|
| 192 | - 'uid = ' . $configuredPid |
|
| 193 | - ) |
|
| 194 | - ->execute() |
|
| 195 | - ->fetch(); |
|
| 196 | - |
|
| 197 | - return is_array($page) |
|
| 198 | - ? $page |
|
| 199 | - : []; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @param string $tableName |
|
| 204 | - * @return object|QueryBuilder |
|
| 205 | - */ |
|
| 206 | - protected function getQueryBuilder($tableName): QueryBuilder |
|
| 207 | - { |
|
| 208 | - /** @var ConnectionPool $connectionPool */ |
|
| 209 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 210 | - return $connectionPool->getQueryBuilderForTable($tableName); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Returns an instance of the current Backend User. |
|
| 215 | - * |
|
| 216 | - * @return BackendUserAuthentication |
|
| 217 | - */ |
|
| 218 | - protected function getBackendUser() |
|
| 219 | - { |
|
| 220 | - return $GLOBALS['BE_USER']; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Get the Vidi Module Loader. |
|
| 225 | - * |
|
| 226 | - * @return ModuleLoader|object |
|
| 227 | - */ |
|
| 228 | - protected function getModuleLoader() |
|
| 229 | - { |
|
| 230 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 231 | - } |
|
| 24 | + /** |
|
| 25 | + * The data type (table) |
|
| 26 | + * |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + protected $dataType = ''; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * A collection of speaking error messages why the pid is invalid. |
|
| 33 | + * |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $errors = []; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * ModulePidService constructor. |
|
| 40 | + */ |
|
| 41 | + public function __construct() |
|
| 42 | + { |
|
| 43 | + $this->dataType = $this->getModuleLoader()->getDataType(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Returns a class instance |
|
| 48 | + * |
|
| 49 | + * @return \Fab\Vidi\Module\ModulePidService|object |
|
| 50 | + */ |
|
| 51 | + public static function getInstance() |
|
| 52 | + { |
|
| 53 | + return GeneralUtility::makeInstance(self::class); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + public function isConfiguredPidValid(): bool |
|
| 60 | + { |
|
| 61 | + $errors = $this->validateConfiguredPid(); |
|
| 62 | + return empty($errors); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @return array |
|
| 67 | + */ |
|
| 68 | + public function validateConfiguredPid(): array |
|
| 69 | + { |
|
| 70 | + $configuredPid = $this->getConfiguredNewRecordPid(); |
|
| 71 | + $this->validateRootLevel($configuredPid); |
|
| 72 | + $this->validatePageExist($configuredPid); |
|
| 73 | + $this->validateDoktype($configuredPid); |
|
| 74 | + return $this->errors; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Return the default configured pid. |
|
| 79 | + * |
|
| 80 | + * @return int |
|
| 81 | + */ |
|
| 82 | + public function getConfiguredNewRecordPid(): int |
|
| 83 | + { |
|
| 84 | + if (GeneralUtility::_GP(Parameter::PID)) { |
|
| 85 | + $configuredPid = (int)GeneralUtility::_GP(Parameter::PID); |
|
| 86 | + } else { |
|
| 87 | + // Get pid from User TSConfig if any. |
|
| 88 | + $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->dataType); |
|
| 89 | + $result = $this->getBackendUser()->getTSConfig($tsConfigPath); |
|
| 90 | + $configuredPid = isset($result['value']) |
|
| 91 | + ? $configuredPid = (int)$result['value'] |
|
| 92 | + : $this->getModuleLoader()->getDefaultPid(); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + return $configuredPid; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Check if pid is 0 and given table is allowed on root level. |
|
| 100 | + * |
|
| 101 | + * @param int $configuredPid |
|
| 102 | + * @return void |
|
| 103 | + */ |
|
| 104 | + protected function validateRootLevel(int $configuredPid): void |
|
| 105 | + { |
|
| 106 | + if ($configuredPid > 0) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $isRootLevel = (bool)Tca::table()->get('rootLevel'); |
|
| 111 | + if (!$isRootLevel) { |
|
| 112 | + $this->errors[] = sprintf( |
|
| 113 | + 'You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;', |
|
| 114 | + $this->dataType |
|
| 115 | + ); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Check if a page exists for the configured pid |
|
| 121 | + * |
|
| 122 | + * @param int $configuredPid |
|
| 123 | + * @return void |
|
| 124 | + */ |
|
| 125 | + protected function validatePageExist(int $configuredPid): void |
|
| 126 | + { |
|
| 127 | + if ($configuredPid === 0) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $page = $this->getPage($configuredPid); |
|
| 132 | + if (empty($page)) { |
|
| 133 | + $this->errors[] = sprintf( |
|
| 134 | + 'No page found for the configured page id "%s".', |
|
| 135 | + $configuredPid |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Check if configured page is a sysfolder and if it is allowed. |
|
| 142 | + * |
|
| 143 | + * @param int $configuredPid |
|
| 144 | + * @return void |
|
| 145 | + */ |
|
| 146 | + protected function validateDoktype(int $configuredPid): void |
|
| 147 | + { |
|
| 148 | + if ($configuredPid === 0) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $page = $this->getPage($configuredPid); |
|
| 153 | + if (!empty($page) |
|
| 154 | + && (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER |
|
| 155 | + && !$this->isTableAllowedOnStandardPages() |
|
| 156 | + && $this->getModuleLoader()->hasComponentInDocHeader(NewButton::class)) { |
|
| 157 | + $this->errors[] = sprintf( |
|
| 158 | + 'The page with the id "%s" either has to be of the type "folder" (doktype=254) or the table "%s" has to be allowed on standard pages.', |
|
| 159 | + $configuredPid, |
|
| 160 | + $this->dataType |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Check if given table is allowed on standard pages |
|
| 167 | + * |
|
| 168 | + * @return bool |
|
| 169 | + * @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages() |
|
| 170 | + */ |
|
| 171 | + protected function isTableAllowedOnStandardPages(): bool |
|
| 172 | + { |
|
| 173 | + $allowedTables = explode(',', $GLOBALS['PAGES_TYPES']['default']['allowedTables']); |
|
| 174 | + return in_array($this->dataType, $allowedTables, true); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Returns the page record of the configured pid |
|
| 179 | + * |
|
| 180 | + * @param int $configuredPid |
|
| 181 | + * @return array |
|
| 182 | + */ |
|
| 183 | + protected function getPage(int $configuredPid): ?array |
|
| 184 | + { |
|
| 185 | + $query = $this->getQueryBuilder('pages'); |
|
| 186 | + $query->getRestrictions()->removeAll(); // we are in BE context. |
|
| 187 | + |
|
| 188 | + $page = $query->select('doktype') |
|
| 189 | + ->from('pages') |
|
| 190 | + ->where( |
|
| 191 | + 'deleted = 0', |
|
| 192 | + 'uid = ' . $configuredPid |
|
| 193 | + ) |
|
| 194 | + ->execute() |
|
| 195 | + ->fetch(); |
|
| 196 | + |
|
| 197 | + return is_array($page) |
|
| 198 | + ? $page |
|
| 199 | + : []; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @param string $tableName |
|
| 204 | + * @return object|QueryBuilder |
|
| 205 | + */ |
|
| 206 | + protected function getQueryBuilder($tableName): QueryBuilder |
|
| 207 | + { |
|
| 208 | + /** @var ConnectionPool $connectionPool */ |
|
| 209 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 210 | + return $connectionPool->getQueryBuilderForTable($tableName); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Returns an instance of the current Backend User. |
|
| 215 | + * |
|
| 216 | + * @return BackendUserAuthentication |
|
| 217 | + */ |
|
| 218 | + protected function getBackendUser() |
|
| 219 | + { |
|
| 220 | + return $GLOBALS['BE_USER']; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Get the Vidi Module Loader. |
|
| 225 | + * |
|
| 226 | + * @return ModuleLoader|object |
|
| 227 | + */ |
|
| 228 | + protected function getModuleLoader() |
|
| 229 | + { |
|
| 230 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 231 | + } |
|
| 232 | 232 | } |
@@ -189,7 +189,7 @@ |
||
| 189 | 189 | ->from('pages') |
| 190 | 190 | ->where( |
| 191 | 191 | 'deleted = 0', |
| 192 | - 'uid = ' . $configuredPid |
|
| 192 | + 'uid = '.$configuredPid |
|
| 193 | 193 | ) |
| 194 | 194 | ->execute() |
| 195 | 195 | ->fetch(); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Access extends Enumeration |
| 18 | 18 | { |
| 19 | - public const USER = 'user,group'; |
|
| 19 | + public const USER = 'user,group'; |
|
| 20 | 20 | |
| 21 | - public const ADMIN = 'admin'; |
|
| 21 | + public const ADMIN = 'admin'; |
|
| 22 | 22 | } |
@@ -16,9 +16,9 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Parameter extends Enumeration |
| 18 | 18 | { |
| 19 | - public const PID = 'id'; |
|
| 19 | + public const PID = 'id'; |
|
| 20 | 20 | |
| 21 | - public const SUBMODULE = 'vidiModuleCode'; |
|
| 21 | + public const SUBMODULE = 'vidiModuleCode'; |
|
| 22 | 22 | |
| 23 | - public const MODULE = 'route'; |
|
| 23 | + public const MODULE = 'route'; |
|
| 24 | 24 | } |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class ModuleName extends Enumeration |
| 18 | 18 | { |
| 19 | - public const WEB = 'web'; |
|
| 19 | + public const WEB = 'web'; |
|
| 20 | 20 | |
| 21 | - public const FILE = 'file'; |
|
| 21 | + public const FILE = 'file'; |
|
| 22 | 22 | |
| 23 | - public const USER = 'user'; |
|
| 23 | + public const USER = 'user'; |
|
| 24 | 24 | |
| 25 | - public const ADMIN = 'admin'; |
|
| 25 | + public const ADMIN = 'admin'; |
|
| 26 | 26 | |
| 27 | - public const SYSTEM = 'system'; |
|
| 27 | + public const SYSTEM = 'system'; |
|
| 28 | 28 | } |
@@ -16,19 +16,19 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class ModulePosition extends Enumeration |
| 18 | 18 | { |
| 19 | - public const DOC_HEADER = 'doc-header'; |
|
| 19 | + public const DOC_HEADER = 'doc-header'; |
|
| 20 | 20 | |
| 21 | - public const TOP = 'top'; |
|
| 21 | + public const TOP = 'top'; |
|
| 22 | 22 | |
| 23 | - public const BOTTOM = 'bottom'; |
|
| 23 | + public const BOTTOM = 'bottom'; |
|
| 24 | 24 | |
| 25 | - public const LEFT = 'left'; |
|
| 25 | + public const LEFT = 'left'; |
|
| 26 | 26 | |
| 27 | - public const RIGHT = 'right'; |
|
| 27 | + public const RIGHT = 'right'; |
|
| 28 | 28 | |
| 29 | - public const GRID = 'grid'; |
|
| 29 | + public const GRID = 'grid'; |
|
| 30 | 30 | |
| 31 | - public const BUTTONS = 'buttons'; |
|
| 31 | + public const BUTTONS = 'buttons'; |
|
| 32 | 32 | |
| 33 | - public const MENU_MASS_ACTION = 'menu-mass-action'; |
|
| 33 | + public const MENU_MASS_ACTION = 'menu-mass-action'; |
|
| 34 | 34 | } |
@@ -14,23 +14,23 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class ConfigurablePart |
| 16 | 16 | { |
| 17 | - public const __default = ''; |
|
| 18 | - public const EXCLUDED_FIELDS = 'excluded_fields'; |
|
| 19 | - public const MENU_VISIBLE_ITEMS = 'menuVisibleItems'; |
|
| 20 | - public const MENU_VISIBLE_ITEMS_DEFAULT = 'menuVisibleItemsDefault'; |
|
| 17 | + public const __default = ''; |
|
| 18 | + public const EXCLUDED_FIELDS = 'excluded_fields'; |
|
| 19 | + public const MENU_VISIBLE_ITEMS = 'menuVisibleItems'; |
|
| 20 | + public const MENU_VISIBLE_ITEMS_DEFAULT = 'menuVisibleItemsDefault'; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Get the valid values for this enum. |
|
| 24 | - * |
|
| 25 | - * @param boolean $include_default |
|
| 26 | - * @return array |
|
| 27 | - */ |
|
| 28 | - public static function getParts($include_default = false) |
|
| 29 | - { |
|
| 30 | - return array( |
|
| 31 | - 'EXCLUDED_FIELDS' => self::EXCLUDED_FIELDS, |
|
| 32 | - 'MENU_VISIBLE_ITEMS' => self::MENU_VISIBLE_ITEMS, |
|
| 33 | - 'MENU_VISIBLE_ITEMS_DEFAULT' => self::MENU_VISIBLE_ITEMS_DEFAULT, |
|
| 34 | - ); |
|
| 35 | - } |
|
| 22 | + /** |
|
| 23 | + * Get the valid values for this enum. |
|
| 24 | + * |
|
| 25 | + * @param boolean $include_default |
|
| 26 | + * @return array |
|
| 27 | + */ |
|
| 28 | + public static function getParts($include_default = false) |
|
| 29 | + { |
|
| 30 | + return array( |
|
| 31 | + 'EXCLUDED_FIELDS' => self::EXCLUDED_FIELDS, |
|
| 32 | + 'MENU_VISIBLE_ITEMS' => self::MENU_VISIBLE_ITEMS, |
|
| 33 | + 'MENU_VISIBLE_ITEMS_DEFAULT' => self::MENU_VISIBLE_ITEMS_DEFAULT, |
|
| 34 | + ); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -17,68 +17,68 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class DataHandlerFactory implements SingletonInterface |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $actionName = ''; |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $actionName = ''; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - protected $dataType = ''; |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + protected $dataType = ''; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Default is CoreDataHandler which wraps the Core DataHandler. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - protected $defaultDataHandler = 'Fab\Vidi\DataHandler\CoreDataHandler'; |
|
| 30 | + /** |
|
| 31 | + * Default is CoreDataHandler which wraps the Core DataHandler. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + protected $defaultDataHandler = 'Fab\Vidi\DataHandler\CoreDataHandler'; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param string $actionName |
|
| 39 | - * @return $this |
|
| 40 | - */ |
|
| 41 | - public function action($actionName) |
|
| 42 | - { |
|
| 43 | - $this->actionName = $actionName; |
|
| 44 | - return $this; |
|
| 45 | - } |
|
| 37 | + /** |
|
| 38 | + * @param string $actionName |
|
| 39 | + * @return $this |
|
| 40 | + */ |
|
| 41 | + public function action($actionName) |
|
| 42 | + { |
|
| 43 | + $this->actionName = $actionName; |
|
| 44 | + return $this; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param string $dataType |
|
| 49 | - * @return $this |
|
| 50 | - */ |
|
| 51 | - public function forType($dataType) |
|
| 52 | - { |
|
| 53 | - $this->dataType = $dataType; |
|
| 54 | - return $this; |
|
| 55 | - } |
|
| 47 | + /** |
|
| 48 | + * @param string $dataType |
|
| 49 | + * @return $this |
|
| 50 | + */ |
|
| 51 | + public function forType($dataType) |
|
| 52 | + { |
|
| 53 | + $this->dataType = $dataType; |
|
| 54 | + return $this; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Returns a Data Handler instance. |
|
| 59 | - * |
|
| 60 | - * @throws \Exception |
|
| 61 | - * @return DataHandlerInterface |
|
| 62 | - */ |
|
| 63 | - public function getDataHandler() |
|
| 64 | - { |
|
| 65 | - if (empty($this->dataType)) { |
|
| 66 | - throw new \Exception('Attribute $this->dataType can not be empty', 1410001035); |
|
| 67 | - } |
|
| 57 | + /** |
|
| 58 | + * Returns a Data Handler instance. |
|
| 59 | + * |
|
| 60 | + * @throws \Exception |
|
| 61 | + * @return DataHandlerInterface |
|
| 62 | + */ |
|
| 63 | + public function getDataHandler() |
|
| 64 | + { |
|
| 65 | + if (empty($this->dataType)) { |
|
| 66 | + throw new \Exception('Attribute $this->dataType can not be empty', 1410001035); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - if (empty($this->actionName)) { |
|
| 70 | - throw new \Exception('Attribute $this->actionName can not be empty', 1410001036); |
|
| 71 | - } |
|
| 69 | + if (empty($this->actionName)) { |
|
| 70 | + throw new \Exception('Attribute $this->actionName can not be empty', 1410001036); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName])) { |
|
| 74 | - $className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName]; |
|
| 75 | - } elseif (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*'])) { |
|
| 76 | - $className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*']; |
|
| 77 | - } else { |
|
| 78 | - $className = $this->defaultDataHandler; |
|
| 79 | - } |
|
| 73 | + if (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName])) { |
|
| 74 | + $className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler'][$this->actionName]; |
|
| 75 | + } elseif (isset($GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*'])) { |
|
| 76 | + $className = $GLOBALS['TCA'][$this->dataType]['vidi']['data_handler']['*']; |
|
| 77 | + } else { |
|
| 78 | + $className = $this->defaultDataHandler; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $dataHandler = GeneralUtility::makeInstance($className); |
|
| 82 | - return $dataHandler; |
|
| 83 | - } |
|
| 81 | + $dataHandler = GeneralUtility::makeInstance($className); |
|
| 82 | + return $dataHandler; |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -15,18 +15,18 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | abstract class AbstractDataHandler implements DataHandlerInterface, SingletonInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var array |
|
| 20 | - */ |
|
| 21 | - protected $errorMessages = []; |
|
| 18 | + /** |
|
| 19 | + * @var array |
|
| 20 | + */ |
|
| 21 | + protected $errorMessages = []; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Return error that have occurred while processing the data. |
|
| 25 | - * |
|
| 26 | - * @return array |
|
| 27 | - */ |
|
| 28 | - public function getErrorMessages() |
|
| 29 | - { |
|
| 30 | - return $this->errorMessages; |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * Return error that have occurred while processing the data. |
|
| 25 | + * |
|
| 26 | + * @return array |
|
| 27 | + */ |
|
| 28 | + public function getErrorMessages() |
|
| 29 | + { |
|
| 30 | + return $this->errorMessages; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -16,53 +16,53 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface DataHandlerInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Process Content with action "update". |
|
| 21 | - * |
|
| 22 | - * @param Content $content |
|
| 23 | - * @return bool |
|
| 24 | - */ |
|
| 25 | - public function processUpdate(Content $content); |
|
| 19 | + /** |
|
| 20 | + * Process Content with action "update". |
|
| 21 | + * |
|
| 22 | + * @param Content $content |
|
| 23 | + * @return bool |
|
| 24 | + */ |
|
| 25 | + public function processUpdate(Content $content); |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Process Content with action "remove". |
|
| 29 | - * |
|
| 30 | - * @param Content $content |
|
| 31 | - * @return bool |
|
| 32 | - */ |
|
| 33 | - public function processRemove(Content $content); |
|
| 27 | + /** |
|
| 28 | + * Process Content with action "remove". |
|
| 29 | + * |
|
| 30 | + * @param Content $content |
|
| 31 | + * @return bool |
|
| 32 | + */ |
|
| 33 | + public function processRemove(Content $content); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Process Content with action "copy". |
|
| 37 | - * |
|
| 38 | - * @param Content $content |
|
| 39 | - * @param string $target |
|
| 40 | - * @return bool |
|
| 41 | - */ |
|
| 42 | - public function processCopy(Content $content, $target); |
|
| 35 | + /** |
|
| 36 | + * Process Content with action "copy". |
|
| 37 | + * |
|
| 38 | + * @param Content $content |
|
| 39 | + * @param string $target |
|
| 40 | + * @return bool |
|
| 41 | + */ |
|
| 42 | + public function processCopy(Content $content, $target); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Process Content with action "move". |
|
| 46 | - * |
|
| 47 | - * @param Content $content |
|
| 48 | - * @param mixed $target |
|
| 49 | - * @return bool |
|
| 50 | - */ |
|
| 51 | - public function processMove(Content $content, $target); |
|
| 44 | + /** |
|
| 45 | + * Process Content with action "move". |
|
| 46 | + * |
|
| 47 | + * @param Content $content |
|
| 48 | + * @param mixed $target |
|
| 49 | + * @return bool |
|
| 50 | + */ |
|
| 51 | + public function processMove(Content $content, $target); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Process Content with action "localize". |
|
| 55 | - * |
|
| 56 | - * @param Content $content |
|
| 57 | - * @param int $language |
|
| 58 | - * @return bool |
|
| 59 | - */ |
|
| 60 | - public function processLocalize(Content $content, $language); |
|
| 53 | + /** |
|
| 54 | + * Process Content with action "localize". |
|
| 55 | + * |
|
| 56 | + * @param Content $content |
|
| 57 | + * @param int $language |
|
| 58 | + * @return bool |
|
| 59 | + */ |
|
| 60 | + public function processLocalize(Content $content, $language); |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Return error that have occurred while processing the data. |
|
| 64 | - * |
|
| 65 | - * @return array |
|
| 66 | - */ |
|
| 67 | - public function getErrorMessages(); |
|
| 62 | + /** |
|
| 63 | + * Return error that have occurred while processing the data. |
|
| 64 | + * |
|
| 65 | + * @return array |
|
| 66 | + */ |
|
| 67 | + public function getErrorMessages(); |
|
| 68 | 68 | } |