@@ -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 | } |
@@ -20,105 +20,105 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class ModuleService implements SingletonInterface |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - protected $storage = []; |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + protected $storage = []; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Returns a class instance |
|
| 30 | - * |
|
| 31 | - * @return \Fab\Vidi\Module\ModuleService|object |
|
| 32 | - */ |
|
| 33 | - public static function getInstance() |
|
| 34 | - { |
|
| 35 | - return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleService::class); |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Returns a class instance |
|
| 30 | + * |
|
| 31 | + * @return \Fab\Vidi\Module\ModuleService|object |
|
| 32 | + */ |
|
| 33 | + public static function getInstance() |
|
| 34 | + { |
|
| 35 | + return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleService::class); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Fetch all modules to be displayed on the current pid. |
|
| 40 | - * |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - public function getModulesForCurrentPid(): array |
|
| 44 | - { |
|
| 45 | - $pid = $this->getModuleLoader()->getCurrentPid(); |
|
| 46 | - return $this->getModulesForPid($pid); |
|
| 47 | - } |
|
| 38 | + /** |
|
| 39 | + * Fetch all modules to be displayed on the current pid. |
|
| 40 | + * |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + public function getModulesForCurrentPid(): array |
|
| 44 | + { |
|
| 45 | + $pid = $this->getModuleLoader()->getCurrentPid(); |
|
| 46 | + return $this->getModulesForPid($pid); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Fetch all modules displayed given a pid. |
|
| 51 | - * |
|
| 52 | - * @param int $pid |
|
| 53 | - * @return array |
|
| 54 | - */ |
|
| 55 | - public function getModulesForPid($pid = null): array |
|
| 56 | - { |
|
| 57 | - if (!isset($this->storage[$pid])) { |
|
| 58 | - $modules = []; |
|
| 59 | - foreach ($GLOBALS['TCA'] as $dataType => $configuration) { |
|
| 60 | - if (Tca::table($dataType)->isNotHidden()) { |
|
| 61 | - $record = $this->getDataService()->getRecord( |
|
| 62 | - $dataType, |
|
| 63 | - [ |
|
| 64 | - 'pid' => $pid |
|
| 65 | - ] |
|
| 66 | - ); |
|
| 67 | - if (!empty($record)) { |
|
| 68 | - $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1'; |
|
| 69 | - $title = Tca::table($dataType)->getTitle(); |
|
| 70 | - $modules[$moduleName] = $title; |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - $this->storage[$pid] = $modules; |
|
| 75 | - } |
|
| 76 | - return $this->storage[$pid]; |
|
| 77 | - } |
|
| 49 | + /** |
|
| 50 | + * Fetch all modules displayed given a pid. |
|
| 51 | + * |
|
| 52 | + * @param int $pid |
|
| 53 | + * @return array |
|
| 54 | + */ |
|
| 55 | + public function getModulesForPid($pid = null): array |
|
| 56 | + { |
|
| 57 | + if (!isset($this->storage[$pid])) { |
|
| 58 | + $modules = []; |
|
| 59 | + foreach ($GLOBALS['TCA'] as $dataType => $configuration) { |
|
| 60 | + if (Tca::table($dataType)->isNotHidden()) { |
|
| 61 | + $record = $this->getDataService()->getRecord( |
|
| 62 | + $dataType, |
|
| 63 | + [ |
|
| 64 | + 'pid' => $pid |
|
| 65 | + ] |
|
| 66 | + ); |
|
| 67 | + if (!empty($record)) { |
|
| 68 | + $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1'; |
|
| 69 | + $title = Tca::table($dataType)->getTitle(); |
|
| 70 | + $modules[$moduleName] = $title; |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + $this->storage[$pid] = $modules; |
|
| 75 | + } |
|
| 76 | + return $this->storage[$pid]; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Fetch the first module for the current pid. |
|
| 81 | - * |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function getFirstModuleForCurrentPid(): string |
|
| 85 | - { |
|
| 86 | - $pid = $this->getModuleLoader()->getCurrentPid(); |
|
| 87 | - return $this->getFirstModuleForPid($pid); |
|
| 88 | - } |
|
| 79 | + /** |
|
| 80 | + * Fetch the first module for the current pid. |
|
| 81 | + * |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function getFirstModuleForCurrentPid(): string |
|
| 85 | + { |
|
| 86 | + $pid = $this->getModuleLoader()->getCurrentPid(); |
|
| 87 | + return $this->getFirstModuleForPid($pid); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Fetch the module given a pid. |
|
| 92 | - * |
|
| 93 | - * @param int $pid |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - public function getFirstModuleForPid($pid): string |
|
| 97 | - { |
|
| 98 | - $firstModule = ''; |
|
| 99 | - $modules = $this->getModulesForPid($pid); |
|
| 100 | - if (!empty($modules)) { |
|
| 101 | - $firstModule = key($modules); |
|
| 102 | - } |
|
| 90 | + /** |
|
| 91 | + * Fetch the module given a pid. |
|
| 92 | + * |
|
| 93 | + * @param int $pid |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + public function getFirstModuleForPid($pid): string |
|
| 97 | + { |
|
| 98 | + $firstModule = ''; |
|
| 99 | + $modules = $this->getModulesForPid($pid); |
|
| 100 | + if (!empty($modules)) { |
|
| 101 | + $firstModule = key($modules); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - return $firstModule; |
|
| 105 | - } |
|
| 104 | + return $firstModule; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * @return object|DataService |
|
| 109 | - */ |
|
| 110 | - protected function getDataService(): DataService |
|
| 111 | - { |
|
| 112 | - return GeneralUtility::makeInstance(DataService::class); |
|
| 113 | - } |
|
| 107 | + /** |
|
| 108 | + * @return object|DataService |
|
| 109 | + */ |
|
| 110 | + protected function getDataService(): DataService |
|
| 111 | + { |
|
| 112 | + return GeneralUtility::makeInstance(DataService::class); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Get the Vidi Module Loader. |
|
| 117 | - * |
|
| 118 | - * @return ModuleLoader|object |
|
| 119 | - */ |
|
| 120 | - protected function getModuleLoader() |
|
| 121 | - { |
|
| 122 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 123 | - } |
|
| 115 | + /** |
|
| 116 | + * Get the Vidi Module Loader. |
|
| 117 | + * |
|
| 118 | + * @return ModuleLoader|object |
|
| 119 | + */ |
|
| 120 | + protected function getModuleLoader() |
|
| 121 | + { |
|
| 122 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 123 | + } |
|
| 124 | 124 | } |
@@ -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 | } |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class ProcessAction extends Enumeration |
| 18 | 18 | { |
| 19 | - public const REMOVE = 'remove'; |
|
| 19 | + public const REMOVE = 'remove'; |
|
| 20 | 20 | |
| 21 | - public const UPDATE = 'update'; |
|
| 21 | + public const UPDATE = 'update'; |
|
| 22 | 22 | |
| 23 | - public const COPY = 'copy'; |
|
| 23 | + public const COPY = 'copy'; |
|
| 24 | 24 | |
| 25 | - public const MOVE = 'move'; |
|
| 25 | + public const MOVE = 'move'; |
|
| 26 | 26 | |
| 27 | - public const LOCALIZE = 'localize'; |
|
| 27 | + public const LOCALIZE = 'localize'; |
|
| 28 | 28 | } |
@@ -18,135 +18,135 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class CoreDataHandler extends AbstractDataHandler |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $dataHandler; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Process Content with action "update". |
|
| 28 | - * |
|
| 29 | - * @param Content $content |
|
| 30 | - * @throws \Exception |
|
| 31 | - * @return bool |
|
| 32 | - */ |
|
| 33 | - public function processUpdate(Content $content) |
|
| 34 | - { |
|
| 35 | - $values = []; |
|
| 36 | - |
|
| 37 | - // Check the field to be updated exists |
|
| 38 | - foreach ($content->toArray() as $fieldName => $value) { |
|
| 39 | - if (!Tca::table($content->getDataType())->hasField($fieldName)) { |
|
| 40 | - $message = sprintf('It looks field "%s" does not exist for data type "%s"', $fieldName, $content->getDataType()); |
|
| 41 | - throw new \Exception($message, 1390668497); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - // Flatten value if array given which is required for the DataHandler. |
|
| 45 | - if (is_array($value)) { |
|
| 46 | - $value = implode(',', $value); |
|
| 47 | - } |
|
| 48 | - $values[$fieldName] = $value; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - $data[$content->getDataType()][$content->getUid()] = $values; |
|
| 52 | - |
|
| 53 | - $dataHandler = $this->getDataHandler(); |
|
| 54 | - $dataHandler->start($data, array()); |
|
| 55 | - $dataHandler->process_datamap(); |
|
| 56 | - $this->errorMessages = $dataHandler->errorLog; |
|
| 57 | - |
|
| 58 | - // Returns true is log does not contain errors. |
|
| 59 | - return empty($dataHandler->errorLog); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Process Content with action "remove". |
|
| 64 | - * |
|
| 65 | - * @param Content $content |
|
| 66 | - * @return bool |
|
| 67 | - */ |
|
| 68 | - public function processRemove(Content $content) |
|
| 69 | - { |
|
| 70 | - // Build command |
|
| 71 | - $cmd[$content->getDataType()][$content->getUid()]['delete'] = 1; |
|
| 72 | - |
|
| 73 | - /** @var $dataHandler \TYPO3\CMS\Core\DataHandling\DataHandler */ |
|
| 74 | - $dataHandler = $this->getDataHandler(); |
|
| 75 | - $dataHandler->start([], $cmd); |
|
| 76 | - $dataHandler->process_datamap(); |
|
| 77 | - $dataHandler->process_cmdmap(); |
|
| 78 | - $this->errorMessages = $dataHandler->errorLog; |
|
| 79 | - |
|
| 80 | - // Returns true is log does not contain errors. |
|
| 81 | - return empty($dataHandler->errorLog); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Process Content with action "copy". |
|
| 86 | - * |
|
| 87 | - * @param Content $content |
|
| 88 | - * @param string $target |
|
| 89 | - * @return bool |
|
| 90 | - */ |
|
| 91 | - public function processCopy(Content $content, $target) |
|
| 92 | - { |
|
| 93 | - // TODO: Implement processCopy() method. |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Process Content with action "move". |
|
| 98 | - * The $target corresponds to the pid to move the records to. |
|
| 99 | - * It can also be a negative value in case of sorting. The negative value would be the uid of its predecessor. |
|
| 100 | - * |
|
| 101 | - * @param Content $content |
|
| 102 | - * @param int $target corresponds |
|
| 103 | - * @return bool |
|
| 104 | - */ |
|
| 105 | - public function processMove(Content $content, $target) |
|
| 106 | - { |
|
| 107 | - // Build command |
|
| 108 | - $cmd[$content->getDataType()][$content->getUid()]['move'] = $target; |
|
| 109 | - |
|
| 110 | - /** @var $dataHandler \TYPO3\CMS\Core\DataHandling\DataHandler */ |
|
| 111 | - $dataHandler = $this->getDataHandler(); |
|
| 112 | - $dataHandler->start([], $cmd); |
|
| 113 | - $dataHandler->process_datamap(); |
|
| 114 | - $dataHandler->process_cmdmap(); |
|
| 115 | - $this->errorMessages = $dataHandler->errorLog; |
|
| 116 | - |
|
| 117 | - // Returns true is log does not contain errors. |
|
| 118 | - return empty($dataHandler->errorLog); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Process Content with action "localize". |
|
| 123 | - * |
|
| 124 | - * @param Content $content |
|
| 125 | - * @param int $language |
|
| 126 | - * @return bool |
|
| 127 | - */ |
|
| 128 | - public function processLocalize(Content $content, $language) |
|
| 129 | - { |
|
| 130 | - $command[$content->getDataType()][$content->getUid()]['localize'] = $language; |
|
| 131 | - |
|
| 132 | - $dataHandler = $this->getDataHandler(); |
|
| 133 | - $dataHandler->start([], $command); |
|
| 134 | - $dataHandler->process_datamap(); |
|
| 135 | - $dataHandler->process_cmdmap(); |
|
| 136 | - $this->errorMessages = $dataHandler->errorLog; |
|
| 137 | - |
|
| 138 | - // Returns true is log does not contain errors. |
|
| 139 | - return empty($dataHandler->errorLog); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @return DataHandler |
|
| 144 | - */ |
|
| 145 | - protected function getDataHandler() |
|
| 146 | - { |
|
| 147 | - if (!$this->dataHandler) { |
|
| 148 | - $this->dataHandler = GeneralUtility::makeInstance(DataHandler::class); |
|
| 149 | - } |
|
| 150 | - return $this->dataHandler; |
|
| 151 | - } |
|
| 21 | + /** |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $dataHandler; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Process Content with action "update". |
|
| 28 | + * |
|
| 29 | + * @param Content $content |
|
| 30 | + * @throws \Exception |
|
| 31 | + * @return bool |
|
| 32 | + */ |
|
| 33 | + public function processUpdate(Content $content) |
|
| 34 | + { |
|
| 35 | + $values = []; |
|
| 36 | + |
|
| 37 | + // Check the field to be updated exists |
|
| 38 | + foreach ($content->toArray() as $fieldName => $value) { |
|
| 39 | + if (!Tca::table($content->getDataType())->hasField($fieldName)) { |
|
| 40 | + $message = sprintf('It looks field "%s" does not exist for data type "%s"', $fieldName, $content->getDataType()); |
|
| 41 | + throw new \Exception($message, 1390668497); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + // Flatten value if array given which is required for the DataHandler. |
|
| 45 | + if (is_array($value)) { |
|
| 46 | + $value = implode(',', $value); |
|
| 47 | + } |
|
| 48 | + $values[$fieldName] = $value; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + $data[$content->getDataType()][$content->getUid()] = $values; |
|
| 52 | + |
|
| 53 | + $dataHandler = $this->getDataHandler(); |
|
| 54 | + $dataHandler->start($data, array()); |
|
| 55 | + $dataHandler->process_datamap(); |
|
| 56 | + $this->errorMessages = $dataHandler->errorLog; |
|
| 57 | + |
|
| 58 | + // Returns true is log does not contain errors. |
|
| 59 | + return empty($dataHandler->errorLog); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Process Content with action "remove". |
|
| 64 | + * |
|
| 65 | + * @param Content $content |
|
| 66 | + * @return bool |
|
| 67 | + */ |
|
| 68 | + public function processRemove(Content $content) |
|
| 69 | + { |
|
| 70 | + // Build command |
|
| 71 | + $cmd[$content->getDataType()][$content->getUid()]['delete'] = 1; |
|
| 72 | + |
|
| 73 | + /** @var $dataHandler \TYPO3\CMS\Core\DataHandling\DataHandler */ |
|
| 74 | + $dataHandler = $this->getDataHandler(); |
|
| 75 | + $dataHandler->start([], $cmd); |
|
| 76 | + $dataHandler->process_datamap(); |
|
| 77 | + $dataHandler->process_cmdmap(); |
|
| 78 | + $this->errorMessages = $dataHandler->errorLog; |
|
| 79 | + |
|
| 80 | + // Returns true is log does not contain errors. |
|
| 81 | + return empty($dataHandler->errorLog); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Process Content with action "copy". |
|
| 86 | + * |
|
| 87 | + * @param Content $content |
|
| 88 | + * @param string $target |
|
| 89 | + * @return bool |
|
| 90 | + */ |
|
| 91 | + public function processCopy(Content $content, $target) |
|
| 92 | + { |
|
| 93 | + // TODO: Implement processCopy() method. |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Process Content with action "move". |
|
| 98 | + * The $target corresponds to the pid to move the records to. |
|
| 99 | + * It can also be a negative value in case of sorting. The negative value would be the uid of its predecessor. |
|
| 100 | + * |
|
| 101 | + * @param Content $content |
|
| 102 | + * @param int $target corresponds |
|
| 103 | + * @return bool |
|
| 104 | + */ |
|
| 105 | + public function processMove(Content $content, $target) |
|
| 106 | + { |
|
| 107 | + // Build command |
|
| 108 | + $cmd[$content->getDataType()][$content->getUid()]['move'] = $target; |
|
| 109 | + |
|
| 110 | + /** @var $dataHandler \TYPO3\CMS\Core\DataHandling\DataHandler */ |
|
| 111 | + $dataHandler = $this->getDataHandler(); |
|
| 112 | + $dataHandler->start([], $cmd); |
|
| 113 | + $dataHandler->process_datamap(); |
|
| 114 | + $dataHandler->process_cmdmap(); |
|
| 115 | + $this->errorMessages = $dataHandler->errorLog; |
|
| 116 | + |
|
| 117 | + // Returns true is log does not contain errors. |
|
| 118 | + return empty($dataHandler->errorLog); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Process Content with action "localize". |
|
| 123 | + * |
|
| 124 | + * @param Content $content |
|
| 125 | + * @param int $language |
|
| 126 | + * @return bool |
|
| 127 | + */ |
|
| 128 | + public function processLocalize(Content $content, $language) |
|
| 129 | + { |
|
| 130 | + $command[$content->getDataType()][$content->getUid()]['localize'] = $language; |
|
| 131 | + |
|
| 132 | + $dataHandler = $this->getDataHandler(); |
|
| 133 | + $dataHandler->start([], $command); |
|
| 134 | + $dataHandler->process_datamap(); |
|
| 135 | + $dataHandler->process_cmdmap(); |
|
| 136 | + $this->errorMessages = $dataHandler->errorLog; |
|
| 137 | + |
|
| 138 | + // Returns true is log does not contain errors. |
|
| 139 | + return empty($dataHandler->errorLog); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @return DataHandler |
|
| 144 | + */ |
|
| 145 | + protected function getDataHandler() |
|
| 146 | + { |
|
| 147 | + if (!$this->dataHandler) { |
|
| 148 | + $this->dataHandler = GeneralUtility::makeInstance(DataHandler::class); |
|
| 149 | + } |
|
| 150 | + return $this->dataHandler; |
|
| 151 | + } |
|
| 152 | 152 | } |
@@ -16,53 +16,53 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class BackendUserPreferenceService |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Returns a class instance |
|
| 21 | - * |
|
| 22 | - * @return \Fab\Vidi\Service\BackendUserPreferenceService|object |
|
| 23 | - */ |
|
| 24 | - public static 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 | + public static 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]; |
|
| 40 | - } |
|
| 41 | - return $result; |
|
| 42 | - } |
|
| 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 | + } |
|
| 41 | + return $result; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Set a configuration for the current BE User. |
|
| 46 | - * |
|
| 47 | - * @param string $key |
|
| 48 | - * @param mixed $value |
|
| 49 | - * @return void |
|
| 50 | - */ |
|
| 51 | - public function set($key, $value) |
|
| 52 | - { |
|
| 53 | - if ($this->getBackendUser()) { |
|
| 54 | - $this->getBackendUser()->uc[$key] = $value; |
|
| 55 | - $this->getBackendUser()->writeUC(); |
|
| 56 | - } |
|
| 57 | - } |
|
| 44 | + /** |
|
| 45 | + * Set a configuration for the current BE User. |
|
| 46 | + * |
|
| 47 | + * @param string $key |
|
| 48 | + * @param mixed $value |
|
| 49 | + * @return void |
|
| 50 | + */ |
|
| 51 | + public function set($key, $value) |
|
| 52 | + { |
|
| 53 | + if ($this->getBackendUser()) { |
|
| 54 | + $this->getBackendUser()->uc[$key] = $value; |
|
| 55 | + $this->getBackendUser()->writeUC(); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Returns an instance of the current Backend User. |
|
| 61 | - * |
|
| 62 | - * @return BackendUserAuthentication |
|
| 63 | - */ |
|
| 64 | - protected function getBackendUser() |
|
| 65 | - { |
|
| 66 | - return $GLOBALS['BE_USER']; |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * Returns an instance of the current Backend User. |
|
| 61 | + * |
|
| 62 | + * @return BackendUserAuthentication |
|
| 63 | + */ |
|
| 64 | + protected function getBackendUser() |
|
| 65 | + { |
|
| 66 | + return $GLOBALS['BE_USER']; |
|
| 67 | + } |
|
| 68 | 68 | } |