diff --git a/Classes/Backend/FormEngine/ButtonBar/ShowNotificationDetailsButton.php b/Classes/Backend/FormEngine/ButtonBar/ShowNotificationDetailsButton.php index 56921a4e..bc2b7e17 100644 --- a/Classes/Backend/FormEngine/ButtonBar/ShowNotificationDetailsButton.php +++ b/Classes/Backend/FormEngine/ButtonBar/ShowNotificationDetailsButton.php @@ -24,6 +24,7 @@ use CuyZ\Notiz\Service\LocalizationService; use ReflectionClass; use TYPO3\CMS\Backend\Controller\EditDocumentController; +use TYPO3\CMS\Backend\Controller\Event\AfterFormEnginePageInitializedEvent; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Core\Imaging\Icon; @@ -60,10 +61,12 @@ public function __construct(DefinitionService $definitionService, IconFactory $i } /** - * @param EditDocumentController $controller + * @param AfterFormEnginePageInitializedEvent $controller */ - public function addButton(EditDocumentController $controller) + public function addButton(AfterFormEnginePageInitializedEvent $event) { + $controller = $event->getController(); + if ($this->definitionService->getValidationResult()->hasErrors()) { return; } @@ -101,7 +104,8 @@ protected function getNotification(NotificationDefinition $notificationDefinitio return null; } - $uid = reset(array_keys($controller->editconf[$tableName])); + $array = array_keys($controller->editconf[$tableName]); + $uid = reset($array); // We show the button only for existing records being edited. if ($controller->editconf[$tableName][$uid] !== 'edit') { diff --git a/Classes/Backend/FormEngine/DataProvider/DefinitionError.php b/Classes/Backend/FormEngine/DataProvider/DefinitionError.php index 4ba89796..c68f7dbc 100644 --- a/Classes/Backend/FormEngine/DataProvider/DefinitionError.php +++ b/Classes/Backend/FormEngine/DataProvider/DefinitionError.php @@ -83,7 +83,7 @@ private function getDefinitionErrorTca(): array 'definition_error_message' => [ 'config' => [ 'type' => 'user', - 'userFunc' => self::class . '->getDefinitionErrorMessage', + 'renderType' => 'notizDefinitionErrorMessage', ], ], ], diff --git a/Classes/Backend/Module/AdministrationModuleHandler.php b/Classes/Backend/Module/AdministrationModuleHandler.php index f3ab5e47..6e12e102 100644 --- a/Classes/Backend/Module/AdministrationModuleHandler.php +++ b/Classes/Backend/Module/AdministrationModuleHandler.php @@ -32,6 +32,6 @@ public function getDefaultControllerName(): string */ public function getModuleName(): string { - return 'NotizNotiz_NotizNotizAdministration'; + return 'notiz_NotizNotizAdministration'; } } diff --git a/Classes/Backend/Module/ManagerModuleHandler.php b/Classes/Backend/Module/ManagerModuleHandler.php index c4fb9883..948c0c20 100644 --- a/Classes/Backend/Module/ManagerModuleHandler.php +++ b/Classes/Backend/Module/ManagerModuleHandler.php @@ -17,7 +17,12 @@ namespace CuyZ\Notiz\Backend\Module; +use CuyZ\Notiz\Controller\Backend\Manager\ListNotificationTypesController; +use CuyZ\Notiz\Controller\Backend\Manager\Notification\ShowEntityEmailController; +use CuyZ\Notiz\Controller\Backend\Manager\Notification\ShowEntityLogController; +use CuyZ\Notiz\Controller\Backend\Manager\Notification\ShowEntitySlackController; use CuyZ\Notiz\Service\Traits\ExtendedSelfInstantiateTrait; +use TYPO3\CMS\Extbase\Utility\ExtensionUtility; class ManagerModuleHandler extends ModuleHandler { @@ -28,7 +33,7 @@ class ManagerModuleHandler extends ModuleHandler */ public function getDefaultControllerName(): string { - return 'Backend\\Manager\\ListNotificationTypes'; + return ListNotificationTypesController::class; } /** @@ -36,7 +41,7 @@ public function getDefaultControllerName(): string */ public function getModuleName(): string { - return 'NotizNotiz_NotizNotizManager'; + return 'notiz_NotizNotizManager'; } /** @@ -45,21 +50,25 @@ public function getModuleName(): string public function registerEntityNotificationControllers() { $controllers = [ - 'Backend\\Manager\\Notification\\ShowEntityEmail' => [ + ShowEntityEmailController::class => [ 'show', 'preview', 'previewError', ], - 'Backend\\Manager\\Notification\\ShowEntityLog' => [ + ShowEntityLogController::class => [ 'show', ], - 'Backend\\Manager\\Notification\\ShowEntitySlack' => [ + ShowEntitySlackController::class => [ 'show', ], ]; foreach ($controllers as $controller => $actions) { - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['Notiz']['modules'][$this->getModuleName()]['controllers'][$controller] = ['actions' => $actions]; + $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['Notiz']['modules'][$this->getModuleName()]['controllers'][$controller] = [ + 'actions' => $actions, + 'className' => $controller, + 'alias' => ExtensionUtility::resolveControllerAliasFromControllerClassName($controller) + ]; } } } diff --git a/Classes/Backend/Module/ModuleHandler.php b/Classes/Backend/Module/ModuleHandler.php index 82cc1b45..c8de9e99 100644 --- a/Classes/Backend/Module/ModuleHandler.php +++ b/Classes/Backend/Module/ModuleHandler.php @@ -40,7 +40,6 @@ abstract class ModuleHandler implements SingletonInterface public function __construct(DefinitionService $definitionService) { $this->definitionService = $definitionService; - $this->uriBuilder = Container::get(UriBuilder::class, $this); } /** @@ -62,6 +61,9 @@ public static function for(string $module): ModuleHandler */ public function getUriBuilder(): UriBuilder { + if ($this->uriBuilder === null) { + $this->uriBuilder = Container::get(UriBuilder::class, $this); + } return $this->uriBuilder; } @@ -70,7 +72,11 @@ public function getUriBuilder(): UriBuilder */ public function canBeAccessed(): bool { - return Container::getBackendUser()->modAccess($GLOBALS['TBE_MODULES']['_configuration'][$this->getModuleName()], false); + try { + return Container::getBackendUser()->modAccess($GLOBALS['TBE_MODULES']['_configuration'][$this->getModuleName()]); + } catch (\RuntimeException $exception) { + return false; + } } /** diff --git a/Classes/Backend/Module/Uri/UriBuilder.php b/Classes/Backend/Module/Uri/UriBuilder.php index c8dd82e0..e7e7b343 100644 --- a/Classes/Backend/Module/Uri/UriBuilder.php +++ b/Classes/Backend/Module/Uri/UriBuilder.php @@ -102,11 +102,6 @@ public function build(): UriInterface $uri = $this->uriBuilder ->reset() ->setArguments([ - /* - * @deprecated `M` arguments must be removed when TYPO3 v8 is - * not supported anymore. - */ - 'M' => $module, 'route' => $module, ]) ->uriFor( diff --git a/Classes/Backend/ToolBarItems/NotificationsToolbarItem.php b/Classes/Backend/ToolBarItems/NotificationsToolbarItem.php index f1694756..adb7f464 100644 --- a/Classes/Backend/ToolBarItems/NotificationsToolbarItem.php +++ b/Classes/Backend/ToolBarItems/NotificationsToolbarItem.php @@ -27,6 +27,7 @@ use Psr\Http\Message\ServerRequestInterface; use Throwable; use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface; +use TYPO3\CMS\Core\Http\Response; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -135,13 +136,14 @@ public function getDropDown(): string * Action called periodically by Ajax (used to refresh the toolbar). * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function renderMenuAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function renderMenuAction(ServerRequestInterface $request): ResponseInterface { $this->fullMenu = true; + $response = new Response(); + $response->getBody()->write($this->getDropDown()); return $response->withHeader('Content-Type', 'text/html; charset=utf-8'); diff --git a/Classes/Controller/Backend/Manager/Notification/ShowNotificationController.php b/Classes/Controller/Backend/Manager/Notification/ShowNotificationController.php index 67a8afeb..3df57212 100644 --- a/Classes/Controller/Backend/Manager/Notification/ShowNotificationController.php +++ b/Classes/Controller/Backend/Manager/Notification/ShowNotificationController.php @@ -21,12 +21,12 @@ use CuyZ\Notiz\Controller\Backend\Menu; use CuyZ\Notiz\Core\Channel\Payload; use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition; -use CuyZ\Notiz\Core\Event\Event; use CuyZ\Notiz\Core\Event\Service\EventFactory; use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties; use CuyZ\Notiz\Core\Notification\Notification; -use CuyZ\Notiz\Core\Property\Factory\PropertyContainer; -use CuyZ\Notiz\Core\Property\Factory\PropertyFactory; +use CuyZ\Notiz\Core\Property\Factory\PropertyFillingEvent; +use TYPO3\CMS\Core\EventDispatcher\ListenerProvider; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; abstract class ShowNotificationController extends ManagerController @@ -41,11 +41,6 @@ abstract class ShowNotificationController extends ManagerController */ protected $notification; - /** - * @var EventFactory - */ - protected $eventFactory; - /** * @param ViewInterface $view */ @@ -118,37 +113,30 @@ protected function fetchNotification() */ protected function getPreviewPayload(): Payload { - $fakeEvent = $this->eventFactory->create($this->notification->getEventDefinition(), $this->notification); + $fakeEvent = EventFactory::create($this->notification->getEventDefinition(), $this->notification); if ($fakeEvent instanceof ProvidesExampleProperties) { - $this->signalSlotDispatcher->connect( - PropertyFactory::class, - PropertyFactory::SIGNAL_PROPERTY_FILLING, - function (PropertyContainer $container, Event $event) use ($fakeEvent) { - if ($event !== $fakeEvent) { - return; - } - - $exampleProperties = $fakeEvent->getExampleProperties(); - - foreach ($container->getEntries() as $property) { - if (isset($exampleProperties[$property->getName()])) { - $property->setValue($exampleProperties[$property->getName()]); - } - } - } - ); + GeneralUtility::makeInstance(ListenerProvider::class) + ->addListener(PropertyFillingEvent::class, \get_class($this), 'onPropertyFilling'); } return new Payload($this->notification, $this->notificationDefinition, $fakeEvent); } - /** - * @param EventFactory $eventFactory - */ - public function injectEventFactory(EventFactory $eventFactory) + public function onPropertyFilling(PropertyFillingEvent $propertyFillingEvent) { - $this->eventFactory = $eventFactory; + $event = $propertyFillingEvent->getEvent(); + $container = $propertyFillingEvent->getPropertyContainer(); + + if ($event instanceof ProvidesExampleProperties) { + $exampleProperties = $event->getExampleProperties(); + } + + foreach ($container->getEntries() as $property) { + if (isset($exampleProperties[$property->getName()])) { + $property->setValue($exampleProperties[$property->getName()]); + } + } } /** diff --git a/Classes/Core/Channel/AbstractChannel.php b/Classes/Core/Channel/AbstractChannel.php index 61650ca8..16c28e71 100644 --- a/Classes/Core/Channel/AbstractChannel.php +++ b/Classes/Core/Channel/AbstractChannel.php @@ -195,8 +195,6 @@ public static function getSettingsClassName(): string $reflectionService = Container::get(ReflectionService::class); $settingsProperty = $reflectionService->getClassSchema(static::class)->getProperty('settings'); - $settingsClassName = $settingsProperty['type']; - - return $settingsClassName; + return $settingsProperty->getType(); } } diff --git a/Classes/Core/Definition/Builder/DefinitionBuilder.php b/Classes/Core/Definition/Builder/DefinitionBuilder.php index 63dc7b70..3dfeb5df 100644 --- a/Classes/Core/Definition/Builder/DefinitionBuilder.php +++ b/Classes/Core/Definition/Builder/DefinitionBuilder.php @@ -18,17 +18,19 @@ namespace CuyZ\Notiz\Core\Definition\Builder; use CuyZ\Notiz\Core\Definition\Builder\Component\DefinitionComponents; +use CuyZ\Notiz\Core\Definition\Builder\Event\DefinitionBuilderBuiltEvent; +use CuyZ\Notiz\Core\Definition\Builder\Event\DefinitionBuilderManageComponentEvent; use CuyZ\Notiz\Core\Definition\Tree\Definition; use CuyZ\Notiz\Core\Support\NotizConstants; use CuyZ\Notiz\Service\CacheService; use CuyZ\Notiz\Service\Traits\ExtendedSelfInstantiateTrait; use CuyZ\Notiz\Validation\Validator\DefinitionValidator; +use Psr\EventDispatcher\EventDispatcherInterface; use Romm\ConfigurationObject\ConfigurationObjectFactory; use Romm\ConfigurationObject\ConfigurationObjectInstance; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; /** * This class is responsible for building a whole PHP definition object that can @@ -62,7 +64,7 @@ * * --- * - * Register new components + * Register new components TODO update docs * ----------------------- * * To register new components in your own API, you first need to connect a class @@ -105,9 +107,6 @@ class DefinitionBuilder implements SingletonInterface { use ExtendedSelfInstantiateTrait; - const COMPONENTS_SIGNAL = 'manageDefinitionComponents'; - const DEFINITION_BUILT_SIGNAL = 'definitionBuilt'; - /** * @var DefinitionComponents */ @@ -124,20 +123,20 @@ class DefinitionBuilder implements SingletonInterface protected $cacheService; /** - * @var Dispatcher + * @var EventDispatcherInterface */ - protected $dispatcher; + protected $eventDispatcher; /** * @param DefinitionComponents $components * @param CacheService $cacheService - * @param Dispatcher $dispatcher + * @param EventDispatcherInterface $dispatcher */ - public function __construct(DefinitionComponents $components, CacheService $cacheService, Dispatcher $dispatcher) + public function __construct(DefinitionComponents $components, CacheService $cacheService, EventDispatcherInterface $eventDispatcher) { $this->components = $components; $this->cacheService = $cacheService; - $this->dispatcher = $dispatcher; + $this->eventDispatcher = $eventDispatcher; } /** @@ -230,13 +229,9 @@ protected function runProcessors(ConfigurationObjectInstance $definitionObject) * Sends a signal to allow external API to manage their own definition * components. */ - protected function sendComponentsSignal() + protected function sendComponentsSignal(): void { - $this->dispatcher->dispatch( - self::class, - self::COMPONENTS_SIGNAL, - [$this->components] - ); + $this->eventDispatcher->dispatch(new DefinitionBuilderManageComponentEvent($this->components)); } /** @@ -245,14 +240,10 @@ protected function sendComponentsSignal() * Please be aware that this signal is sent only if no error was found when * the definition was built. */ - protected function sendDefinitionBuiltSignal() + protected function sendDefinitionBuiltSignal(): void { if (!$this->definitionObject->getValidationResult()->hasErrors()) { - $this->dispatcher->dispatch( - self::class, - self::DEFINITION_BUILT_SIGNAL, - [$this->definitionObject->getObject()] - ); + $this->eventDispatcher->dispatch(new DefinitionBuilderBuiltEvent($this->definitionObject->getObject())); } } } diff --git a/Classes/Core/Definition/Builder/Event/DefinitionBuilderBuiltEvent.php b/Classes/Core/Definition/Builder/Event/DefinitionBuilderBuiltEvent.php new file mode 100644 index 00000000..8bf875f3 --- /dev/null +++ b/Classes/Core/Definition/Builder/Event/DefinitionBuilderBuiltEvent.php @@ -0,0 +1,34 @@ +definitionObject = $definitionObject; + } + + /** + * @return ConfigurationObjectInterface + */ + public function getDefinitionObject(): ConfigurationObjectInterface + { + return $this->definitionObject; + } + +} diff --git a/Classes/Core/Definition/Builder/Event/DefinitionBuilderManageComponentEvent.php b/Classes/Core/Definition/Builder/Event/DefinitionBuilderManageComponentEvent.php new file mode 100644 index 00000000..64c79df5 --- /dev/null +++ b/Classes/Core/Definition/Builder/Event/DefinitionBuilderManageComponentEvent.php @@ -0,0 +1,31 @@ +components = $components; + } + + /** + * @return DefinitionComponents + */ + public function getComponents(): DefinitionComponents + { + return $this->components; + } + +} diff --git a/Classes/Core/Definition/Tree/Definition.php b/Classes/Core/Definition/Tree/Definition.php index 69172210..3759f5e9 100644 --- a/Classes/Core/Definition/Tree/Definition.php +++ b/Classes/Core/Definition/Tree/Definition.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Core\Definition\Tree; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Definition\Tree\EventGroup\EventGroup; use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition; @@ -43,7 +44,7 @@ class Definition extends AbstractDefinitionComponent implements ConfigurationObj /** * @var \CuyZ\Notiz\Core\Definition\Tree\EventGroup\EventGroup[] * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $eventGroups = []; @@ -130,7 +131,8 @@ public function hasEventFromFullIdentifier(string $fullIdentifier): bool */ public function getFirstEventGroup(): EventGroup { - return array_pop(array_reverse($this->getEventGroups())); + $array = array_reverse($this->getEventGroups()); + return array_pop($array); } /** @@ -184,8 +186,6 @@ public function getNotification(string $identifier): NotificationDefinition public static function getConfigurationObjectServices() { return ServiceFactory::getInstance() - ->attach(ServiceInterface::SERVICE_CACHE) - ->setOption(CacheService::OPTION_CACHE_NAME, NotizConstants::CACHE_KEY_DEFINITION_OBJECT) ->attach(ServiceInterface::SERVICE_PARENTS) ->attach(ServiceInterface::SERVICE_DATA_PRE_PROCESSOR) ->attach(ServiceInterface::SERVICE_MIXED_TYPES); diff --git a/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Connection.php b/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Connection.php index cfe5bfec..4fed8843 100644 --- a/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Connection.php +++ b/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Connection.php @@ -17,7 +17,7 @@ namespace CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\Connection; -use CuyZ\Notiz\Core\Event\Runner\EventRunner; +use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; interface Connection { @@ -27,8 +27,7 @@ interface Connection /** * Registers the event connection. * - * @param EventRunner $eventRunner * @return void */ - public function register(EventRunner $eventRunner); + public function register(EventDefinition $definition); } diff --git a/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Hook.php b/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Hook.php index e252f8b2..663c5fd3 100644 --- a/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Hook.php +++ b/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Hook.php @@ -19,11 +19,14 @@ use Closure; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; +use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Event\Runner\EventRunner; use CuyZ\Notiz\Core\Event\Runner\EventRunnerContainer; use CuyZ\Notiz\Core\Exception\ClassNotFoundException; use CuyZ\Notiz\Core\Exception\WrongFormatException; use TYPO3\CMS\Core\Utility\ArrayUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Annotation as Extbase; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class Hook extends AbstractDefinitionComponent implements Connection @@ -33,21 +36,21 @@ class Hook extends AbstractDefinitionComponent implements Connection /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $path; /** * @var string * - * @validate Romm.ConfigurationObject:ClassExists + * @Extbase\Validate("Romm\ConfigurationObject\Validation\Validator\ClassExistsValidator") */ protected $interface; /** * @var string * - * @validate RegularExpression(regularExpression=/^[_a-zA-Z]+\w*$/) + * @Extbase\Validate("RegularExpression", options={"regularExpression": "/^[_a-zA-Z]+\w*$/"}) */ protected $method; @@ -67,19 +70,21 @@ public function getPath(): string * * @param EventRunner $eventRunner */ - public function register(EventRunner $eventRunner) + public function register(EventDefinition $definition) { if ($this->hookIsRegistered()) { return; } + $eventRunner = GeneralUtility::makeInstance(EventRunner::class); + if (!empty($this->interface) || !empty($this->method) ) { - $closure = $this->preventEvalNeverIdealStuff($eventRunner); + $closure = $this->preventEvalNeverIdealStuff($definition); } else { - $closure = function () use ($eventRunner) { - return call_user_func_array($eventRunner->getCallable(), func_get_args()); + $closure = function () use ($eventRunner, $definition) { + return call_user_func_array($eventRunner->getClosure($definition), func_get_args()); }; } @@ -115,9 +120,9 @@ protected function injectHookInGlobalArray($closure) * @throws ClassNotFoundException * @throws WrongFormatException */ - protected function preventEvalNeverIdealStuff(EventRunner $eventRunner): string + protected function preventEvalNeverIdealStuff(EventDefinition $definition): string { - $className = 'notiz_hook_' . sha1($eventRunner->getEventDefinition()->getFullIdentifier()); + $className = 'notiz_hook_' . sha1($definition->getFullIdentifier()); $implements = $this->interface ? 'implements ' . $this->interface @@ -135,7 +140,7 @@ protected function preventEvalNeverIdealStuff(EventRunner $eventRunner): string throw WrongFormatException::eventHookMethodNameWrongFormat($method, $this); } - $classPhpCode = $this->anotherNonUsefulSystem($className, $implements, $method, $eventRunner); + $classPhpCode = $this->anotherNonUsefulSystem($className, $implements, $method, $definition); // Please lord, forgive me. eval($classPhpCode); @@ -152,7 +157,7 @@ protected function preventEvalNeverIdealStuff(EventRunner $eventRunner): string * @param EventRunner $eventRunner * @return string */ - protected function anotherNonUsefulSystem(string $className, string $implements, string $method, EventRunner $eventRunner): string + protected function anotherNonUsefulSystem(string $className, string $implements, string $method, EventDefinition $eventDefinition): string { $eventRunnerContainerClass = EventRunnerContainer::class; @@ -161,7 +166,7 @@ class $className $implements { public function $method(...\$arguments) { - \$eventRunner = $eventRunnerContainerClass::getInstance()->get('{$eventRunner->getEventDefinition()->getFullIdentifier()}'); + \$eventRunner = $eventRunnerContainerClass::getInstance()->get('{$eventDefinition->getFullIdentifier()}'); call_user_func_array(\$eventRunner->getCallable(), \$arguments); } diff --git a/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Signal.php b/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Signal.php index 28a406f6..a30eae34 100644 --- a/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Signal.php +++ b/Classes/Core/Definition/Tree/EventGroup/Event/Connection/Signal.php @@ -18,8 +18,11 @@ namespace CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\Connection; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; +use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Event\Runner\EventRunner; use CuyZ\Notiz\Service\Container; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Annotation as Extbase; use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; class Signal extends AbstractDefinitionComponent implements Connection @@ -27,14 +30,14 @@ class Signal extends AbstractDefinitionComponent implements Connection /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $className; /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $name; @@ -50,18 +53,19 @@ public function __construct(string $className, string $name) /** * Registers the signal in TYPO3 signal slot dispatcher. + * TODO remove method body since signal slots are deprecated and replaced by NotizEvent wrapper * * @param EventRunner $eventRunner */ - public function register(EventRunner $eventRunner) + public function register(EventDefinition $definition) { /** @var Dispatcher $signalSlotDispatcher */ $signalSlotDispatcher = Container::get(Dispatcher::class); - + $eventRunner = GeneralUtility::makeInstance(EventRunner::class); $signalSlotDispatcher->connect( $this->className, $this->name, - ...$eventRunner->getCallable() + $eventRunner->getClosure($definition) ); } diff --git a/Classes/Core/Definition/Tree/EventGroup/Event/EventDefinition.php b/Classes/Core/Definition/Tree/EventGroup/Event/EventDefinition.php index bd833afd..daf8be4e 100644 --- a/Classes/Core/Definition/Tree/EventGroup/Event/EventDefinition.php +++ b/Classes/Core/Definition/Tree/EventGroup/Event/EventDefinition.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; use CuyZ\Notiz\Core\Definition\Tree\Definition; use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\Configuration\EventConfiguration; @@ -37,7 +38,7 @@ class EventDefinition extends AbstractDefinitionComponent implements DataPreProc /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $identifier; @@ -54,7 +55,7 @@ class EventDefinition extends AbstractDefinitionComponent implements DataPreProc /** * @var string * - * @validate Romm.ConfigurationObject:ClassImplements(interface=CuyZ\Notiz\Core\Event\Event) + * @Extbase\Validate("Romm\ConfigurationObject\Validation\Validator\ClassImplementsValidator", options={"interface": "CuyZ\Notiz\Core\Event\Event"}) */ protected $className; @@ -66,9 +67,9 @@ class EventDefinition extends AbstractDefinitionComponent implements DataPreProc /** * @var \CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\Connection\Connection * - * @validate NotEmpty * * @mixedTypesResolver \CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\Connection\ConnectionResolver + * @Extbase\Validate("NotEmpty") */ protected $connection; diff --git a/Classes/Core/Definition/Tree/EventGroup/EventGroup.php b/Classes/Core/Definition/Tree/EventGroup/EventGroup.php index 3cbaa050..e59256f4 100644 --- a/Classes/Core/Definition/Tree/EventGroup/EventGroup.php +++ b/Classes/Core/Definition/Tree/EventGroup/EventGroup.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Core\Definition\Tree\EventGroup; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Exception\EntryNotFoundException; @@ -29,7 +30,7 @@ class EventGroup extends AbstractDefinitionComponent implements DataPreProcessor /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $identifier; @@ -41,14 +42,14 @@ class EventGroup extends AbstractDefinitionComponent implements DataPreProcessor /** * @var \CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition[] * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $events = []; /** * @param string $identifier */ - public function __construct(string $identifier) + public function __construct(string $identifier = null) { $this->identifier = $identifier; } @@ -106,7 +107,8 @@ public function getEvent(string $identifier): EventDefinition */ public function getFirstEvent(): EventDefinition { - return array_pop(array_reverse($this->getEvents())); + $array = array_reverse($this->getEvents()); + return array_pop($array); } /** diff --git a/Classes/Core/Definition/Tree/Notification/Channel/ChannelDefinition.php b/Classes/Core/Definition/Tree/Notification/Channel/ChannelDefinition.php index 6e9a1597..fd3103a5 100644 --- a/Classes/Core/Definition/Tree/Notification/Channel/ChannelDefinition.php +++ b/Classes/Core/Definition/Tree/Notification/Channel/ChannelDefinition.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Core\Definition\Tree\Notification\Channel; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Channel\Channel; use CuyZ\Notiz\Core\Channel\Settings\ChannelSettings; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; @@ -33,15 +34,15 @@ class ChannelDefinition extends AbstractDefinitionComponent implements DataPrePr /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $identifier; /** * @var string * - * @validate NotEmpty - * @validate Romm.ConfigurationObject:ClassImplements(interface=CuyZ\Notiz\Core\Channel\Channel) + * @Extbase\Validate("NotEmpty") + * @Extbase\Validate("Romm\ConfigurationObject\Validation\Validator\ClassImplementsValidator", options={"interface": "CuyZ\Notiz\Core\Channel\Channel"}) */ protected $className; diff --git a/Classes/Core/Definition/Tree/Notification/NotificationDefinition.php b/Classes/Core/Definition/Tree/Notification/NotificationDefinition.php index 5bf8663e..2fbc5cf3 100644 --- a/Classes/Core/Definition/Tree/Notification/NotificationDefinition.php +++ b/Classes/Core/Definition/Tree/Notification/NotificationDefinition.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Core\Definition\Tree\Notification; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; use CuyZ\Notiz\Core\Definition\Tree\Notification\Channel\ChannelDefinition; use CuyZ\Notiz\Core\Exception\ClassNotFoundException; @@ -41,7 +42,7 @@ class NotificationDefinition extends AbstractDefinitionComponent implements Data /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $identifier; @@ -58,8 +59,8 @@ class NotificationDefinition extends AbstractDefinitionComponent implements Data /** * @var string * - * @validate NotEmpty - * @validate Romm.ConfigurationObject:ClassImplements(interface=CuyZ\Notiz\Core\Notification\Notification) + * @Extbase\Validate("NotEmpty") + * @Extbase\Validate("Romm\ConfigurationObject\Validation\Validator\ClassImplementsValidator", options={"interface": "CuyZ\Notiz\Core\Notification\Notification"}) */ protected $className; @@ -73,21 +74,21 @@ class NotificationDefinition extends AbstractDefinitionComponent implements Data /** * @var \CuyZ\Notiz\Core\Definition\Tree\Notification\Channel\ChannelDefinition[] * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $channels = []; /** * @var string * - * @validate Romm.ConfigurationObject:FileExists + * @Extbase\Validate("Romm\ConfigurationObject\Validation\Validator\FileExistsValidator") */ protected $iconPath; /** * @param string $identifier */ - public function __construct(string $identifier) + public function __construct(string $identifier = null) { $this->identifier = $identifier; } @@ -227,7 +228,7 @@ public static function dataPreProcessor(DataPreProcessor $processor) */ protected static function fetchSettingsClassName(array $data): array { - $notificationClassName = $data['className'] ?? null; + $notificationClassName = $data['className'] ?? ''; if (class_exists($notificationClassName) && in_array(CustomSettingsNotification::class, class_implements($notificationClassName)) diff --git a/Classes/Core/Event/AbstractEvent.php b/Classes/Core/Event/AbstractEvent.php index 7f60c462..63d40346 100644 --- a/Classes/Core/Event/AbstractEvent.php +++ b/Classes/Core/Event/AbstractEvent.php @@ -24,10 +24,8 @@ use CuyZ\Notiz\Core\Notification\Notification; use CuyZ\Notiz\Core\Property\Builder\PropertyBuilder; use CuyZ\Notiz\Core\Property\Factory\PropertyContainer; -use CuyZ\Notiz\Core\Property\Factory\PropertyFactory; use CuyZ\Notiz\Domain\Property\Builder\TagsPropertyBuilder; use CuyZ\Notiz\Service\Container; -use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Default event implementation provided by this extension, you can use it for @@ -94,16 +92,6 @@ abstract class AbstractEvent implements Event, HasProperties */ protected $configuration = []; - /** - * @var PropertyFactory - */ - protected $propertyFactory; - - /** - * @var ObjectManager - */ - protected $objectManager; - /** * WARNING * ------- @@ -113,16 +101,12 @@ abstract class AbstractEvent implements Event, HasProperties * * @param EventDefinition $eventDefinition * @param Notification $notification - * @param PropertyFactory $propertyFactory - * @param ObjectManager $objectManager */ - public function __construct(EventDefinition $eventDefinition, Notification $notification, PropertyFactory $propertyFactory, ObjectManager $objectManager) + public function __construct(EventDefinition $eventDefinition, Notification $notification) { $this->eventDefinition = $eventDefinition; $this->notification = $notification; $this->configuration = $notification->getEventConfiguration(); - $this->propertyFactory = $propertyFactory; - $this->objectManager = $objectManager; } /** diff --git a/Classes/Core/Event/Configuration/FlexForm/DefaultEventFlexFormProvider.php b/Classes/Core/Event/Configuration/FlexForm/DefaultEventFlexFormProvider.php index d6a20908..14877687 100644 --- a/Classes/Core/Event/Configuration/FlexForm/DefaultEventFlexFormProvider.php +++ b/Classes/Core/Event/Configuration/FlexForm/DefaultEventFlexFormProvider.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Core\Event\Configuration\FlexForm; +use TYPO3\CMS\Extbase\Annotation as Extbase; /** * Default implementation of a FlexForm provider, it does nothing more than * returning the path to the given file, so TCA can handle the FlexForm file @@ -27,7 +28,7 @@ class DefaultEventFlexFormProvider implements EventFlexFormProvider /** * @var string * - * @validate Romm.ConfigurationObject:FileExists + * @Extbase\Validate("Romm\ConfigurationObject\Validation\Validator\FileExistsValidator") */ protected $file; diff --git a/Classes/Core/Event/NotizEvent.php b/Classes/Core/Event/NotizEvent.php new file mode 100644 index 00000000..fe6f41d8 --- /dev/null +++ b/Classes/Core/Event/NotizEvent.php @@ -0,0 +1,35 @@ +identifier = $identifier; + $this->args = $args; + } + + /** + * @return string + */ + public function getIdentifier(): string + { + return $this->identifier; + } + + /** + * @return array + */ + public function getArgs(): array + { + return $this->args; + } + +} diff --git a/Classes/Core/Event/Runner/DispatchErrorEvent.php b/Classes/Core/Event/Runner/DispatchErrorEvent.php new file mode 100644 index 00000000..01193b51 --- /dev/null +++ b/Classes/Core/Event/Runner/DispatchErrorEvent.php @@ -0,0 +1,49 @@ +exception = $exception; + $this->event = $event; + $this->notification = $notification; + } + + /** + * @return Throwable + */ + public function getException(): Throwable + { + return $this->exception; + } + + /** + * @return Event + */ + public function getEvent(): Event + { + return $this->event; + } + + /** + * @return Notification + */ + public function getNotification(): Notification + { + return $this->notification; + } + +} diff --git a/Classes/Core/Event/Runner/DispatchedEvent.php b/Classes/Core/Event/Runner/DispatchedEvent.php new file mode 100644 index 00000000..8ea286e4 --- /dev/null +++ b/Classes/Core/Event/Runner/DispatchedEvent.php @@ -0,0 +1,38 @@ +event = $event; + $this->notification = $notification; + } + + /** + * @return Event + */ + public function getEvent(): Event + { + return $this->event; + } + + /** + * @return Notification + */ + public function getNotification(): Notification + { + return $this->notification; + } + +} diff --git a/Classes/Core/Event/Runner/EventRunner.php b/Classes/Core/Event/Runner/EventRunner.php index 333ec2d7..ee5a71c1 100644 --- a/Classes/Core/Event/Runner/EventRunner.php +++ b/Classes/Core/Event/Runner/EventRunner.php @@ -21,32 +21,21 @@ use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Event\Event; use CuyZ\Notiz\Core\Event\Exception\CancelEventDispatch; +use CuyZ\Notiz\Core\Event\NotizEvent; use CuyZ\Notiz\Core\Event\Service\EventFactory; use CuyZ\Notiz\Core\Notification\Notification; use CuyZ\Notiz\Core\Notification\NotificationDispatcher; use CuyZ\Notiz\Service\ExtensionConfigurationService; use Throwable; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; +use TYPO3\CMS\Core\EventDispatcher\EventDispatcher; +use TYPO3\CMS\Core\SingletonInterface; /** * This class is used as a bridge between the trigger of an event and a * notification dispatch. */ -class EventRunner +class EventRunner implements SingletonInterface { - const SIGNAL_EVENT_WAS_DISPATCHED = 'eventWasDispatched'; - - const SIGNAL_EVENT_DISPATCH_ERROR = 'eventDispatchError'; - - /** - * @var EventDefinition - */ - protected $eventDefinition; - - /** - * @var Dispatcher - */ - protected $signalDispatcher; /** * @var ExtensionConfigurationService @@ -59,40 +48,42 @@ class EventRunner protected $notificationDispatcher; /** - * @var EventFactory + * @var EventDispatcher */ - protected $eventFactory; + protected $eventDispatcher; + + /** + * @var EventRunnerContainer + */ + protected $eventRunnerContainer; /** - * @param EventDefinition $eventDefinition - * @param EventFactory $eventFactory * @param NotificationDispatcher $notificationDispatcher - * @param Dispatcher $signalDispatcher + * @param EventDispatcher $eventDispatcher * @param ExtensionConfigurationService $extensionConfigurationService */ public function __construct( - EventDefinition $eventDefinition, - EventFactory $eventFactory, NotificationDispatcher $notificationDispatcher, - Dispatcher $signalDispatcher, - ExtensionConfigurationService $extensionConfigurationService + EventDispatcher $eventDispatcher, + ExtensionConfigurationService $extensionConfigurationService, + EventRunnerContainer $eventRunnerContainer ) { - $this->eventDefinition = $eventDefinition; - $this->signalDispatcher = $signalDispatcher; - $this->extensionConfigurationService = $extensionConfigurationService; $this->notificationDispatcher = $notificationDispatcher; - $this->eventFactory = $eventFactory; + $this->eventDispatcher = $eventDispatcher; + $this->extensionConfigurationService = $extensionConfigurationService; + $this->eventRunnerContainer = $eventRunnerContainer; } /** + * @param EventDefinition $eventDefinition * @param mixed ...$arguments */ - public function process(...$arguments) + public function process(EventDefinition $eventDefinition, ...$arguments) { - $notifications = $this->notificationDispatcher->fetchNotifications($this->eventDefinition); + $notifications = $this->notificationDispatcher->fetchNotifications($eventDefinition); foreach ($notifications as $notification => $dispatchCallback) { - $event = $this->eventFactory->create($this->eventDefinition, $notification); + $event = EventFactory::create($eventDefinition, $notification); $doDispatch = true; if (is_callable([$event, 'run'])) { @@ -118,33 +109,23 @@ public function process(...$arguments) * - When the dispatch ran well; * - If an error occurred during the dispatch. * - * @see \CuyZ\Notiz\Core\Event\Runner\EventRunner::SIGNAL_EVENT_WAS_DISPATCHED - * @see \CuyZ\Notiz\Core\Event\Runner\EventRunner::SIGNAL_EVENT_DISPATCH_ERROR - * * @param Closure $callback * @param Event $event * @param Notification $notification * * @throws Throwable + * @see \CuyZ\Notiz\Core\Event\Runner\DispatchedEvent + * @see \CuyZ\Notiz\Core\Event\Runner\DispatchErrorEvent + * */ protected function dispatchEvent(Closure $callback, Event $event, Notification $notification) { - $exception = null; - try { $callback($event); - $this->signalDispatcher->dispatch( - self::class, - self::SIGNAL_EVENT_WAS_DISPATCHED, - [$event, $notification] - ); + $this->eventDispatcher->dispatch(new DispatchedEvent($event, $notification)); } catch (Throwable $exception) { - $this->signalDispatcher->dispatch( - self::class, - self::SIGNAL_EVENT_DISPATCH_ERROR, - [$exception, $event, $notification] - ); + $this->eventDispatcher->dispatch(new DispatchErrorEvent($exception, $event, $notification)); $gracefulMode = $this->extensionConfigurationService->getConfigurationValue('dispatch.graceful_mode'); @@ -155,19 +136,13 @@ protected function dispatchEvent(Closure $callback, Event $event, Notification $ } /** - * @return callable - */ - public function getCallable(): callable - { - return [$this, 'process']; - } - - /** - * @return EventDefinition + * @return \Closure */ - public function getEventDefinition(): EventDefinition + public function getClosure(EventDefinition $definition): \Closure { - return $this->eventDefinition; + return function (...$args) use ($definition) { + $this->process($definition, ...$args); + }; } /** @@ -184,4 +159,16 @@ public function __sleep(): array { return []; } + + public function __invoke(NotizEvent $event) + { + $identifier = $event->getIdentifier(); + $args = $event->getArgs(); + + if ($this->eventRunnerContainer->has($identifier)) { + $eventDefinition = $this->eventRunnerContainer->get($identifier); + $this->process($eventDefinition, ...$args); + } + } + } diff --git a/Classes/Core/Event/Runner/EventRunnerContainer.php b/Classes/Core/Event/Runner/EventRunnerContainer.php index 675d1d82..7cb3082f 100644 --- a/Classes/Core/Event/Runner/EventRunnerContainer.php +++ b/Classes/Core/Event/Runner/EventRunnerContainer.php @@ -19,7 +19,6 @@ use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Exception\EntryNotFoundException; -use CuyZ\Notiz\Service\Container; use CuyZ\Notiz\Service\Traits\SelfInstantiateTrait; use TYPO3\CMS\Core\SingletonInterface; @@ -37,26 +36,23 @@ class EventRunnerContainer implements SingletonInterface } /** - * @var EventRunner[] + * @var EventDefinition[] */ - protected $entries; + protected $eventDefinitions; /** * @param EventDefinition $eventDefinition - * @return EventRunner + * @return EventDefinition */ - public function add(EventDefinition $eventDefinition): EventRunner + public function add(EventDefinition $eventDefinition): EventDefinition { $identifier = $eventDefinition->getFullIdentifier(); if (false === $this->has($identifier)) { - /** @var EventRunner $runner */ - $runner = Container::get(EventRunner::class, $eventDefinition); - - $this->entries[$identifier] = $runner; + $this->eventDefinitions[$identifier] = $eventDefinition; } - return $this->entries[$identifier]; + return $this->eventDefinitions[$identifier]; } /** @@ -65,21 +61,22 @@ public function add(EventDefinition $eventDefinition): EventRunner */ public function has(string $identifier): bool { - return isset($this->entries[$identifier]); + return isset($this->eventDefinitions[$identifier]); } /** * @param string $identifier - * @return EventRunner + * @return EventDefinition * * @throws EntryNotFoundException */ - public function get(string $identifier): EventRunner + public function get(string $identifier): EventDefinition { if (false === $this->has($identifier)) { throw EntryNotFoundException::eventRunnerEntryNotFound($identifier); } - return $this->entries[$identifier]; + return $this->eventDefinitions[$identifier]; } + } diff --git a/Classes/Core/Event/Service/EventFactory.php b/Classes/Core/Event/Service/EventFactory.php index cd33f8b5..3f7bb818 100644 --- a/Classes/Core/Event/Service/EventFactory.php +++ b/Classes/Core/Event/Service/EventFactory.php @@ -22,31 +22,10 @@ use CuyZ\Notiz\Core\Exception\ClassNotFoundException; use CuyZ\Notiz\Core\Exception\InvalidClassException; use CuyZ\Notiz\Core\Notification\Notification; -use TYPO3\CMS\Core\SingletonInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Core\Utility\GeneralUtility; -class EventFactory implements SingletonInterface +class EventFactory { - /** - * @var EventRegistry - */ - protected $eventRegistry; - - /** - * @var ObjectManager - */ - protected $objectManager; - - /** - * @param EventRegistry $eventRegistry - * @param ObjectManager $objectManager - */ - public function __construct(EventRegistry $eventRegistry, ObjectManager $objectManager) - { - $this->eventRegistry = $eventRegistry; - $this->objectManager = $objectManager; - } - /** * @param EventDefinition $eventDefinition * @param Notification $notification @@ -55,7 +34,7 @@ public function __construct(EventRegistry $eventRegistry, ObjectManager $objectM * @throws ClassNotFoundException * @throws InvalidClassException */ - public function create(EventDefinition $eventDefinition, Notification $notification): Event + public static function create(EventDefinition $eventDefinition, Notification $notification): Event { $className = $eventDefinition->getClassName(); @@ -68,7 +47,7 @@ public function create(EventDefinition $eventDefinition, Notification $notificat } /** @var Event $event */ - $event = $this->objectManager->get($className, $eventDefinition, $notification); + $event = GeneralUtility::makeInstance($className, ...[$eventDefinition, $notification]); return $event; } diff --git a/Classes/Core/Event/Service/EventRegistry.php b/Classes/Core/Event/Service/EventRegistry.php index dabaa2c1..5477602f 100644 --- a/Classes/Core/Event/Service/EventRegistry.php +++ b/Classes/Core/Event/Service/EventRegistry.php @@ -86,9 +86,8 @@ protected function registerEventsInternal() $definition = $this->definitionService->getDefinition(); foreach ($definition->getEvents() as $eventDefinition) { - $eventRunner = $this->eventRunnerContainer->add($eventDefinition); - - $eventDefinition->getConnection()->register($eventRunner); + $eventDefinition = $this->eventRunnerContainer->add($eventDefinition); + $eventDefinition->getConnection()->register($eventDefinition); } } } diff --git a/Classes/Core/Notification/Processor/NotificationProcessorFactory.php b/Classes/Core/Notification/Processor/NotificationProcessorFactory.php index eca2f434..260f5c0d 100644 --- a/Classes/Core/Notification/Processor/NotificationProcessorFactory.php +++ b/Classes/Core/Notification/Processor/NotificationProcessorFactory.php @@ -104,11 +104,11 @@ protected function getProcessorClassNameFromNotificationClassName(string $notifi $processorClassName = $notificationClassName::getProcessorClassName(); if (!class_exists($processorClassName)) { - throw ClassNotFoundException::notificationProcessorClassNotFound($notificationClassName, $processorClassName); + throw ClassNotFoundException::notificationProcessorClassNotFound((string)$notificationClassName, $processorClassName); } if (!in_array(NotificationProcessor::class, class_parents($processorClassName))) { - throw InvalidClassException::notificationProcessorWrongParent($notificationClassName, $processorClassName); + throw InvalidClassException::notificationProcessorWrongParent((string)$notificationClassName, $processorClassName); } return $processorClassName; diff --git a/Classes/Core/Notification/Service/NotificationTcaService.php b/Classes/Core/Notification/Service/NotificationTcaService.php index 0ea3a651..fdd63a2f 100644 --- a/Classes/Core/Notification/Service/NotificationTcaService.php +++ b/Classes/Core/Notification/Service/NotificationTcaService.php @@ -21,7 +21,6 @@ use CuyZ\Notiz\Core\Definition\Tree\Definition; use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition; -use CuyZ\Notiz\Core\Event\Service\EventFactory; use CuyZ\Notiz\Core\Exception\NotImplementedException; use CuyZ\Notiz\Core\Notification\Notification; use CuyZ\Notiz\Core\Support\NotizConstants; @@ -38,11 +37,6 @@ */ abstract class NotificationTcaService implements SingletonInterface { - /** - * @var EventFactory - */ - protected $eventFactory; - /** * @var DefinitionService */ @@ -68,7 +62,6 @@ abstract class NotificationTcaService implements SingletonInterface */ public function __construct() { - $this->eventFactory = Container::get(EventFactory::class); $this->definitionService = Container::get(DefinitionService::class); $this->viewService = Container::get(ViewService::class); $this->dataMapper = Container::get(DataMapper::class); @@ -136,16 +129,15 @@ protected function getSelectedEvent(array $row): EventDefinition * Loads all markers for the current selected event and formats them as a * list to be displayed on the edit form. * - * @param array $parameters + * @param array $row * @return string */ - public function getMarkersLabel(array &$parameters): string + public function getMarkersLabel(array $row): string { if ($this->definitionHasErrors()) { return ''; } - $row = $parameters['row']; $eventDefinition = $this->getSelectedEvent($row); $notification = $this->getNotification($row); @@ -207,9 +199,10 @@ protected function getNotification(array $row): Notification $hash = json_encode($row); if (!isset($this->notification[$hash])) { + $map = $this->dataMapper->map($this->getNotificationDefinition()->getClassName(), [$row]); $this->notification[$hash] = isset($row['uid']) && is_integer($row['uid']) ? $this->getNotificationDefinition()->getProcessor()->getNotificationFromIdentifier((string)$row['uid']) - : reset($this->dataMapper->map($this->getNotificationDefinition()->getClassName(), [$row])); + : reset($map); } return $this->notification[$hash]; diff --git a/Classes/Core/Notification/TCA/EntityTcaWriter.php b/Classes/Core/Notification/TCA/EntityTcaWriter.php index 01381f06..8e13afa3 100644 --- a/Classes/Core/Notification/TCA/EntityTcaWriter.php +++ b/Classes/Core/Notification/TCA/EntityTcaWriter.php @@ -169,7 +169,7 @@ private function addDefaultTypo3Columns() $defaultColumns = [ 'sys_language_uid' => [ 'exclude' => 1, - 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', @@ -177,15 +177,15 @@ private function addDefaultTypo3Columns() 'foreign_table_where' => 'ORDER BY sys_language.title', 'default' => 0, 'items' => [ - ['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1], - ['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0], + ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1], + ['LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.default_value', 0], ], ], ], 'l10n_parent' => [ 'displayCond' => 'FIELD:sys_language_uid:>:0', 'exclude' => 1, - 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent', 'l10n_display' => 'defaultAsReadonly', 'config' => [ 'type' => 'select', @@ -203,7 +203,7 @@ private function addDefaultTypo3Columns() ], ], 't3ver_label' => [ - 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel', 'config' => [ 'type' => 'input', 'size' => 30, @@ -212,14 +212,14 @@ private function addDefaultTypo3Columns() ], 'hidden' => [ 'exclude' => 1, - 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', 'config' => [ 'type' => 'check', ], ], 'starttime' => [ 'exclude' => 1, - 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime', 'config' => [ 'type' => 'input', 'renderType' => 'inputDateTime', @@ -232,7 +232,7 @@ private function addDefaultTypo3Columns() ], 'endtime' => [ 'exclude' => 1, - 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime', 'config' => [ 'type' => 'input', 'renderType' => 'inputDateTime', @@ -332,7 +332,10 @@ private function addCommonColumns() 'l10n_display' => 'defaultAsReadonly', 'config' => [ 'type' => 'user', - 'userFunc' => $this->getNotificationTcaServiceClass() . '->getMarkersLabel', + 'renderType' => 'notizMarkerLabel', + 'parameters' => [ + 'serviceClass' => $this->getNotificationTcaServiceClass() + ] ], ], ]; diff --git a/Classes/Core/Notification/TCA/Processor/GracefulProcessor.php b/Classes/Core/Notification/TCA/Processor/GracefulProcessor.php index a0e53cf5..c442a35e 100644 --- a/Classes/Core/Notification/TCA/Processor/GracefulProcessor.php +++ b/Classes/Core/Notification/TCA/Processor/GracefulProcessor.php @@ -107,9 +107,10 @@ private function getDefinitionErrorTca(Throwable $exception): array 'error_message' => [ 'config' => [ 'type' => 'user', - 'userFunc' => static::class . '->getErrorMessage', + 'renderType' => 'notizErrorMessage', 'parameters' => [ 'exception' => $exception, + 'serviceClass' => \get_class($this) ] ], ], @@ -118,17 +119,17 @@ private function getDefinitionErrorTca(Throwable $exception): array } /** - * @param array $arguments + * @param array $exception * @return string */ - public function getErrorMessage($arguments): string + public function getErrorMessage($exception): string { $view = $this->viewService->getStandaloneView('Backend/TCA/ErrorMessage'); $frameSrc = GeneralUtility::getIndpEnv('REQUEST_URI') . '&showException=1'; $view->assign('frameSrc', $frameSrc); - $view->assign('exception', $arguments['parameters']['exception']); + $view->assign('exception', $exception); return $view->render(); } diff --git a/Classes/Core/Property/Factory/PropertyBuildDefinitionEvent.php b/Classes/Core/Property/Factory/PropertyBuildDefinitionEvent.php new file mode 100644 index 00000000..a75d7e2f --- /dev/null +++ b/Classes/Core/Property/Factory/PropertyBuildDefinitionEvent.php @@ -0,0 +1,48 @@ +propertyDefinition = $propertyDefinition; + $this->eventDefinition = $eventDefinition; + $this->notification = $notification; + } + + /** + * @return PropertyDefinition + */ + public function getPropertyDefinition(): PropertyDefinition + { + return $this->propertyDefinition; + } + + /** + * @return EventDefinition + */ + public function getEventDefinition(): EventDefinition + { + return $this->eventDefinition; + } + + /** + * @return Notification + */ + public function getNotification(): Notification + { + return $this->notification; + } + +} diff --git a/Classes/Core/Property/Factory/PropertyFactory.php b/Classes/Core/Property/Factory/PropertyFactory.php index c4afccdd..39072993 100644 --- a/Classes/Core/Property/Factory/PropertyFactory.php +++ b/Classes/Core/Property/Factory/PropertyFactory.php @@ -23,17 +23,17 @@ use CuyZ\Notiz\Core\Notification\Notification; use CuyZ\Notiz\Core\Property\PropertyEntry; use CuyZ\Notiz\Service\Traits\ExtendedSelfInstantiateTrait; +use TYPO3\CMS\Core\EventDispatcher\EventDispatcher; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\Container\Container; use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; /** * Factory for getting both properties definitions and values, that are defined * by events and used by notifications. * - * Global properties manipulation + * Global properties manipulation TODO update docs * ------------------------------ * * If you need to globally do things with properties (for instance markers), you @@ -86,9 +86,6 @@ */ class PropertyFactory implements SingletonInterface { - const SIGNAL_PROPERTY_BUILD_DEFINITION = 'propertyBuildDefinition'; - - const SIGNAL_PROPERTY_FILLING = 'propertyFilling'; use ExtendedSelfInstantiateTrait; @@ -113,20 +110,20 @@ class PropertyFactory implements SingletonInterface protected $objectContainer; /** - * @var Dispatcher + * @var EventDispatcher */ - protected $slotDispatcher; + protected $eventDispatcher; /** * @param ObjectManager $objectManager * @param Container $objectContainer - * @param Dispatcher $slotDispatcher + * @param EventDispatcher $eventDispatcher */ - public function __construct(ObjectManager $objectManager, Container $objectContainer, Dispatcher $slotDispatcher) + public function __construct(ObjectManager $objectManager, Container $objectContainer, EventDispatcher $eventDispatcher) { $this->objectManager = $objectManager; $this->objectContainer = $objectContainer; - $this->slotDispatcher = $slotDispatcher; + $this->eventDispatcher = $eventDispatcher; } /** @@ -254,14 +251,8 @@ protected function dispatchPropertyBuildDefinitionSignal( EventDefinition $eventDefinition, Notification $notification ) { - $this->slotDispatcher->dispatch( - self::class, - self::SIGNAL_PROPERTY_BUILD_DEFINITION, - [ - $propertyDefinition, - $eventDefinition, - $notification, - ] + $this->eventDispatcher->dispatch( + new PropertyBuildDefinitionEvent($propertyDefinition, $eventDefinition,$notification) ); } @@ -275,14 +266,7 @@ protected function dispatchPropertyBuildDefinitionSignal( */ protected function dispatchPropertyFillingSignal(PropertyContainer $propertyContainer, Event $event) { - $this->slotDispatcher->dispatch( - self::class, - self::SIGNAL_PROPERTY_FILLING, - [ - $propertyContainer, - $event, - ] - ); + $this->eventDispatcher->dispatch(new PropertyFillingEvent($propertyContainer, $event)); } /** diff --git a/Classes/Core/Property/Factory/PropertyFillingEvent.php b/Classes/Core/Property/Factory/PropertyFillingEvent.php new file mode 100644 index 00000000..5196b972 --- /dev/null +++ b/Classes/Core/Property/Factory/PropertyFillingEvent.php @@ -0,0 +1,38 @@ +propertyContainer = $propertyContainer; + $this->event = $event; + } + + /** + * @return PropertyContainer + */ + public function getPropertyContainer(): PropertyContainer + { + return $this->propertyContainer; + } + + /** + * @return Event + */ + public function getEvent(): Event + { + return $this->event; + } + + +} diff --git a/Classes/Core/Property/Service/TagsPropertyService.php b/Classes/Core/Property/Service/TagsPropertyService.php index a69f891a..a56e178c 100644 --- a/Classes/Core/Property/Service/TagsPropertyService.php +++ b/Classes/Core/Property/Service/TagsPropertyService.php @@ -24,11 +24,10 @@ use CuyZ\Notiz\Core\Property\Factory\PropertyDefinition; use CuyZ\Notiz\Core\Property\PropertyEntry; use CuyZ\Notiz\Service\Traits\ExtendedSelfInstantiateTrait; +use Romm\ConfigurationObject\Legacy\Reflection\ClassReflection; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Extbase\Reflection\ClassReflection; use TYPO3\CMS\Extbase\Reflection\ReflectionService; /** @@ -139,76 +138,23 @@ public function __construct(ObjectManager $objectManager) */ public function fillPropertyDefinition(PropertyDefinition $definition) { - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - $this->fillPropertyDefinitionLegacy($definition); - return; - } - $identifier = $this->getPropertyTagIdentifier($definition); - /** @var ReflectionService $reflectionService */ - $reflectionService = $this->objectManager->get(ReflectionService::class); + /** @var \Romm\ConfigurationObject\Core\Service\ReflectionService $reflectionService */ + $reflectionService = $this->objectManager->get(\Romm\ConfigurationObject\Core\Service\ReflectionService::class); - $classSchema = $reflectionService->getClassSchema($definition->getEventClassName()); + $classSchema = $reflectionService->getClassReflection($definition->getEventClassName()); - foreach ($classSchema->getProperties() as $name => $property) { - if (!isset($property['tags'][$identifier])) { + foreach ($classSchema->getProperties() as $property) { + $tags = $property->getTagsValues(); + if (!isset($tags[$identifier])) { continue; } - $entry = $definition->addEntry($name); + $entry = $definition->addEntry($property->getName()); - $label = $property['tags']['label'][0] ?? ''; + $label = $tags['label'][0] ?? ''; $entry->setLabel($label); - - /* - * @deprecated Must be removed when TYPO3 v9 is not supported - * anymore. - * - * @see https://review.typo3.org/c/58923/ - */ - $defaultProperty = isset($property['defaultValue']) - ? $property['defaultValue'] - : (new \ReflectionClass($definition->getEventClassName()))->getDefaultProperties()[$name]; - - if ($defaultProperty) { - $entry->setValue($defaultProperty); - } - } - } - - /** - * @param PropertyDefinition $definition - * - * @deprecated Must be removed when TYPO3 v8 is not supported anymore. - */ - private function fillPropertyDefinitionLegacy(PropertyDefinition $definition) - { - $identifier = $this->getPropertyTagIdentifier($definition); - - /** @var ClassReflection $eventReflection */ - $eventReflection = $this->objectManager->get(ClassReflection::class, $definition->getEventClassName()); - - $eventProperties = $eventReflection->getProperties(); - $eventDefaultProperties = $eventReflection->getDefaultProperties(); - - foreach ($eventProperties as $classProperty) { - if (!$classProperty->isTaggedWith($identifier)) { - continue; - } - - $name = $classProperty->getName(); - $entry = $definition->addEntry($name); - - $label = $classProperty->isTaggedWith('label') - ? reset($classProperty->getTagValues('label')) - : ''; - - $entry->setLabel($label); - - if (null !== $eventDefaultProperties[$name]) { - $entry->setValue($eventDefaultProperties[$name]); - } } } diff --git a/Classes/Domain/Channel/Email/TYPO3/EmailChannel.php b/Classes/Domain/Channel/Email/TYPO3/EmailChannel.php index e43709e2..fb7df0f5 100644 --- a/Classes/Domain/Channel/Email/TYPO3/EmailChannel.php +++ b/Classes/Domain/Channel/Email/TYPO3/EmailChannel.php @@ -21,9 +21,9 @@ use CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Service\EntityEmailAddressMapper; use CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Service\EntityEmailTemplateBuilder; use CuyZ\Notiz\Domain\Notification\Email\EmailNotification; +use TYPO3\CMS\Core\EventDispatcher\EventDispatcher; use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; /** * Channel using the default `MailMessage` provided by the TYPO3 core. @@ -83,8 +83,6 @@ */ class EmailChannel extends AbstractChannel { - const EMAIL_SIGNAL = 'sendEmail'; - /** * @var array */ @@ -103,9 +101,17 @@ class EmailChannel extends AbstractChannel protected $addressMapper; /** - * @var Dispatcher + * @var EventDispatcher + */ + protected $dispatcher; + + /** + * @param EventDispatcher $dispatcher */ - protected $slotDispatcher; + public function injectSlotDispatcher(EventDispatcher $dispatcher) + { + $this->dispatcher = $dispatcher; + } /** * Setting up services used by this channel. @@ -126,38 +132,15 @@ protected function process() $mailMessage ->setSubject($this->templateBuilder->getSubject()) - ->setBody($this->templateBuilder->getBody()) + ->html($this->templateBuilder->getBody()) ->setFrom($this->addressMapper->getSender()) ->setTo($this->addressMapper->getSendTo()) ->setCc($this->addressMapper->getSendCc()) ->setBcc($this->addressMapper->getSendBcc()) - ->setContentType('text/html'); + ; - $this->dispatchEmailSignal($mailMessage); + $this->dispatcher->dispatch(new SendMailEvent($mailMessage, $this->payload)); $mailMessage->send(); } - - /** - * @param MailMessage $mailMessage - */ - protected function dispatchEmailSignal(MailMessage $mailMessage) - { - $this->slotDispatcher->dispatch( - self::class, - self::EMAIL_SIGNAL, - [ - $mailMessage, - $this->payload, - ] - ); - } - - /** - * @param Dispatcher $slotDispatcher - */ - public function injectSlotDispatcher(Dispatcher $slotDispatcher) - { - $this->slotDispatcher = $slotDispatcher; - } } diff --git a/Classes/Domain/Channel/Email/TYPO3/SendMailEvent.php b/Classes/Domain/Channel/Email/TYPO3/SendMailEvent.php new file mode 100644 index 00000000..52588ae7 --- /dev/null +++ b/Classes/Domain/Channel/Email/TYPO3/SendMailEvent.php @@ -0,0 +1,38 @@ +message = $message; + $this->payload = $payload; + } + + /** + * @return MailMessage + */ + public function getMessage(): MailMessage + { + return $this->message; + } + + /** + * @return Payload + */ + public function getPayload(): Payload + { + return $this->payload; + } + +} diff --git a/Classes/Domain/Definition/Builder/Component/DefaultDefinitionComponents.php b/Classes/Domain/Definition/Builder/Component/DefaultDefinitionComponents.php index cad67da6..9d86b273 100644 --- a/Classes/Domain/Definition/Builder/Component/DefaultDefinitionComponents.php +++ b/Classes/Domain/Definition/Builder/Component/DefaultDefinitionComponents.php @@ -19,6 +19,7 @@ use CuyZ\Notiz\Core\Definition\Builder\Component\DefinitionComponents; use CuyZ\Notiz\Core\Definition\Builder\Component\Source\DefinitionSource; +use CuyZ\Notiz\Core\Definition\Builder\Event\DefinitionBuilderManageComponentEvent; use CuyZ\Notiz\Core\Support\NotizConstants; use CuyZ\Notiz\Domain\Definition\Builder\Component\Source\TypoScriptDefinitionSource; use CuyZ\Notiz\Service\ExtensionConfigurationService; @@ -55,10 +56,12 @@ public function __construct(ExtensionConfigurationService $extensionConfiguratio * Default definition comes from TypoScript files, so a definition source * must be added to the definition builder and the files must be registered. * - * @param DefinitionComponents $components + * @param DefinitionBuilderManageComponentEvent $event */ - public function register(DefinitionComponents $components) + public function register(DefinitionBuilderManageComponentEvent $event) { + $components = $event->getComponents(); + if ($this->registrationDone) { return; } diff --git a/Classes/Domain/Event/TYPO3/ExtensionInstalledEvent.php b/Classes/Domain/Event/TYPO3/ExtensionInstalledEvent.php index 14bc43c8..0f2d3619 100644 --- a/Classes/Domain/Event/TYPO3/ExtensionInstalledEvent.php +++ b/Classes/Domain/Event/TYPO3/ExtensionInstalledEvent.php @@ -86,7 +86,7 @@ protected function getExtensionData(string $extensionKey): array $extensionPackage = $this->listUtility->getExtension($extensionKey); $data = [ - 'siteRelPath' => PathUtility::getRelativePath(PATH_site, $extensionPackage->getPackagePath()), + 'siteRelPath' => PathUtility::getRelativePath(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/', $extensionPackage->getPackagePath()), 'key' => $extensionKey, ]; diff --git a/Classes/Domain/Notification/Email/Application/EntityEmail/EntityEmailNotification.php b/Classes/Domain/Notification/Email/Application/EntityEmail/EntityEmailNotification.php index a681ed57..57568154 100644 --- a/Classes/Domain/Notification/Email/Application/EntityEmail/EntityEmailNotification.php +++ b/Classes/Domain/Notification/Email/Application/EntityEmail/EntityEmailNotification.php @@ -28,8 +28,8 @@ use CuyZ\Notiz\Domain\Notification\Email\EmailNotification; use CuyZ\Notiz\Domain\Notification\EntityNotification; use CuyZ\Notiz\Domain\Property\Email; +use TYPO3\CMS\Core\Service\FlexFormService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Service\FlexFormService; class EntityEmailNotification extends EntityNotification implements EmailNotification, @@ -297,9 +297,7 @@ public function getBody(): string public function getBodySlots(): array { if (empty($this->bodySlots)) { - /** @var FlexFormService $flexFormService */ $flexFormService = GeneralUtility::makeInstance(FlexFormService::class); - $this->bodySlots = $flexFormService->convertFlexFormContentToArray($this->body); } diff --git a/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/EntityEmailSettings.php b/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/EntityEmailSettings.php index 5c34a653..b3b12e97 100644 --- a/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/EntityEmailSettings.php +++ b/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/EntityEmailSettings.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; use CuyZ\Notiz\Core\Notification\Settings\NotificationSettings; use CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\View\View; @@ -28,7 +29,7 @@ class EntityEmailSettings extends AbstractDefinitionComponent implements Notific /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $defaultSender; diff --git a/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/GlobalRecipients/Recipient.php b/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/GlobalRecipients/Recipient.php index a269b36a..27b301fc 100644 --- a/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/GlobalRecipients/Recipient.php +++ b/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/GlobalRecipients/Recipient.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\GlobalRecipients; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; use CuyZ\Notiz\Service\StringService; use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor; @@ -32,8 +33,8 @@ class Recipient extends AbstractDefinitionComponent implements DataPreProcessorI /** * @var string * - * @validate NotEmpty - * @validate EmailAddress + * @Extbase\Validate("NotEmpty") + * @Extbase\Validate("EmailAddress") */ protected $email; diff --git a/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/View/Layout.php b/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/View/Layout.php index 0f192085..63309bc6 100644 --- a/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/View/Layout.php +++ b/Classes/Domain/Notification/Email/Application/EntityEmail/Settings/View/Layout.php @@ -17,6 +17,7 @@ namespace CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\View; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; use CuyZ\Notiz\Service\LocalizationService; @@ -25,7 +26,7 @@ class Layout extends AbstractDefinitionComponent /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $identifier; @@ -37,7 +38,7 @@ class Layout extends AbstractDefinitionComponent /** * @var string * - * @validate NotEmpty + * @Extbase\Validate("NotEmpty") */ protected $path; diff --git a/Classes/Domain/Notification/Email/Application/EntityEmail/TCA/EntityEmailTcaWriter.php b/Classes/Domain/Notification/Email/Application/EntityEmail/TCA/EntityEmailTcaWriter.php index 12e6cb98..e0c0e8a0 100644 --- a/Classes/Domain/Notification/Email/Application/EntityEmail/TCA/EntityEmailTcaWriter.php +++ b/Classes/Domain/Notification/Email/Application/EntityEmail/TCA/EntityEmailTcaWriter.php @@ -160,7 +160,10 @@ protected function buildTcaArray(): array 'displayCond' => 'FIELD:sender_custom:=:0', 'config' => [ 'type' => 'user', - 'userFunc' => $this->getNotificationTcaServiceClass() . '->getDefaultSender', + 'renderType' => 'notizDefaultSender', + 'parameters' => [ + 'serviceClass' => $this->getNotificationTcaServiceClass() + ] ], ], diff --git a/Classes/Domain/Notification/EntityNotification.php b/Classes/Domain/Notification/EntityNotification.php index 6e81decb..b04bbd73 100644 --- a/Classes/Domain/Notification/EntityNotification.php +++ b/Classes/Domain/Notification/EntityNotification.php @@ -17,6 +17,8 @@ namespace CuyZ\Notiz\Domain\Notification; +use TYPO3\CMS\Core\Service\FlexFormService; +use TYPO3\CMS\Extbase\Annotation as Extbase; use CuyZ\Notiz\Backend\Module\ManagerModuleHandler; use CuyZ\Notiz\Core\Definition\DefinitionService; use CuyZ\Notiz\Core\Definition\Tree\Definition; @@ -28,12 +30,10 @@ use CuyZ\Notiz\Service\Container; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Type\Bitmask\Permission; -use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Domain\Model\BackendUser; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; -use TYPO3\CMS\Extbase\Service\FlexFormService; +use TYPO3\CMS\Extbase\Persistence\ClassesConfigurationFactory; abstract class EntityNotification extends AbstractEntity implements Notification, MultipleChannelsNotification { @@ -69,7 +69,7 @@ abstract class EntityNotification extends AbstractEntity implements Notification /** * @var \TYPO3\CMS\Extbase\Domain\Model\BackendUser - * @lazy + * @Extbase\ORM\Lazy */ protected $backendUser; @@ -225,9 +225,7 @@ public function getEventDefinition(): EventDefinition public function getEventConfiguration(): array { if (null === $this->eventConfiguration) { - /** @var FlexFormService $flexFormService */ $flexFormService = GeneralUtility::makeInstance(FlexFormService::class); - $this->eventConfiguration = $flexFormService->convertFlexFormContentToArray($this->eventConfigurationFlex); } @@ -382,15 +380,17 @@ public function shouldDispatch(ChannelDefinition $definition): bool */ public static function getTableName(): string { - /** @var ConfigurationManagerInterface $configurationManager */ - $configurationManager = Container::get(ConfigurationManagerInterface::class); - $configuration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); + /** @var ClassesConfigurationFactory $configurationManager */ + $classesConfigurationFactory = Container::get(ClassesConfigurationFactory::class); + $className = self::getDefinition() ->getNotification(static::getDefinitionIdentifier()) ->getClassName(); - return ArrayUtility::getValueByPath($configuration, "persistence/classes/$className/mapping/tableName"); + $config = $classesConfigurationFactory->createClassesConfiguration()->getConfigurationFor($className); + + return $config['tableName']; } /** diff --git a/Classes/Domain/Notification/Log/Application/EntityLog/TCA/EntityLogTcaWriter.php b/Classes/Domain/Notification/Log/Application/EntityLog/TCA/EntityLogTcaWriter.php index 6974d150..67d9f4c4 100644 --- a/Classes/Domain/Notification/Log/Application/EntityLog/TCA/EntityLogTcaWriter.php +++ b/Classes/Domain/Notification/Log/Application/EntityLog/TCA/EntityLogTcaWriter.php @@ -104,7 +104,7 @@ protected function buildTcaArray(): array 'l10n_display' => 'defaultAsReadonly', 'config' => [ 'type' => 'user', - 'userFunc' => EntityLogTcaService::class . '->getLogLevelsDescriptions', + 'renderType' => 'notizLogLevelsDescriptions', ], ], diff --git a/Classes/Domain/Notification/Slack/Application/EntitySlack/TCA/EntitySlackTcaWriter.php b/Classes/Domain/Notification/Slack/Application/EntitySlack/TCA/EntitySlackTcaWriter.php index d5af743c..e38d668c 100644 --- a/Classes/Domain/Notification/Slack/Application/EntitySlack/TCA/EntitySlackTcaWriter.php +++ b/Classes/Domain/Notification/Slack/Application/EntitySlack/TCA/EntitySlackTcaWriter.php @@ -122,7 +122,10 @@ protected function buildTcaArray(): array ], 'config' => [ 'type' => 'user', - 'userFunc' => $this->getNotificationTcaServiceClass() . '->getNoDefinedBotText', + 'renderType' => 'notizNoDefinedBotText', + 'parameters' => [ + 'serviceClass' => $this->getNotificationTcaServiceClass() + ] ], ], @@ -163,7 +166,10 @@ protected function buildTcaArray(): array 'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->hasNoDefinedSlackChannel', 'config' => [ 'type' => 'user', - 'userFunc' => $this->getNotificationTcaServiceClass() . '->getNoDefinedSlackChannelText', + 'renderType' => 'notizNoDefinedSlackChannelText', + 'parameters' => [ + 'serviceClass' => $this->getNotificationTcaServiceClass() + ] ], ], diff --git a/Classes/Form/Element/DefaultSenderElement.php b/Classes/Form/Element/DefaultSenderElement.php new file mode 100644 index 00000000..bb2f295f --- /dev/null +++ b/Classes/Form/Element/DefaultSenderElement.php @@ -0,0 +1,23 @@ +initializeResultArray(); + $serviceClass = $this->data['parameterArray']['fieldConf']['config']['parameters']['serviceClass']; + + $service = GeneralUtility::makeInstance($serviceClass); + if (\method_exists($service, 'getDefaultSender')) { + $result['html'] = $service->getDefaultSender(); + } + return $result; + } +} diff --git a/Classes/Form/Element/DefinitionErrorMessageElement.php b/Classes/Form/Element/DefinitionErrorMessageElement.php new file mode 100644 index 00000000..17d2c5c1 --- /dev/null +++ b/Classes/Form/Element/DefinitionErrorMessageElement.php @@ -0,0 +1,21 @@ +initializeResultArray(); + $definitionError = GeneralUtility::makeInstance(DefinitionError::class); + $result['html'] = $definitionError->getDefinitionErrorMessage(); + return $result; + } +} diff --git a/Classes/Form/Element/ErrorMessageElement.php b/Classes/Form/Element/ErrorMessageElement.php new file mode 100644 index 00000000..064f4122 --- /dev/null +++ b/Classes/Form/Element/ErrorMessageElement.php @@ -0,0 +1,25 @@ +initializeResultArray(); + $serviceClass = $this->data['parameterArray']['fieldConf']['config']['parameters']['serviceClass']; + $exception = $this->data['parameterArray']['fieldConf']['config']['parameters']['exception']; + + /** @var GracefulProcessor $service */ + $service = GeneralUtility::makeInstance($serviceClass); + $result['html'] = $service->getErrorMessage($exception); + return $result; + } +} diff --git a/Classes/Form/Element/LogLevelsDescriptionsElement.php b/Classes/Form/Element/LogLevelsDescriptionsElement.php new file mode 100644 index 00000000..39b24ef7 --- /dev/null +++ b/Classes/Form/Element/LogLevelsDescriptionsElement.php @@ -0,0 +1,21 @@ +initializeResultArray(); + $service = GeneralUtility::makeInstance(EntityLogTcaService::class); + $result['html'] = $service->getLogLevelsDescriptions(); + return $result; + } +} diff --git a/Classes/Form/Element/MarkerLabelElement.php b/Classes/Form/Element/MarkerLabelElement.php new file mode 100644 index 00000000..10ba0389 --- /dev/null +++ b/Classes/Form/Element/MarkerLabelElement.php @@ -0,0 +1,25 @@ +initializeResultArray(); + $serviceClass = $this->data['parameterArray']['fieldConf']['config']['parameters']['serviceClass']; + + /** @var NotificationTcaService $service */ + $service = GeneralUtility::makeInstance($serviceClass); + + $result['html'] = $service->getMarkersLabel($this->data['databaseRow']); + return $result; + } +} diff --git a/Classes/Form/Element/NoDefinedBotTextElement.php b/Classes/Form/Element/NoDefinedBotTextElement.php new file mode 100644 index 00000000..a0da7b81 --- /dev/null +++ b/Classes/Form/Element/NoDefinedBotTextElement.php @@ -0,0 +1,25 @@ +initializeResultArray(); + $serviceClass = $this->data['parameterArray']['fieldConf']['config']['parameters']['serviceClass']; + + /** @var EntitySlackTcaService $service */ + $service = GeneralUtility::makeInstance($serviceClass); + $result['html'] = $service->getNoDefinedBotText(); + return $result; + } +} diff --git a/Classes/Form/Element/NoDefinedSlackChannelTextElement.php b/Classes/Form/Element/NoDefinedSlackChannelTextElement.php new file mode 100644 index 00000000..674146db --- /dev/null +++ b/Classes/Form/Element/NoDefinedSlackChannelTextElement.php @@ -0,0 +1,24 @@ +initializeResultArray(); + $serviceClass = $this->data['parameterArray']['fieldConf']['config']['parameters']['serviceClass']; + + /** @var EntitySlackTcaService $service */ + $service = GeneralUtility::makeInstance($serviceClass); + $result['html'] = $service->getNoDefinedSlackChannelText(); + return $result; + } +} diff --git a/Classes/Middleware/EventDefinitionRegistererMiddleware.php b/Classes/Middleware/EventDefinitionRegistererMiddleware.php index 3b413fc2..7c659304 100644 --- a/Classes/Middleware/EventDefinitionRegistererMiddleware.php +++ b/Classes/Middleware/EventDefinitionRegistererMiddleware.php @@ -17,12 +17,13 @@ namespace CuyZ\Notiz\Middleware; -use CuyZ\Notiz\Service\Hook\EventDefinitionRegisterer; +use CuyZ\Notiz\Core\Event\Service\EventRegistry; +use CuyZ\Notiz\Service\RuntimeService; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use Throwable; class EventDefinitionRegistererMiddleware implements MiddlewareInterface { @@ -33,7 +34,11 @@ class EventDefinitionRegistererMiddleware implements MiddlewareInterface */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { - GeneralUtility::makeInstance(EventDefinitionRegisterer::class)->processData(); + try { + EventRegistry::get()->registerEvents(); + } catch (Throwable $exception) { + RuntimeService::get()->setException($exception); + } return $handler->handle($request); } diff --git a/Classes/Service/Container.php b/Classes/Service/Container.php index e3c018e7..c7b2ab48 100644 --- a/Classes/Service/Container.php +++ b/Classes/Service/Container.php @@ -19,9 +19,9 @@ use CuyZ\Notiz\Service\Traits\ExtendedSelfInstantiateTrait; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Frontend\Page\PageRepository; class Container implements SingletonInterface { diff --git a/Classes/Service/Extension/LocalConfigurationService.php b/Classes/Service/Extension/LocalConfigurationService.php index 778d9ea8..fa235faf 100644 --- a/Classes/Service/Extension/LocalConfigurationService.php +++ b/Classes/Service/Extension/LocalConfigurationService.php @@ -21,17 +21,13 @@ use CuyZ\Notiz\Backend\FormEngine\DataProvider\DefinitionError; use CuyZ\Notiz\Backend\FormEngine\DataProvider\HideColumns; use CuyZ\Notiz\Backend\ToolBarItems\NotificationsToolbarItem; -use CuyZ\Notiz\Core\Definition\Builder\DefinitionBuilder; use CuyZ\Notiz\Core\Notification\TCA\Processor\GracefulProcessorRunner; use CuyZ\Notiz\Core\Support\NotizConstants; -use CuyZ\Notiz\Domain\Definition\Builder\Component\DefaultDefinitionComponents; use CuyZ\Notiz\Domain\Event\Blog\Processor\BlogNotificationProcessor; use CuyZ\Notiz\Service\Container; use CuyZ\Notiz\Service\ExtensionConfigurationService; -use CuyZ\Notiz\Service\Hook\EventDefinitionRegisterer; use CuyZ\Notiz\Service\Traits\SelfInstantiateTrait; use Doctrine\Common\Annotations\AnnotationReader; -use T3G\AgencyPack\Blog\Notification\CommentAddedNotification; use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEditRow; use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordOverrideValues; use TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca; @@ -44,10 +40,7 @@ use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; use TYPO3\CMS\Scheduler\Scheduler; - use function version_compare; /** @@ -65,11 +58,6 @@ class LocalConfigurationService implements SingletonInterface, TableConfiguratio */ protected $iconRegistry; - /** - * @var Dispatcher - */ - protected $dispatcher; - /** * @var ExtensionConfigurationService */ @@ -80,7 +68,6 @@ class LocalConfigurationService implements SingletonInterface, TableConfiguratio */ public function __construct() { - $this->dispatcher = GeneralUtility::makeInstance(Dispatcher::class); $this->iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); } @@ -90,16 +77,15 @@ public function __construct() public function process() { $this->registerLaterProcessHook(); - $this->registerDefinitionComponents(); - $this->registerEventDefinitionHook(); $this->registerInternalCache(); $this->registerIcons(); $this->registerNotificationProcessorRunner(); $this->registerFormEngineComponents(); - $this->resetTypeConvertersArray(); $this->overrideScheduler(); $this->ignoreDoctrineAnnotation(); $this->registerBlogNotificationProcessors(); + $this->registerCache(); + $this->registerNodeElements(); } /** @@ -127,31 +113,6 @@ protected function registerLaterProcessHook() $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = static::class; } - /** - * Connects a slot on the definition components customization signal. - */ - protected function registerDefinitionComponents() - { - $this->dispatcher->connect( - DefinitionBuilder::class, - DefinitionBuilder::COMPONENTS_SIGNAL, - DefaultDefinitionComponents::class, - 'register' - ); - } - - /** - * Hooking in TYPO3 early process to register all hooks/signals added to the - * event definition. - */ - protected function registerEventDefinitionHook() - { - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.5.0', '<')) { - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = EventDefinitionRegisterer::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'][] = EventDefinitionRegisterer::class . '->processData'; - } - } - /** * Internal cache used by the extension. */ @@ -206,21 +167,6 @@ protected function registerToolBarItem() } } - /** - * Because of some core issue concerning the type converters registration, - * we need to make sure the array containing the entries is valid. - * - * See the ticket below for more information: - * - * @link https://forge.typo3.org/issues/82651 - * - * @deprecated Must be removed when TYPO3 v8 is not supported anymore. - */ - protected function resetTypeConvertersArray() - { - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = array_unique($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters']); - } - /** * Registering a xClass that overrides core scheduler, to have access to * signals for when tasks are executed. @@ -295,7 +241,57 @@ protected function registerBlogNotificationProcessors() if (ExtensionManagementUtility::isLoaded('blog') && version_compare(ExtensionManagementUtility::getExtensionVersion('blog'), '9.0.0', '>') ) { - $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['Blog']['notificationRegistry'][CommentAddedNotification::class][] = BlogNotificationProcessor::class; + $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['Blog']['notificationRegistry'][\T3G\AgencyPack\Blog\Notification\CommentAddedNotification::class][] = BlogNotificationProcessor::class; + } + } + + protected function registerCache() + { + if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['notiz_definition_object'])) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['notiz_definition_object'] = [ + 'backend' => \TYPO3\CMS\Core\Cache\Backend\FileBackend::class, + 'frontend' => \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class, + 'groups' => ['all', 'system'] + ]; } } + + protected function registerNodeElements() + { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624441436645] = [ + 'nodeName' => 'notizMarkerLabel', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\MarkerLabelElement::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624442140118] = [ + 'nodeName' => 'notizDefaultSender', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\DefaultSenderElement::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624443407523] = [ + 'nodeName' => 'notizDefinitionErrorMessage', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\DefinitionErrorMessageElement::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624443410038] = [ + 'nodeName' => 'notizErrorMessage', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\ErrorMessageElement::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624443412752] = [ + 'nodeName' => 'notizLogLevelsDescriptions', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\LogLevelsDescriptionsElement::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624443415134] = [ + 'nodeName' => 'notizNoDefinedBotText', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\NoDefinedBotTextElement::class, + ]; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1624443458382] = [ + 'nodeName' => 'notizNoDefinedSlackChannelText', + 'priority' => 40, + 'class' => \CuyZ\Notiz\Form\Element\NoDefinedSlackChannelTextElement::class, + ]; + } } diff --git a/Classes/Service/Extension/TablesConfigurationService.php b/Classes/Service/Extension/TablesConfigurationService.php index 23b5e261..96380c04 100644 --- a/Classes/Service/Extension/TablesConfigurationService.php +++ b/Classes/Service/Extension/TablesConfigurationService.php @@ -17,15 +17,11 @@ namespace CuyZ\Notiz\Service\Extension; -use CuyZ\Notiz\Backend\Report\NotificationStatus; -use CuyZ\Notiz\Backend\FormEngine\ButtonBar\ShowNotificationDetailsButton; use CuyZ\Notiz\Backend\Module\ManagerModuleHandler; +use CuyZ\Notiz\Backend\Report\NotificationStatus; use CuyZ\Notiz\Core\Support\NotizConstants; use CuyZ\Notiz\Service\Traits\SelfInstantiateTrait; -use TYPO3\CMS\Backend\Controller\EditDocumentController; use TYPO3\CMS\Core\SingletonInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; use TYPO3\CMS\Extbase\Utility\ExtensionUtility; /** @@ -41,108 +37,76 @@ class TablesConfigurationService implements SingletonInterface /** * @var string */ - protected $extensionKey; - - /** - * @var Dispatcher - */ - protected $dispatcher; - - /** - * Manual dependency injection. - */ - public function __construct() - { - $this->extensionKey = NotizConstants::EXTENSION_KEY; - $this->dispatcher = GeneralUtility::makeInstance(Dispatcher::class); - } + protected $extensionKey = NotizConstants::EXTENSION_KEY; /** * Main processing methods that will call every method of this class. */ - public function process() + public static function process() { - $this->registerBackendModule(); - $this->registerDetailViewButton(); - $this->registerEntityNotificationControllers(); - $this->registerReportStatus(); + self::registerBackendModule(); + self::registerEntityNotificationControllers(); + self::registerReportStatus(); } /** * Registers the main backend module used to display notifications, * definition and more. */ - protected function registerBackendModule() + protected static function registerBackendModule() { - ExtensionUtility::registerModule( - 'CuyZ.Notiz', + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( 'notiz', '', '', - [], + null, [ - 'access' => '', - 'icon' => '', 'iconIdentifier' => 'tx-notiz-icon-main-module', - 'labels' => "LLL:EXT:{$this->extensionKey}/Resources/Private/Language/Backend/Module/Main/Main.xlf", - 'sub' => [] + 'labels' => "LLL:EXT:" . NotizConstants::EXTENSION_KEY . "/Resources/Private/Language/Backend/Module/Main/Main.xlf", ] ); ExtensionUtility::registerModule( - 'CuyZ.Notiz', + 'Notiz', 'notiz', 'notiz_manager', '', [ - 'Backend\Manager\ListNotificationTypes' => 'process', - 'Backend\Manager\ListNotifications' => 'process', - 'Backend\Manager\NotificationActivation' => 'process', - 'Backend\Manager\ListEvents' => 'process', - 'Backend\Manager\ShowEvent' => 'process', + \CuyZ\Notiz\Controller\Backend\Manager\ListNotificationTypesController::class => 'process', + \CuyZ\Notiz\Controller\Backend\Manager\ListNotificationsController::class => 'process', + \CuyZ\Notiz\Controller\Backend\Manager\NotificationActivationController::class => 'process', + \CuyZ\Notiz\Controller\Backend\Manager\ListEventsController::class => 'process', + \CuyZ\Notiz\Controller\Backend\Manager\ShowEventController::class => 'process', ], [ 'access' => 'user,group', 'icon' => NotizConstants::EXTENSION_ICON_PATH_MODULE_MANAGER, - 'labels' => "LLL:EXT:{$this->extensionKey}/Resources/Private/Language/Backend/Module/Manager/Manager.xlf", + 'labels' => "LLL:EXT:" . NotizConstants::EXTENSION_KEY . "/Resources/Private/Language/Backend/Module/Manager/Manager.xlf", ] ); ExtensionUtility::registerModule( - 'CuyZ.Notiz', + 'Notiz', 'notiz', 'notiz_administration', '', [ - 'Backend\Administration\Index' => 'process', - 'Backend\Administration\ShowDefinition' => 'process', - 'Backend\Administration\ShowException' => 'process', + \CuyZ\Notiz\Controller\Backend\Administration\IndexController::class => 'process', + \CuyZ\Notiz\Controller\Backend\Administration\ShowDefinitionController::class => 'process', + \CuyZ\Notiz\Controller\Backend\Administration\ShowExceptionController::class => 'process', ], [ 'access' => 'admin', 'icon' => NotizConstants::EXTENSION_ICON_PATH_MODULE_ADMINISTRATION, - 'labels' => "LLL:EXT:{$this->extensionKey}/Resources/Private/Language/Backend/Module/Administration/Administration.xlf", + 'labels' => "LLL:EXT:" . NotizConstants::EXTENSION_KEY . "/Resources/Private/Language/Backend/Module/Administration/Administration.xlf", ] ); } - /** - * @see ShowNotificationDetailsButton - */ - protected function registerDetailViewButton() - { - $this->dispatcher->connect( - EditDocumentController::class, - 'initAfter', - ShowNotificationDetailsButton::class, - 'addButton' - ); - } - /** * Dynamically registers the controllers for existing entity notifications. */ - protected function registerEntityNotificationControllers() + protected static function registerEntityNotificationControllers() { ManagerModuleHandler::get()->registerEntityNotificationControllers(); } @@ -150,7 +114,7 @@ protected function registerEntityNotificationControllers() /** * @see \CuyZ\Notiz\Backend\Report\NotificationStatus */ - protected function registerReportStatus() + protected static function registerReportStatus() { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['NotiZ'][] = NotificationStatus::class; } diff --git a/Classes/Service/ExtensionConfigurationService.php b/Classes/Service/ExtensionConfigurationService.php index 0136e694..63aeec1c 100644 --- a/Classes/Service/ExtensionConfigurationService.php +++ b/Classes/Service/ExtensionConfigurationService.php @@ -23,9 +23,6 @@ use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility; /** * Service to ease the reading of the extension configuration written in the @@ -34,31 +31,14 @@ class ExtensionConfigurationService implements SingletonInterface { /** - * @param string $key - * @return mixed - * - * @throws EntryNotFoundException + * @var array */ - public function getConfigurationValue(string $key) - { - if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { - return $this->getConfigurationValueLegacy($key); - } - - /* - * @deprecated When TYPO3 v8 is not supported anymore, inject this - * service in constructor and fill a class property `$configuration` - * for memoization. - */ - $extensionConfiguration = $this->objectManager()->get(ExtensionConfiguration::class); + protected $configuration; - $configuration = $extensionConfiguration->get(NotizConstants::EXTENSION_KEY); - - if (!ArrayUtility::isValidPath($configuration, $key, '.')) { - throw EntryNotFoundException::extensionConfigurationEntryNotFound($key); - } - - return ArrayUtility::getValueByPath($configuration, $key, '.'); + public function __construct() + { + $this->configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class) + ->get(NotizConstants::EXTENSION_KEY); } /** @@ -67,24 +47,13 @@ public function getConfigurationValue(string $key) * * @throws EntryNotFoundException */ - private function getConfigurationValueLegacy(string $key) + public function getConfigurationValue(string $key) { - $configurationUtility = $this->objectManager()->get(ConfigurationUtility::class); - $configuration = $configurationUtility->getCurrentConfiguration(NotizConstants::EXTENSION_KEY); - - if (!isset($configuration[$key]['value'])) { + if (!ArrayUtility::isValidPath($this->configuration, $key, '.')) { throw EntryNotFoundException::extensionConfigurationEntryNotFound($key); } - return $configuration[$key]['value']; + return ArrayUtility::getValueByPath($this->configuration, $key, '.'); } - /** - * @return ObjectManager - */ - private function objectManager(): ObjectManager - { - /** @noinspection PhpIncompatibleReturnTypeInspection */ - return GeneralUtility::makeInstance(ObjectManager::class); - } } diff --git a/Classes/Service/Hook/EventDefinitionRegisterer.php b/Classes/Service/Hook/EventDefinitionRegisterer.php deleted file mode 100644 index 9e3beb04..00000000 --- a/Classes/Service/Hook/EventDefinitionRegisterer.php +++ /dev/null @@ -1,90 +0,0 @@ - - * Romain Canon - * - * This file is part of the TYPO3 NotiZ project. - * It is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, either - * version 3 of the License, or any later version. - * - * For the full copyright and license information, see: - * http://www.gnu.org/licenses/gpl-3.0.html - */ - -namespace CuyZ\Notiz\Service\Hook; - -use CuyZ\Notiz\Core\Event\Service\EventRegistry; -use CuyZ\Notiz\Core\Support\NotizConstants; -use CuyZ\Notiz\Service\CacheService; -use CuyZ\Notiz\Service\RuntimeService; -use Throwable; -use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface; -use TYPO3\CMS\Core\SingletonInterface; - -/** - * This class is hooked on the TYPO3 core signal: - * - * `$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing']` - * - * We get there to register events (signals, hooks) that were added to the - * definition. - * - * @deprecated Must be moved when TYPO3 v8 is not supported anymore. - * @see \CuyZ\Notiz\Middleware\EventDefinitionRegistererMiddleware - */ -class EventDefinitionRegisterer implements SingletonInterface, TableConfigurationPostProcessingHookInterface -{ - /** - * @var bool - */ - private static $initialized = false; - - /** - * Just calling the event registry. - * - * Gotta get SCHWIFTY! - * - * @internal - */ - public function processData() - { - if (self::$initialized) { - return; - } - - self::$initialized = true; - - if ($this->clearingInstallToolCache()) { - return; - } - - try { - EventRegistry::get()->registerEvents(); - } catch (Throwable $exception) { - RuntimeService::get()->setException($exception); - } - } - - /** - * When clearing caches from install tool we need to cancel the registration - * because of the cache manager not being accessible. - * - * One of the only way to know that, is to check if the extension cache is - * not registered in the cache manager, while the configuration is still - * present in the global array. - * - * This behaviour is due to the special way the install tool clears the - * caches, and registers extensions caches at the very end of the process. - * - * @return bool - */ - protected function clearingInstallToolCache(): bool - { - return false === CacheService::getInstance()->cacheIsRegistered() - && isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][NotizConstants::CACHE_ID]); - } -} diff --git a/Classes/Service/LocalizationService.php b/Classes/Service/LocalizationService.php index 63a1bb0c..910d96f0 100644 --- a/Classes/Service/LocalizationService.php +++ b/Classes/Service/LocalizationService.php @@ -19,7 +19,9 @@ use CuyZ\Notiz\Core\Support\NotizConstants; use CuyZ\Notiz\Service\Traits\SelfInstantiateTrait; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\SingletonInterface; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** @@ -153,7 +155,8 @@ function ($extensionKey) use ($file, $key) { * * For example, the path `Foo/Bar` will generate the path `Foo/Bar/Bar.xlf` */ - $file = $file . '/' . end(explode('/', $file)); + $array = explode('/', $file); + $file = $file . '/' . end($array); return 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/' . $file . '.xlf:' . $key; }, @@ -170,6 +173,10 @@ function ($extensionKey) use ($file, $key) { */ protected function localizeInternal(string $key, array $arguments) { + if ($GLOBALS['LANG'] === null) { + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); + } + return LocalizationUtility::translate( $key, NotizConstants::EXTENSION_KEY, diff --git a/Classes/Service/Scheduler/Scheduler.php b/Classes/Service/Scheduler/Scheduler.php index 199dfbab..127d58f2 100644 --- a/Classes/Service/Scheduler/Scheduler.php +++ b/Classes/Service/Scheduler/Scheduler.php @@ -17,9 +17,9 @@ namespace CuyZ\Notiz\Service\Scheduler; -use CuyZ\Notiz\Service\Container; use Throwable; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; +use TYPO3\CMS\Core\EventDispatcher\EventDispatcher; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Scheduler\Task\AbstractTask; /** @@ -31,7 +31,7 @@ * Signal: task was executed * ------------------------- * - * @see \CuyZ\Notiz\Service\Scheduler\Scheduler::SIGNAL_TASK_EXECUTED + * @see \CuyZ\Notiz\Service\Scheduler\SchedulerTaskExecutedEvent * * When a task was successfully executed. * @@ -46,7 +46,7 @@ * Signal: task execution failed * ----------------------------- * - * @see \CuyZ\Notiz\Service\Scheduler\Scheduler::SIGNAL_TASK_FAILED + * @see \CuyZ\Notiz\Service\Scheduler\SchedulerTaskExecutionFailedEvent * * When something has gone wrong during the execution of the task (an exception * has been thrown). @@ -61,12 +61,8 @@ */ class Scheduler extends \TYPO3\CMS\Scheduler\Scheduler { - const SIGNAL_TASK_EXECUTED = 'taskWasExecuted'; - - const SIGNAL_TASK_FAILED = 'taskExecutionFailed'; - /** - * @var Dispatcher + * @var EventDispatcher */ protected $dispatcher; @@ -74,7 +70,7 @@ public function __construct() { parent::__construct(); - $this->dispatcher = Container::get(Dispatcher::class); + $this->dispatcher = GeneralUtility::makeInstance(EventDispatcher::class); } /** @@ -87,25 +83,12 @@ public function __construct() */ public function executeTask(AbstractTask $task): bool { - $exception = null; - try { $result = parent::executeTask($task); - - $this->dispatcher->dispatch( - __CLASS__, - self::SIGNAL_TASK_EXECUTED, - [$task, $result] - ); - + $this->dispatcher->dispatch(new SchedulerTaskExecutedEvent($task, $result)); return $result; } catch (Throwable $exception) { - $this->dispatcher->dispatch( - __CLASS__, - self::SIGNAL_TASK_FAILED, - [$task, $exception] - ); - + $this->dispatcher->dispatch(new SchedulerTaskExecutionFailedEvent($task, $exception)); throw $exception; } } diff --git a/Classes/Service/Scheduler/SchedulerTaskExecutedEvent.php b/Classes/Service/Scheduler/SchedulerTaskExecutedEvent.php new file mode 100644 index 00000000..3a248509 --- /dev/null +++ b/Classes/Service/Scheduler/SchedulerTaskExecutedEvent.php @@ -0,0 +1,35 @@ +task = $task; + $this->result = $result; + } + + /** + * @return \TYPO3\CMS\Scheduler\Task\AbstractTask + */ + public function getTask(): \TYPO3\CMS\Scheduler\Task\AbstractTask + { + return $this->task; + } + + /** + * @return bool + */ + public function isResult(): bool + { + return $this->result; + } + +} diff --git a/Classes/Service/Scheduler/SchedulerTaskExecutionFailedEvent.php b/Classes/Service/Scheduler/SchedulerTaskExecutionFailedEvent.php new file mode 100644 index 00000000..1767ec84 --- /dev/null +++ b/Classes/Service/Scheduler/SchedulerTaskExecutionFailedEvent.php @@ -0,0 +1,36 @@ +task = $task; + $this->exception = $exception; + } + + /** + * @return \TYPO3\CMS\Scheduler\Task\AbstractTask + */ + public function getTask(): \TYPO3\CMS\Scheduler\Task\AbstractTask + { + return $this->task; + } + + /** + * @return Throwable + */ + public function getException(): Throwable + { + return $this->exception; + } + +} diff --git a/Classes/ViewHelpers/Backend/Module/HasAccessViewHelper.php b/Classes/ViewHelpers/Backend/Module/HasAccessViewHelper.php index c0dc0247..b7eb94f1 100644 --- a/Classes/ViewHelpers/Backend/Module/HasAccessViewHelper.php +++ b/Classes/ViewHelpers/Backend/Module/HasAccessViewHelper.php @@ -18,7 +18,7 @@ namespace CuyZ\Notiz\ViewHelpers\Backend\Module; use CuyZ\Notiz\Backend\Module\ModuleHandler; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; class HasAccessViewHelper extends AbstractViewHelper { diff --git a/Classes/ViewHelpers/Backend/Module/LinkViewHelper.php b/Classes/ViewHelpers/Backend/Module/LinkViewHelper.php index 8196b9e4..88aa9f2a 100644 --- a/Classes/ViewHelpers/Backend/Module/LinkViewHelper.php +++ b/Classes/ViewHelpers/Backend/Module/LinkViewHelper.php @@ -18,7 +18,7 @@ namespace CuyZ\Notiz\ViewHelpers\Backend\Module; use CuyZ\Notiz\Backend\Module\ModuleHandler; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class LinkViewHelper extends AbstractTagBasedViewHelper { diff --git a/Classes/ViewHelpers/Format/WrapLinesViewHelper.php b/Classes/ViewHelpers/Format/WrapLinesViewHelper.php index f0bbc23f..441a323d 100644 --- a/Classes/ViewHelpers/Format/WrapLinesViewHelper.php +++ b/Classes/ViewHelpers/Format/WrapLinesViewHelper.php @@ -19,8 +19,8 @@ use Closure; use CuyZ\Notiz\Service\StringService; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; class WrapLinesViewHelper extends AbstractViewHelper diff --git a/Classes/ViewHelpers/Iterator/ChunkViewHelper.php b/Classes/ViewHelpers/Iterator/ChunkViewHelper.php index f883edf6..ecbff571 100644 --- a/Classes/ViewHelpers/Iterator/ChunkViewHelper.php +++ b/Classes/ViewHelpers/Iterator/ChunkViewHelper.php @@ -18,8 +18,8 @@ namespace CuyZ\Notiz\ViewHelpers\Iterator; use Closure; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; class ChunkViewHelper extends AbstractViewHelper diff --git a/Classes/ViewHelpers/MarkViewHelper.php b/Classes/ViewHelpers/MarkViewHelper.php index bc7ba325..10658ae8 100644 --- a/Classes/ViewHelpers/MarkViewHelper.php +++ b/Classes/ViewHelpers/MarkViewHelper.php @@ -19,16 +19,15 @@ use Closure; use CuyZ\Notiz\Service\StringService; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; /** * Applies the "marker" behaviour to the given content: * * @see \CuyZ\Notiz\Service\StringService::doMark */ -class MarkViewHelper extends AbstractViewHelper implements CompilableInterface +class MarkViewHelper extends AbstractViewHelper { /** * @var boolean diff --git a/Classes/ViewHelpers/Notification/HasEventViewHelper.php b/Classes/ViewHelpers/Notification/HasEventViewHelper.php index 867049d3..40b3a7ca 100644 --- a/Classes/ViewHelpers/Notification/HasEventViewHelper.php +++ b/Classes/ViewHelpers/Notification/HasEventViewHelper.php @@ -18,7 +18,7 @@ namespace CuyZ\Notiz\ViewHelpers\Notification; use CuyZ\Notiz\Core\Notification\Notification; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; class HasEventViewHelper extends AbstractViewHelper { diff --git a/Classes/ViewHelpers/Notification/Link/ActivateViewHelper.php b/Classes/ViewHelpers/Notification/Link/ActivateViewHelper.php index d9f6e709..48472fbc 100644 --- a/Classes/ViewHelpers/Notification/Link/ActivateViewHelper.php +++ b/Classes/ViewHelpers/Notification/Link/ActivateViewHelper.php @@ -20,7 +20,7 @@ use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Notification\Activable; use CuyZ\Notiz\Core\Notification\Notification; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class ActivateViewHelper extends AbstractTagBasedViewHelper { diff --git a/Classes/ViewHelpers/Notification/Link/CreateViewHelper.php b/Classes/ViewHelpers/Notification/Link/CreateViewHelper.php index d83f0e03..e6a159ea 100644 --- a/Classes/ViewHelpers/Notification/Link/CreateViewHelper.php +++ b/Classes/ViewHelpers/Notification/Link/CreateViewHelper.php @@ -20,7 +20,7 @@ use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition; use CuyZ\Notiz\Core\Notification\Creatable; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class CreateViewHelper extends AbstractTagBasedViewHelper { diff --git a/Classes/ViewHelpers/Notification/Link/EditViewHelper.php b/Classes/ViewHelpers/Notification/Link/EditViewHelper.php index ae2ca73f..515f3418 100644 --- a/Classes/ViewHelpers/Notification/Link/EditViewHelper.php +++ b/Classes/ViewHelpers/Notification/Link/EditViewHelper.php @@ -19,7 +19,7 @@ use CuyZ\Notiz\Core\Notification\Editable; use CuyZ\Notiz\Core\Notification\Notification; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class EditViewHelper extends AbstractTagBasedViewHelper { diff --git a/Classes/ViewHelpers/Notification/Link/ShowViewHelper.php b/Classes/ViewHelpers/Notification/Link/ShowViewHelper.php index 8848767f..a92470bc 100644 --- a/Classes/ViewHelpers/Notification/Link/ShowViewHelper.php +++ b/Classes/ViewHelpers/Notification/Link/ShowViewHelper.php @@ -19,7 +19,7 @@ use CuyZ\Notiz\Core\Notification\Notification; use CuyZ\Notiz\Core\Notification\Viewable; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; class ShowViewHelper extends AbstractTagBasedViewHelper { diff --git a/Classes/ViewHelpers/Slot/RenderViewHelper.php b/Classes/ViewHelpers/Slot/RenderViewHelper.php index 72f2704a..5adebe48 100644 --- a/Classes/ViewHelpers/Slot/RenderViewHelper.php +++ b/Classes/ViewHelpers/Slot/RenderViewHelper.php @@ -24,11 +24,11 @@ use CuyZ\Notiz\Service\Container; use CuyZ\Notiz\View\Slot\SlotContainer; use CuyZ\Notiz\View\Slot\SlotView; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper; -use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer; use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler; use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer; /** * Will process and render the wanted slot, by getting the value filled by the diff --git a/Classes/ViewHelpers/Slot/SlotViewHelper.php b/Classes/ViewHelpers/Slot/SlotViewHelper.php index 63580af3..ac56e722 100644 --- a/Classes/ViewHelpers/Slot/SlotViewHelper.php +++ b/Classes/ViewHelpers/Slot/SlotViewHelper.php @@ -19,7 +19,7 @@ use CuyZ\Notiz\View\Slot\Application\Slot; use CuyZ\Notiz\View\Slot\SlotContainer; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; abstract class SlotViewHelper extends AbstractViewHelper { diff --git a/Classes/ViewHelpers/TViewHelper.php b/Classes/ViewHelpers/TViewHelper.php index 40f54f62..020df994 100644 --- a/Classes/ViewHelpers/TViewHelper.php +++ b/Classes/ViewHelpers/TViewHelper.php @@ -19,11 +19,10 @@ use CuyZ\Notiz\Service\LocalizationService; use CuyZ\Notiz\Service\StringService; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -class TViewHelper extends AbstractViewHelper implements CompilableInterface +class TViewHelper extends AbstractViewHelper { /** * @var boolean diff --git a/Configuration/Extbase/Persistence/Classes.php b/Configuration/Extbase/Persistence/Classes.php new file mode 100644 index 00000000..53eb4ed5 --- /dev/null +++ b/Configuration/Extbase/Persistence/Classes.php @@ -0,0 +1,28 @@ + [ + 'tableName' => 'tx_notiz_domain_model_entityemailnotification', + 'properties' => [ + 'backendUser' => [ + 'fieldName' => 'cruser_id' + ] + ] + ], + \CuyZ\Notiz\Domain\Notification\Log\Application\EntityLog\EntityLogNotification::class => [ + 'tableName' => 'tx_notiz_domain_model_entitylognotification', + 'properties' => [ + 'backendUser' => [ + 'fieldName' => 'cruser_id' + ] + ] + ], + \CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\EntitySlackNotification::class => [ + 'tableName' => 'tx_notiz_domain_model_entityslacknotification', + 'properties' => [ + 'backendUser' => [ + 'fieldName' => 'cruser_id' + ] + ] + ], +]; diff --git a/Configuration/FlexForm/Event/TYPO3/CachesClearedEventFlexForm.xml b/Configuration/FlexForm/Event/TYPO3/CachesClearedEventFlexForm.xml index 6a7ec591..778ee555 100644 --- a/Configuration/FlexForm/Event/TYPO3/CachesClearedEventFlexForm.xml +++ b/Configuration/FlexForm/Event/TYPO3/CachesClearedEventFlexForm.xml @@ -15,6 +15,7 @@ select + selectMultipleSideBySide 0 4 4 diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 00000000..c1bb19f0 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,41 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + CuyZ\Notiz\: + resource: '../Classes/*' + exclude: + - '../Classes/Domain/Event/Blog/*' + - '../Classes/Domain/Event/Form/*' + - '../Classes/Domain/Event/Scheduler/*' + - '../Classes/Domain/Event/TYPO3/*' + + CuyZ\Notiz\Core\Notification\Notification: '@CuyZ\Notiz\Domain\Notification\Log\Application\EntityLog\EntityLogNotification' + + CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition: + autowire: false + + CuyZ\Notiz\Core\Event\AbstractEvent: + autowire: false + + CuyZ\Notiz\Backend\FormEngine\ButtonBar\ShowNotificationDetailsButton: + tags: + - name: event.listener + identifier: 'show-notification-details-button' + event: TYPO3\CMS\Backend\Controller\Event\AfterFormEnginePageInitializedEvent + method: addButton + + CuyZ\Notiz\Domain\Definition\Builder\Component\DefaultDefinitionComponents: + tags: + - name: event.listener + identifier: 'default-definition-component' + event: CuyZ\Notiz\Core\Definition\Builder\Event\DefinitionBuilderManageComponentEvent + method: register + + CuyZ\Notiz\Core\Event\Runner\EventRunner: + tags: + - name: event.listener + identifier: 'notiz-event-listener' + event: CuyZ\Notiz\Core\Event\NotizEvent diff --git a/Configuration/Yaml/Form/DispatchFormNotificationModule.yaml b/Configuration/Yaml/Form/DispatchFormNotificationModule.yaml index a3bd81fb..5af9b61e 100644 --- a/Configuration/Yaml/Form/DispatchFormNotificationModule.yaml +++ b/Configuration/Yaml/Form/DispatchFormNotificationModule.yaml @@ -4,8 +4,7 @@ TYPO3: prototypes: standard: formEditor: - translationFile: - 10: 'EXT:form/Resources/Private/Language/Database.xlf' + translationFiles: 20: 'EXT:notiz/Resources/Private/Language/Event/Form/Form.xlf' formElementsDefinition: Form: @@ -14,14 +13,14 @@ TYPO3: 900: selectOptions: 1519552194: - value: 'DispatchNotification' - label: 'dispatch_form_notification.form_editor.finisher.dispatch_notification.label' + value: DispatchNotification + label: dispatch_form_notification.form_editor.finisher.dispatch_notification.label propertyCollections: finishers: 1519552194: - identifier: 'DispatchNotification' + identifier: DispatchNotification editors: __inheritances: - 10: 'TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin' + 10: TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin 100: - label: 'dispatch_form_notification.form_editor.finisher.dispatch_notification.label' + label: dispatch_form_notification.form_editor.finisher.dispatch_notification.label diff --git a/composer.json b/composer.json index aff0030c..e7420bd6 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ } ], "require": { - "typo3/cms-core": "^8.7.0 || ^9.5.17", - "romm/configuration-object": "^1.10 || ^2.0" + "typo3/cms-core": "^10.4.0", + "romm/configuration-object": "dev-development" }, "require-dev": { "phpunit/phpunit": "^4.7 || ^5.6", @@ -44,7 +44,7 @@ }, "extra": { "typo3/cms": { - "cms-package-dir": "{$vendor-dir}/typo3/cms" + "extension-key": "notiz" } } } diff --git a/ext_emconf.php b/ext_emconf.php index 3e3fedc8..46bf276c 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -4,19 +4,19 @@ 'title' => 'NotiZ • Powerful notification dispatcher', 'description' => 'Handle any type of notification in TYPO3 with ease: emails, SMS, Slack and more. Listen to your own events or provided ones (scheduler task finishing, extension installed, etc…).', - 'version' => '2.1.2', + 'version' => '3.0.0', 'state' => 'stable', 'author' => 'Romain Canon, Nathan Boiron', 'author_email' => 'team.cuyz@gmail.com', 'category' => 'be', - 'clearCacheOnLoad' => 1, + 'clearCacheOnLoad' => true, 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.0-9.5.99', - 'configuration_object' => '1.10.0-2.99.99', + 'typo3' => '10.4.0-10.4.99', + 'configuration_object' => '3.0.0-3.9.99', ], ], ]; diff --git a/ext_typoscript_setup.txt b/ext_typoscript_setup.txt index 26eb763a..59befce7 100644 --- a/ext_typoscript_setup.txt +++ b/ext_typoscript_setup.txt @@ -1,35 +1,3 @@ -config.tx_extbase.persistence.classes { - CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\EntityEmailNotification { - mapping { - tableName = tx_notiz_domain_model_entityemailnotification - - columns { - cruser_id.mapOnProperty = backendUser - } - } - } - - CuyZ\Notiz\Domain\Notification\Log\Application\EntityLog\EntityLogNotification { - mapping { - tableName = tx_notiz_domain_model_entitylognotification - - columns { - cruser_id.mapOnProperty = backendUser - } - } - } - - CuyZ\Notiz\Domain\Notification\Slack\Application\EntitySlack\EntitySlackNotification { - mapping { - tableName = tx_notiz_domain_model_entityslacknotification - - columns { - cruser_id.mapOnProperty = backendUser - } - } - } -} - module.tx_form { settings { yamlConfigurations {