diff --git a/src/Notifications/AdminModule/NotificationSettingFormFactory.php b/src/Notifications/AdminModule/NotificationSettingFormFactory.php index f5b204de..c1202c4d 100755 --- a/src/Notifications/AdminModule/NotificationSettingFormFactory.php +++ b/src/Notifications/AdminModule/NotificationSettingFormFactory.php @@ -52,9 +52,6 @@ public function create() ->setOption(IComponentMapper::ITEMS_TITLE, 'email') ->setPrompt('all'); - $form->setCurrentGroup(); - $form->addSubmit('_submit', 'Save'); - return $form; } diff --git a/src/Notifications/AdminModule/NotificationSettingFormService.php b/src/Notifications/AdminModule/NotificationSettingFormService.php new file mode 100644 index 00000000..d740b415 --- /dev/null +++ b/src/Notifications/AdminModule/NotificationSettingFormService.php @@ -0,0 +1,41 @@ + + */ +class NotificationSettingFormService extends \Venne\System\DoctrineFormService +{ + + public function __construct( + NotificationSettingFormFactory $formFactory, + EntityManager $entityManager, + EntityFormMapper $entityFormMapper + ) { + parent::__construct($formFactory, $entityManager, $entityFormMapper); + } + + /** + * @return string + */ + protected function getEntityClassName() + { + return NotificationSetting::class; + } + +} diff --git a/src/Notifications/AdminModule/SettingsPresenter.php b/src/Notifications/AdminModule/SettingsPresenter.php index 6a303e49..9dcb2802 100755 --- a/src/Notifications/AdminModule/SettingsPresenter.php +++ b/src/Notifications/AdminModule/SettingsPresenter.php @@ -34,20 +34,19 @@ class SettingsPresenter extends \Nette\Application\UI\Presenter /** @var \Venne\System\Components\AdminGrid\IAdminGridFactory */ private $adminGridFactory; - /** @var \Venne\Notifications\AdminModule\NotificationSettingFormFactory */ - private $notificationSettingFormFactory; + /** @var \Venne\Notifications\AdminModule\NotificationSettingFormService */ + private $notificationSettingFormService; public function __construct( EntityManager $entityManager, NotificationManager $notificationManager, IAdminGridFactory $adminGridFactory, - NotificationSettingFormFactory $notificationSettingFormFactory - ) - { + NotificationSettingFormService $notificationSettingFormService + ) { $this->notificationSettingRepository = $entityManager->getRepository(NotificationSetting::class); $this->notificationManager = $notificationManager; $this->adminGridFactory = $adminGridFactory; - $this->notificationSettingFormFactory = $notificationSettingFormFactory; + $this->notificationSettingFormService = $notificationSettingFormService; } /** diff --git a/src/Notifications/DI/NotificationsExtension.php b/src/Notifications/DI/NotificationsExtension.php index 97cddc70..176e721d 100755 --- a/src/Notifications/DI/NotificationsExtension.php +++ b/src/Notifications/DI/NotificationsExtension.php @@ -35,6 +35,10 @@ class NotificationsExtension extends \Nette\DI\CompilerExtension implements public function loadConfiguration() { $container = $this->getContainerBuilder(); + $this->compiler->parseServices( + $container, + $this->loadFromFile(__DIR__ . '/services.neon') + ); $config = $this->getConfig($this->defaults); $notificationManager = $container->addDefinition($this->prefix('notificationManager')) @@ -73,9 +77,6 @@ public function loadConfiguration() $container->addDefinition($this->prefix('emailJob')) ->setClass('Venne\Notifications\Jobs\EmailJob'); - - $container->addDefinition($this->prefix('notificationSettingFormFactory')) - ->setClass('Venne\Notifications\AdminModule\NotificationSettingFormFactory', array(new Statement('@system.admin.ajaxFormFactory'))); } public function beforeCompile() diff --git a/src/Notifications/DI/services.neon b/src/Notifications/DI/services.neon new file mode 100644 index 00000000..d7dffe73 --- /dev/null +++ b/src/Notifications/DI/services.neon @@ -0,0 +1,4 @@ +services: + + - Venne\Notifications\AdminModule\NotificationSettingFormFactory (@system.admin.ajaxFormFactory) + - Venne\Notifications\AdminModule\NotificationSettingFormService