diff --git a/.gitignore b/.gitignore index 2d07a150..2f8a275b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ composer.phar composer.lock coverage.xml phpunit.phar -.php_cs.cache +.php-cs-fixer.cache grunt.lock package-lock.json .phpunit.result.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 71% rename from .php_cs rename to .php-cs-fixer.php index 064932b5..2465f3f4 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -1,6 +1,6 @@ setRiskyAllowed(true) ->setRules([ '@PhpCsFixer' => true, @@ -10,7 +10,9 @@ 'concat_space' => ['spacing' => 'one'], 'method_chaining_indentation' => false, 'multiline_whitespace_before_semicolons' => false, - 'native_function_invocation' => false, + 'native_function_invocation' => ['include' => ['@all']], + 'no_superfluous_phpdoc_tags' => false, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], 'php_unit_internal_class' => false, 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], 'php_unit_test_class_requires_covers' => false, @@ -23,8 +25,15 @@ // Additional rules 'date_time_immutable' => true, 'declare_strict_types' => true, + 'global_namespace_import' => [ + 'import_classes' => null, + 'import_constants' => true, + 'import_functions' => true, + ], 'list_syntax' => ['syntax' => 'short'], 'mb_str_functions' => true, + 'native_constant_invocation' => true, + 'nullable_type_declaration_for_default_null_value' => true, 'static_lambda' => true, 'ternary_to_null_coalescing' => true, ]) diff --git a/README.md b/README.md index 5ab43b56..55f612f7 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ It is typically useful when it comes to the creation of feedback forms, polls, e An object can collect information if at least one of the class attributes is marked as an information collector. When the object is viewed, each collector attribute will be displayed using the chosen datatype's data collector template. Instead of just outputting the attributes' contents, the collector templates provide interfaces for data input. -The generated input interface depends on the datatype that represents the attribute. ( From eZ [documentation](https://doc.ez.no/eZ-Publish/Technical-manual/3.9/Concepts-and-basics/Content-management/Information-collection)). +The generated input interface depends on the datatype that represents the attribute. ( From eZ legacy [documentation](https://doc.ez.no/eZ-Publish/Technical-manual/3.9/Concepts-and-basics/Content-management/Information-collection)). -This bundle reimplements information collection feature in eZ Platform/Ibexa stack. +This bundle reimplements information collection feature in Ibexa Platform stack. License, docs and installation instructions ------------------------------------------- diff --git a/bundle/Command/DataAnonymizerCommand.php b/bundle/Command/DataAnonymizerCommand.php index cf26a8f0..f1e682e4 100644 --- a/bundle/Command/DataAnonymizerCommand.php +++ b/bundle/Command/DataAnonymizerCommand.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; +use DateTimeInterface; use DateInterval; use DateTime; use Exception; @@ -18,15 +19,9 @@ class DataAnonymizerCommand extends Command { protected static $defaultName = 'nginfocollector:anonymize'; - /** - * @var \Netgen\InformationCollection\Core\Persistence\Anonymizer\AnonymizerServiceFacade - */ - protected $anonymizer; + protected AnonymizerServiceFacade $anonymizer; - /** - * @var \DateInterval - */ - protected $period; + protected DateInterval $period; public function __construct(AnonymizerServiceFacade $anonymizerServiceFacade) { @@ -36,7 +31,7 @@ public function __construct(AnonymizerServiceFacade $anonymizerServiceFacade) parent::__construct(); } - protected function configure() + protected function configure(): void { $this->setName("nginfocollector:anonymize"); $this->setDescription("Anonymizes collected data in collected info tables."); @@ -58,14 +53,16 @@ protected function configure() $this->addUsage("--info-collection-id=456 --field-identifiers=title,name,last_name"); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if (is_null($input->getOption('content-id'))) { $output->writeln(" "); $output->writeln(" Missing content-id parameter. "); $output->writeln(" "); - return $this->displayHelp($input, $output); + $this->displayHelp($input, $output); + + return 1; } if (is_null($input->getOption('field-identifiers')) && !$input->getOption('all')) { @@ -73,7 +70,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(" Missing field-identifiers parameter. "); $output->writeln(" "); - return $this->displayHelp($input, $output); + $this->displayHelp($input, $output); + + return 1; } $contentId = intval($input->getOption('content-id')); @@ -87,13 +86,16 @@ protected function execute(InputInterface $input, OutputInterface $output) $count = $this->anonymizer->anonymize($contentId, $fields, $this->getDateFromPeriod()); $output->writeln("Done."); $output->writeln("Anonymized #{$count} collections."); + return 0; } $output->writeln("Canceled."); + + return 0; } - protected function initialize(InputInterface $input, OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output): void { if (!empty($input->getOption('period'))) { @@ -109,15 +111,15 @@ protected function initialize(InputInterface $input, OutputInterface $output) } } - protected function displayHelp(InputInterface $input, OutputInterface $output) + protected function displayHelp(InputInterface $input, OutputInterface $output): void { $help = new HelpCommand(); $help->setCommand($this); - return $help->run($input, $output); + $help->run($input, $output); } - protected function getFields(InputInterface $input) + protected function getFields(InputInterface $input): array { if (!empty($input->getOption('all'))) { return []; @@ -142,7 +144,7 @@ protected function getFields(InputInterface $input) return []; } - protected function proceedWithAction(InputInterface $input, OutputInterface $output) + protected function proceedWithAction(InputInterface $input, OutputInterface $output): bool { if ($input->getOption('neglect')) { return true; @@ -157,7 +159,7 @@ protected function proceedWithAction(InputInterface $input, OutputInterface $out return false; } - protected function getDateFromPeriod() + protected function getDateFromPeriod(): DateTimeInterface { $dt = new DateTime(); $dt->sub($this->period); diff --git a/bundle/Controller/Admin/AdminController.php b/bundle/Controller/Admin/AdminController.php index ae67cd38..b211c2f2 100644 --- a/bundle/Controller/Admin/AdminController.php +++ b/bundle/Controller/Admin/AdminController.php @@ -2,11 +2,11 @@ namespace Netgen\Bundle\InformationCollectionBundle\Controller\Admin; -use eZ\Publish\API\Repository\Values\Content\Content; -use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute; -use eZ\Bundle\EzPublishCoreBundle\Controller; -use eZ\Publish\API\Repository\ContentService; -use eZ\Publish\Core\MVC\ConfigResolverInterface; +use Ibexa\Contracts\Core\Repository\Values\Content\Content; +use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; +use Ibexa\Bundle\Core\Controller; +use Ibexa\Contracts\Core\Repository\ContentService; +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer; use Netgen\InformationCollection\API\Service\InformationCollection; use Netgen\InformationCollection\API\Value\Collection; @@ -21,45 +21,23 @@ use Netgen\InformationCollection\Core\Pagination\InformationCollectionContentsAdapter; use Pagerfanta\Adapter\AdapterInterface; use Pagerfanta\Pagerfanta; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; class AdminController extends Controller { - /** - * @var \Netgen\InformationCollection\API\Service\InformationCollection - */ - protected $service; + protected InformationCollection $service; - /** - * @var \eZ\Publish\API\Repository\ContentService - */ - protected $contentService; + protected ContentService $contentService; - /** - * @var \eZ\Publish\Core\MVC\ConfigResolverInterface - */ - protected $configResolver; + protected ConfigResolverInterface $configResolver; - /** - * @var \Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer - */ - protected $anonymizer; + protected Anonymizer $anonymizer; - /** - * @var \Symfony\Contracts\Translation\TranslatorInterface - */ - private $translator; + private TranslatorInterface $translator; - /** - * AdminController constructor. - * - * @param \Netgen\InformationCollection\API\Service\InformationCollection $service - * @param \Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer $anonymizer - * @param \eZ\Publish\API\Repository\ContentService $contentService - * @param \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - */ public function __construct( InformationCollection $service, Anonymizer $anonymizer, @@ -77,12 +55,8 @@ public function __construct( /** * Displays overview page - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response */ - public function overviewAction(Request $request) + public function overviewAction(Request $request): Response { $this->checkReadPermissions(); @@ -94,13 +68,8 @@ public function overviewAction(Request $request) /** * Displays list of collection for selected Content - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \eZ\Publish\API\Repository\Values\Content\Content $content - * - * @return \Symfony\Component\HttpFoundation\Response */ - public function collectionListAction(Request $request, Content $content) + public function collectionListAction(Request $request, Content $content): Response { $this->checkReadPermissions(); @@ -115,13 +84,8 @@ public function collectionListAction(Request $request, Content $content) /** * Handles collection search - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \eZ\Publish\API\Repository\Values\Content\Content $content - * - * @return \Symfony\Component\HttpFoundation\Response */ - public function searchAction(Request $request, Content $content) + public function searchAction(Request $request, Content $content): Response { $this->checkReadPermissions(); @@ -140,12 +104,8 @@ public function searchAction(Request $request, Content $content) /** * Displays individual collection details - * - * @param \Netgen\InformationCollection\API\Value\Collection $collection - * - * @return \Symfony\Component\HttpFoundation\Response */ - public function viewAction(Collection $collection) + public function viewAction(Collection $collection): Response { $this->checkReadPermissions(); @@ -157,12 +117,8 @@ public function viewAction(Collection $collection) /** * Handles actions performed on overview page - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function handleContentsAction(Request $request) + public function handleContentsAction(Request $request): RedirectResponse { $this->checkReadPermissions(); @@ -195,12 +151,8 @@ public function handleContentsAction(Request $request) /** * Handles actions performed on collection list page - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function handleCollectionListAction(Request $request) + public function handleCollectionListAction(Request $request): RedirectResponse { $this->checkReadPermissions(); @@ -247,12 +199,8 @@ public function handleCollectionListAction(Request $request) /** * Handles action on collection details page - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function handleCollectionAction(Request $request) + public function handleCollectionAction(Request $request): RedirectResponse { $this->checkReadPermissions(); @@ -325,13 +273,8 @@ public function handleCollectionAction(Request $request) /** * Adds a flash message with specified parameters. - * - * @param string $messageType - * @param string $message - * @param int $count - * @param array $parameters */ - protected function addFlashMessage(string $messageType, string $message, int $count = 1, array $parameters = array()) + protected function addFlashMessage(string $messageType, string $message, int $count = 1, array $parameters = array()): void { $parameters = array_merge($parameters, ['count' => $count]); @@ -347,15 +290,9 @@ protected function addFlashMessage(string $messageType, string $message, int $co /** * Returns configured instance of Pagerfanta - * - * @param \Pagerfanta\Adapter\AdapterInterface $adapter - * @param int $currentPage - * - * @return \Pagerfanta\Pagerfanta */ protected function getPager(AdapterInterface $adapter, int $currentPage): Pagerfanta { - $currentPage = (int) $currentPage; $pager = new Pagerfanta($adapter); $pager->setNormalizeOutOfRangePages(true); $pager->setMaxPerPage( diff --git a/bundle/Controller/Admin/Export/Export.php b/bundle/Controller/Admin/Export/Export.php index fc442760..9510166d 100644 --- a/bundle/Controller/Admin/Export/Export.php +++ b/bundle/Controller/Admin/Export/Export.php @@ -2,31 +2,23 @@ namespace Netgen\Bundle\InformationCollectionBundle\Controller\Admin\Export; -use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute; +use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Netgen\InformationCollection\API\Value\Export\ExportCriteria; use Netgen\InformationCollection\API\Service\Exporter; use Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry; use Symfony\Component\HttpFoundation\Request; -use Netgen\InformationCollection\Form\Type\ExportType; -use eZ\Publish\API\Repository\ContentService; +use Netgen\Bundle\InformationCollectionBundle\Form\ExportType; +use Ibexa\Contracts\Core\Repository\ContentService; +use Symfony\Component\HttpFoundation\Response; final class Export extends AbstractController { - /** - * @var \eZ\Publish\API\Repository\ContentService - */ - protected $contentService; + protected ContentService $contentService; - /** - * @var \Netgen\InformationCollection\API\Service\Exporter - */ - protected $exporter; + protected Exporter $exporter; - /** - * @var \Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry - */ - protected $formatterRegistry; + protected ExportResponseFormatterRegistry $formatterRegistry; public function __construct( ContentService $contentService, @@ -39,12 +31,15 @@ public function __construct( $this->formatterRegistry = $formatterRegistry; } - public function __invoke($contentId, Request $request) + /** + * @param int $contentId + */ + public function __invoke($contentId, Request $request): Response { $attribute = new Attribute('infocollector', 'export'); $this->denyAccessUnlessGranted($attribute); - $content = $this->contentService->loadContent($contentId); + $content = $this->contentService->loadContent((int) $contentId); $form = $this->createForm(ExportType::class, null, [ 'contentId' => $content->id, diff --git a/bundle/Controller/Admin/TreeController.php b/bundle/Controller/Admin/TreeController.php index 575e9cec..75270516 100644 --- a/bundle/Controller/Admin/TreeController.php +++ b/bundle/Controller/Admin/TreeController.php @@ -2,8 +2,8 @@ namespace Netgen\Bundle\InformationCollectionBundle\Controller\Admin; -use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute; -use eZ\Bundle\EzPublishCoreBundle\Controller; +use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; +use Ibexa\Bundle\Core\Controller; use Netgen\InformationCollection\API\Service\InformationCollection; use Netgen\InformationCollection\API\Value\Content; use Netgen\InformationCollection\API\Value\Filter\ContentId; @@ -14,28 +14,12 @@ class TreeController extends Controller { - /** - * @var \Symfony\Contracts\Translation\TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; - /** - * @var \Symfony\Component\Routing\RouterInterface - */ - protected $router; + protected RouterInterface $router; - /** - * @var \Netgen\InformationCollection\API\Service\InformationCollection - */ - protected $service; + protected InformationCollection $service; - /** - * TreeController constructor. - * - * @param \Netgen\InformationCollection\API\Service\InformationCollection $service - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - * @param \Symfony\Component\Routing\RouterInterface $router - */ public function __construct( InformationCollection $service, TranslatorInterface $translator, @@ -50,17 +34,16 @@ public function __construct( * Get contents with collections * * @param bool $isRoot - * - * @return \Symfony\Component\HttpFoundation\JsonResponse */ - public function getChildrenAction($isRoot = false) + public function getChildrenAction($isRoot = false): JsonResponse { + $isRoot = (bool) $isRoot; $attribute = new Attribute('infocollector', 'read'); $this->denyAccessUnlessGranted($attribute); $result = array(); - if ((bool) $isRoot) { + if ($isRoot) { $result[] = $this->getRootTreeData(); } else { @@ -77,10 +60,8 @@ public function getChildrenAction($isRoot = false) /** * Generates data for root of the tree. - * - * @return array */ - protected function getRootTreeData() + protected function getRootTreeData(): array { $count = $this->service->getObjectsWithCollectionsCount(); @@ -104,13 +85,11 @@ protected function getRootTreeData() /** * Creates tree structure for Content * - * @param \Netgen\InformationCollection\API\Value\Content $content * @param bool $isRoot - * - * @return array */ - protected function getCollections(Content $content, $isRoot = false) + protected function getCollections(Content $content, $isRoot = false): array { + $isRoot = (bool) $isRoot; $languages = $this->getConfigResolver()->getParameter('languages'); $query = ContentId::countWithContentId($content->getContent()->id); @@ -120,7 +99,7 @@ protected function getCollections(Content $content, $isRoot = false) return array( 'id' => $content->getContent()->id, 'parent' => $isRoot ? '#' : '0', - 'text' => $content->getContent()->getName($languages[0]) . ' (' . strval($count->getCount()) . ')', + 'text' => $content->getContent()->getName(in_array($languages[0], $content->getContent()->getVersionInfo()->languageCodes) ? $languages[0] : null) . ' (' . strval($count->getCount()) . ')', 'children' => false, 'a_attr' => array( 'href' => $this->router->generate('netgen_information_collection.route.admin.collection_list', ['contentId' => $content->getContent()->id]), diff --git a/bundle/Controller/CollectInformation.php b/bundle/Controller/CollectInformation.php index fe65430e..e83ce6f2 100644 --- a/bundle/Controller/CollectInformation.php +++ b/bundle/Controller/CollectInformation.php @@ -2,7 +2,7 @@ namespace Netgen\Bundle\InformationCollectionBundle\Controller; -use eZ\Publish\Core\MVC\Symfony\View\ContentValueView; +use Ibexa\Core\MVC\Symfony\View\ContentValueView; use Netgen\InformationCollection\API\InformationCollectionTrait; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; @@ -14,12 +14,8 @@ class CollectInformation implements ContainerAwareInterface /** * Displays and handles information collection. - * - * @param ContentValueView $view - * - * @return ContentValueView */ - public function __invoke(ContentValueView $view) + public function __invoke(ContentValueView $view): ContentValueView { return $this->collectInformation($view, []); } diff --git a/bundle/DataCollector/InformationCollectionCollector.php b/bundle/DataCollector/InformationCollectionCollector.php index b69e4a1c..3dc9e628 100644 --- a/bundle/DataCollector/InformationCollectionCollector.php +++ b/bundle/DataCollector/InformationCollectionCollector.php @@ -4,25 +4,19 @@ namespace Netgen\Bundle\InformationCollectionBundle\DataCollector; -use eZ\Publish\API\Repository\Repository; -use eZ\Publish\API\Repository\Values\ContentType\ContentType; -use eZ\Publish\Core\Helper\TranslationHelper; +use Ibexa\Contracts\Core\Repository\Repository; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; +use Ibexa\Core\Helper\TranslationHelper; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; -use Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionType; +use Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms\InformationCollectionType; class InformationCollectionCollector extends DataCollector { - /** - * @var \eZ\Publish\API\Repository\Repository - */ - private $repository; + private Repository $repository; - /** - * @var \eZ\Publish\Core\Helper\TranslationHelper - */ - private $translationHelper; + private TranslationHelper $translationHelper; public function __construct(Repository $repository, TranslationHelper $translationHelper) { @@ -37,7 +31,7 @@ public function __construct(Repository $repository, TranslationHelper $translati $this->translationHelper = $translationHelper; } - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, \Throwable $exception = null): void { if ($request->get(InformationCollectionType::FORM_BLOCK_PREFIX) !== null) { $this->mapCollectedData($request); diff --git a/bundle/DependencyInjection/Configuration.php b/bundle/DependencyInjection/Configuration.php index 28eb09d3..82129a65 100644 --- a/bundle/DependencyInjection/Configuration.php +++ b/bundle/DependencyInjection/Configuration.php @@ -2,7 +2,7 @@ namespace Netgen\Bundle\InformationCollectionBundle\DependencyInjection; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration; use Netgen\InformationCollection\Core\Action\EmailAction; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; @@ -16,10 +16,7 @@ */ class Configuration extends SiteAccessConfiguration { - /** - * {@inheritdoc} - */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder(ConfigurationConstants::SETTINGS_ROOT); $rootNode = $treeBuilder->getRootNode(); @@ -37,7 +34,7 @@ public function getConfigTreeBuilder() return $treeBuilder; } - private function addCaptchaSection(NodeBuilder $nodeBuilder) + private function addCaptchaSection(NodeBuilder $nodeBuilder): void { $nodeBuilder ->arrayNode('captcha') @@ -107,7 +104,7 @@ private function addCaptchaSection(NodeBuilder $nodeBuilder) ->end(); } - private function addActionsSection(NodeBuilder $nodeBuilder) + private function addActionsSection(NodeBuilder $nodeBuilder): void { $nodeBuilder ->arrayNode(ConfigurationConstants::ACTIONS) @@ -133,7 +130,7 @@ private function addActionsSection(NodeBuilder $nodeBuilder) ->end(); } - private function addActionConfigSection(NodeBuilder $nodeBuilder) + private function addActionConfigSection(NodeBuilder $nodeBuilder): void { $nodeBuilder ->arrayNode(ConfigurationConstants::ACTION_CONFIG) @@ -226,7 +223,7 @@ private function addActionConfigSection(NodeBuilder $nodeBuilder) ->end(); } - private function addExportSection(NodeBuilder $nodeBuilder) + private function addExportSection(NodeBuilder $nodeBuilder): void { $nodeBuilder ->arrayNode('export') diff --git a/bundle/DependencyInjection/NetgenInformationCollectionExtension.php b/bundle/DependencyInjection/NetgenInformationCollectionExtension.php index f36e19d5..8f3a20f6 100644 --- a/bundle/DependencyInjection/NetgenInformationCollectionExtension.php +++ b/bundle/DependencyInjection/NetgenInformationCollectionExtension.php @@ -2,8 +2,9 @@ namespace Netgen\Bundle\InformationCollectionBundle\DependencyInjection; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; +use Ibexa\Core\Helper\TranslationHelper; use Netgen\InformationCollection\API\Action\ActionInterface; use Netgen\InformationCollection\API\ConfigurationConstants; use Symfony\Component\Config\FileLocator; @@ -24,10 +25,7 @@ */ class NetgenInformationCollectionExtension extends Extension implements PrependExtensionInterface { - /** - * {@inheritdoc} - */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); @@ -42,6 +40,9 @@ public function load(array $configs, ContainerBuilder $container) $libResourceLoader->load('services.yml'); $libResourceLoader->load('parameters.yml'); $libResourceLoader->load('default_settings.yml'); + $libResourceLoader->load('email_data_providers.yml'); + $libResourceLoader->load('mailers.yml'); + $libResourceLoader->load('graphql.yml'); $this->processSemanticConfig($container, $config); @@ -51,7 +52,7 @@ public function load(array $configs, ContainerBuilder $container) // ConfigurationConstants::ACTION_CONFIG, // ); // -// $scopes = array_merge(array('default'), $container->getParameter('ezpublish.siteaccess.list')); +// $scopes = array_merge(array('default'), $container->getParameter('ibexa.site_access.list')); // // foreach ($configArrays as $configArray) { // $processor->mapConfigArray($configArray, $config); @@ -72,7 +73,7 @@ public function load(array $configs, ContainerBuilder $container) $this->registerServiceDefinitions($container); } - public function prepend(ContainerBuilder $container) + public function prepend(ContainerBuilder $container): void { $this->addTwigConfig($container); $this->addDoctrineConfig($container); @@ -95,7 +96,7 @@ static function ($config, $scope, ContextualizerInterface $c): void { ); } - protected function addDoctrineConfig(ContainerBuilder $container) + protected function addDoctrineConfig(ContainerBuilder $container): void { $configDir = __DIR__ . '/../../lib/Doctrine/mappings'; @@ -147,8 +148,8 @@ protected function registerServiceDefinitions(ContainerBuilder $container): void \Netgen\InformationCollection\Core\Export\CsvExportResponseFormatter::class ); $csvExportFormatter->addTag('netgen_information_collection.export.formatter'); - $csvExportFormatter->addArgument(new Reference('ezpublish.translation_helper')); - $csvExportFormatter->addArgument(new Reference('ezpublish.config.resolver')); + $csvExportFormatter->addArgument(new Reference(TranslationHelper::class)); + $csvExportFormatter->addArgument(new Reference('ibexa.config.resolver')); $csvExportFormatter->setPublic(false); $csvExportFormatter->setAutowired(false); $csvExportFormatter->setAutoconfigured(false); @@ -161,7 +162,7 @@ protected function registerServiceDefinitions(ContainerBuilder $container): void \Netgen\InformationCollection\Core\Export\XlsExportResponseFormatter::class ); $xlsExportFormatter->addTag('netgen_information_collection.export.formatter'); - $xlsExportFormatter->addArgument(new Reference('ezpublish.translation_helper')); + $xlsExportFormatter->addArgument(new Reference(TranslationHelper::class)); $xlsExportFormatter->setPublic(false); $xlsExportFormatter->setAutowired(false); $xlsExportFormatter->setAutoconfigured(false); @@ -170,7 +171,7 @@ protected function registerServiceDefinitions(ContainerBuilder $container): void \Netgen\InformationCollection\Core\Export\XlsxExportResponseFormatter::class ); $xlsxExportFormatter->addTag('netgen_information_collection.export.formatter'); - $xlsxExportFormatter->addArgument(new Reference('ezpublish.translation_helper')); + $xlsxExportFormatter->addArgument(new Reference(TranslationHelper::class)); $xlsxExportFormatter->setPublic(false); $xlsxExportFormatter->setAutowired(false); $xlsxExportFormatter->setAutoconfigured(false); diff --git a/bundle/Form/CaptchaType.php b/bundle/Form/CaptchaType.php index 7039c65e..43de5d84 100644 --- a/bundle/Form/CaptchaType.php +++ b/bundle/Form/CaptchaType.php @@ -11,17 +11,14 @@ class CaptchaType extends AbstractType { - /** - * @var \Netgen\Bundle\InformationCollectionBundle\Listener\CaptchaValidationListener - */ - private $validationListener; + private CaptchaValidationListener $validationListener; public function __construct(CaptchaValidationListener $validationListener) { $this->validationListener = $validationListener; } - public function buildView(FormView $view, FormInterface $form, array $options) + public function buildView(FormView $view, FormInterface $form, array $options): void { $view->vars['type'] = $options['type']; $view->vars['theme'] = $options['theme']; @@ -30,12 +27,12 @@ public function buildView(FormView $view, FormInterface $form, array $options) $view->vars['captcha_action'] = $options['captcha_action']; } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->addEventSubscriber($this->validationListener); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults( [ diff --git a/bundle/Form/ExportType.php b/bundle/Form/ExportType.php index b09fa703..4b6d3bf5 100644 --- a/bundle/Form/ExportType.php +++ b/bundle/Form/ExportType.php @@ -4,6 +4,7 @@ namespace Netgen\Bundle\InformationCollectionBundle\Form; +use DateTimeInterface; use Netgen\InformationCollection\API\Value\Export\ExportCriteria; use Netgen\InformationCollection\API\Value\Filter\ContentId; use Symfony\Component\Form\AbstractType; @@ -23,16 +24,8 @@ class ExportType extends AbstractType implements DataMapperInterface { - /** - * @var \Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry - */ - protected $exportResponseFormatterRegistry; - - /** - * ExportType constructor. - * - * @param \Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry $exportResponseFormatterRegistry - */ + protected ExportResponseFormatterRegistry $exportResponseFormatterRegistry; + public function __construct(ExportResponseFormatterRegistry $exportResponseFormatterRegistry) { $this->exportResponseFormatterRegistry = $exportResponseFormatterRegistry; @@ -48,7 +41,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'translation_domain' => 'netgen_information_collection_admin', 'constraints' => [ new Assert\NotBlank(), - new Assert\Type(\DateTimeInterface::class), + new Assert\Type(DateTimeInterface::class), ], ]); @@ -60,7 +53,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'translation_domain' => 'netgen_information_collection_admin', 'constraints' => [ new Assert\NotBlank(), - new Assert\Type(\DateTimeInterface::class), + new Assert\Type(DateTimeInterface::class), ], ]); @@ -121,7 +114,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->setDataMapper($this); - $builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) use ($availableFormatters) { + $builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) use ($availableFormatters): void { if (empty($availableFormatters)) { $formError = new FormError('netgen_information_collection_admin_export_no_formatters'); $event->getForm()->addError($formError); @@ -129,7 +122,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void }); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => ExportCriteria::class, @@ -140,12 +133,12 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('contentId', 'int'); } - public function mapDataToForms($viewData, iterable $forms) + public function mapDataToForms($viewData, iterable $forms): void { } - public function mapFormsToData(iterable $forms, &$viewData) + public function mapFormsToData(iterable $forms, &$viewData): void { $forms = iterator_to_array($forms); diff --git a/bundle/EzPlatform/EzPlatformAdmin/EventListener/SetPageLayoutListener.php b/bundle/Ibexa/Admin/EventListener/SetPageLayoutListener.php similarity index 62% rename from bundle/EzPlatform/EzPlatformAdmin/EventListener/SetPageLayoutListener.php rename to bundle/Ibexa/Admin/EventListener/SetPageLayoutListener.php index 9551ff31..bbd4ca97 100644 --- a/bundle/EzPlatform/EzPlatformAdmin/EventListener/SetPageLayoutListener.php +++ b/bundle/Ibexa/Admin/EventListener/SetPageLayoutListener.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\EzPlatformAdmin\EventListener; +namespace Netgen\Bundle\InformationCollectionBundle\Ibexa\Admin\EventListener; -use EzSystems\EzPlatformAdminUiBundle\EzPlatformAdminUiBundle; +use Ibexa\Bundle\AdminUi\IbexaAdminUiBundle; use Netgen\Bundle\InformationCollectionBundle\Templating\Twig\AdminGlobalVariable; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\RequestEvent; @@ -12,39 +12,30 @@ class SetPageLayoutListener implements EventSubscriberInterface { - /** - * @var \Netgen\Bundle\InformationCollectionBundle\Templating\Twig\AdminGlobalVariable - */ - protected $globalVariable; + protected AdminGlobalVariable $globalVariable; - /** - * @var string - */ - protected $pageLayoutTemplate; + protected string $pageLayoutTemplate; - /** - * @var array - */ - protected $groupsBySiteAccess; + protected array $groupsBySiteAccess; public function __construct( AdminGlobalVariable $adminGlobalVariable, array $groupsBySiteAccess, - $pageLayoutTemplate + string $pageLayoutTemplate ) { $this->globalVariable = $adminGlobalVariable; $this->pageLayoutTemplate = $pageLayoutTemplate; $this->groupsBySiteAccess = $groupsBySiteAccess; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::REQUEST => 'onKernelRequest', ]; } - public function onKernelRequest(RequestEvent $event) + public function onKernelRequest(RequestEvent $event): void { if (!$event->isMasterRequest()) { return; @@ -55,7 +46,7 @@ public function onKernelRequest(RequestEvent $event) return; } - if (!in_array(EzPlatformAdminUiBundle::ADMIN_GROUP_NAME, $this->groupsBySiteAccess[$siteAccess], true)) { + if (!in_array(IbexaAdminUiBundle::ADMIN_GROUP_NAME, $this->groupsBySiteAccess[$siteAccess], true)) { return; } diff --git a/bundle/EzPlatform/EzPlatformAdmin/MenuListener.php b/bundle/Ibexa/Admin/MenuListener.php similarity index 78% rename from bundle/EzPlatform/EzPlatformAdmin/MenuListener.php rename to bundle/Ibexa/Admin/MenuListener.php index d8538dda..dbd12896 100644 --- a/bundle/EzPlatform/EzPlatformAdmin/MenuListener.php +++ b/bundle/Ibexa/Admin/MenuListener.php @@ -2,22 +2,22 @@ declare(strict_types=1); -namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\EzPlatformAdmin; +namespace Netgen\Bundle\InformationCollectionBundle\Ibexa\Admin; -use EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent; -use EzSystems\EzPlatformAdminUi\Menu\MainMenuBuilder; +use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent; +use Ibexa\AdminUi\Menu\MainMenuBuilder; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class MenuListener implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConfigureMenuEvent::MAIN_MENU => ['onMenuConfigure', 0], ]; } - public function onMenuConfigure(ConfigureMenuEvent $event) + public function onMenuConfigure(ConfigureMenuEvent $event): void { $menu = $event->getMenu(); @@ -28,9 +28,10 @@ public function onMenuConfigure(ConfigureMenuEvent $event) $menu[MainMenuBuilder::ITEM_ADMIN]->addChild( 'information_collection', [ - 'label' => 'Information collection', + 'label' => 'netgen_information_collection_menu_label', 'route' => 'netgen_information_collection.route.admin.overview', 'extras' => [ + 'translation_domain' => 'netgen_information_collection_admin', 'routes' => [ 'collection_list' => 'netgen_information_collection.route.admin.collection_list', 'collection_list_search' => 'netgen_information_collection.route.admin.collection_list_search', diff --git a/bundle/Ibexa/ContentForms/ContentFieldTypeExtension.php b/bundle/Ibexa/ContentForms/ContentFieldTypeExtension.php new file mode 100644 index 00000000..99722411 --- /dev/null +++ b/bundle/Ibexa/ContentForms/ContentFieldTypeExtension.php @@ -0,0 +1,43 @@ +getName(); + + /** @var \Ibexa\ContentForms\Data\Content\ContentUpdateData $updateStruct */ + $updateStruct = $options['contentUpdateStruct']; + + if (null === $updateStruct) { + return; + } + + $fieldDefinition = $updateStruct->fieldsData[$fieldIdentifier]->fieldDefinition; + if ($fieldDefinition->isInfoCollector) { + $builder->setRequired(false); + + (function () { + $this->isRequired = false; + })->call($fieldDefinition); + } + } +} diff --git a/bundle/EzPlatform/RepositoryForms/FieldDefinitionTypeExtension.php b/bundle/Ibexa/ContentForms/FieldDefinitionTypeExtension.php similarity index 79% rename from bundle/EzPlatform/RepositoryForms/FieldDefinitionTypeExtension.php rename to bundle/Ibexa/ContentForms/FieldDefinitionTypeExtension.php index 0f07b468..ebd1bf80 100644 --- a/bundle/EzPlatform/RepositoryForms/FieldDefinitionTypeExtension.php +++ b/bundle/Ibexa/ContentForms/FieldDefinitionTypeExtension.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms; +namespace Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms; -use EzSystems\EzPlatformAdminUi\Form\Type\FieldDefinition\FieldDefinitionType; +use Ibexa\AdminUi\Form\Type\FieldDefinition\FieldDefinitionType; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\FormBuilderInterface; class FieldDefinitionTypeExtension extends AbstractTypeExtension { - public function getExtendedType() + public function getExtendedType(): string { return FieldDefinitionType::class; } @@ -21,7 +21,7 @@ public static function getExtendedTypes(): iterable return [FieldDefinitionType::class]; } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $isTranslation = $options['languageCode'] !== $options['mainLanguageCode']; diff --git a/bundle/Ibexa/ContentForms/InfoCollectorContentValidator.php b/bundle/Ibexa/ContentForms/InfoCollectorContentValidator.php new file mode 100644 index 00000000..a2aab9e7 --- /dev/null +++ b/bundle/Ibexa/ContentForms/InfoCollectorContentValidator.php @@ -0,0 +1,36 @@ +getContentType()->fieldDefinitions as $fieldDefinition) { + /** @var \Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition $fieldDefinition */ + if ($fieldDefinition->isInfoCollector) { + (function () { + $this->isRequired = false; + })->call($fieldDefinition); + } + } + + return []; + } +} diff --git a/bundle/EzPlatform/RepositoryForms/InformationCollectionFieldType.php b/bundle/Ibexa/ContentForms/InformationCollectionFieldType.php similarity index 72% rename from bundle/EzPlatform/RepositoryForms/InformationCollectionFieldType.php rename to bundle/Ibexa/ContentForms/InformationCollectionFieldType.php index 1a844a33..e63e6c4f 100644 --- a/bundle/EzPlatform/RepositoryForms/InformationCollectionFieldType.php +++ b/bundle/Ibexa/ContentForms/InformationCollectionFieldType.php @@ -1,10 +1,10 @@ fieldTypeFormMapper = $fieldTypeFormMapper; } - public function getName() + public function getName(): string { return $this->getBlockPrefix(); } - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'ezplatform_content_forms_content_field'; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ @@ -48,15 +45,15 @@ public function configureOptions(OptionsResolver $resolver) ->setRequired(['languageCode', 'mainLanguageCode']); } - public function buildView(FormView $view, FormInterface $form, array $options) + public function buildView(FormView $view, FormInterface $form, array $options): void { $view->vars['languageCode'] = $options['languageCode']; $view->vars['mainLanguageCode'] = $options['mainLanguageCode']; } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { $this->fieldTypeFormMapper->map($event->getForm(), $event->getData()); }); } diff --git a/bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php b/bundle/Ibexa/ContentForms/InformationCollectionMapper.php similarity index 52% rename from bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php rename to bundle/Ibexa/ContentForms/InformationCollectionMapper.php index 9cb45293..ac922dea 100644 --- a/bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php +++ b/bundle/Ibexa/ContentForms/InformationCollectionMapper.php @@ -2,31 +2,26 @@ declare(strict_types=1); -namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms; +namespace Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms; -use eZ\Publish\API\Repository\Values\Content\Content; -use eZ\Publish\API\Repository\Values\Content\Location; -use eZ\Publish\API\Repository\Values\ContentType\ContentType; -use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; -use eZ\Publish\API\Repository\Values\ValueObject; +use Ibexa\Contracts\Core\Repository\Values\Content\Content; +use Ibexa\Contracts\Core\Repository\Values\Content\Location; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; +use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition; +use Ibexa\Contracts\Core\Repository\Values\ValueObject; use Netgen\InformationCollection\API\Value\InformationCollectionStruct; use Symfony\Component\OptionsResolver\OptionsResolver; -use EzSystems\EzPlatformContentForms\Data\Mapper\FormDataMapperInterface; -use EzSystems\EzPlatformContentForms\Data\Content\FieldData; +use Ibexa\ContentForms\Data\Mapper\FormDataMapperInterface; +use Ibexa\Contracts\ContentForms\Data\Content\FieldData; final class InformationCollectionMapper { /** - * Maps a ValueObject from eZ content repository to a data usable as underlying form data (e.g. create/update struct). - * - * @param \eZ\Publish\API\Repository\Values\Content\Content $contentDraft - * @param array $params - * - * @return InformationCollectionStruct + * Maps a ValueObject from Ibexa content repository to a data usable as underlying form data (e.g. create/update struct). */ - public function mapToFormData(Content $content, Location $location, ContentType $contentType) + public function mapToFormData(Content $content, Location $location, ContentType $contentType): InformationCollectionStruct { - $fields = $content->getFieldsByLanguage($content->contentInfo->mainLanguageCode); + $fields = $content->getFieldsByLanguage(); $informationCollectionFields = []; diff --git a/bundle/EzPlatform/RepositoryForms/InformationCollectionType.php b/bundle/Ibexa/ContentForms/InformationCollectionType.php similarity index 74% rename from bundle/EzPlatform/RepositoryForms/InformationCollectionType.php rename to bundle/Ibexa/ContentForms/InformationCollectionType.php index ad00102e..12815f41 100644 --- a/bundle/EzPlatform/RepositoryForms/InformationCollectionType.php +++ b/bundle/Ibexa/ContentForms/InformationCollectionType.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms; +namespace Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms; -use eZ\Publish\Core\MVC\ConfigResolverInterface; +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; use Netgen\Bundle\InformationCollectionBundle\Form\CaptchaType; use Netgen\InformationCollection\API\Service\CaptchaService; use Netgen\InformationCollection\API\Value\InformationCollectionStruct; @@ -21,33 +21,34 @@ class InformationCollectionType extends AbstractType implements DataMapperInterf { public const FORM_BLOCK_PREFIX = 'information_collection'; - /** - * @var \Netgen\InformationCollection\API\Service\CaptchaService - */ - private $captchaService; + private CaptchaService $captchaService; - public function __construct(CaptchaService $captchaService) + private ConfigResolverInterface $configResolver; + + public function __construct(CaptchaService $captchaService, ConfigResolverInterface $configResolver) { $this->captchaService = $captchaService; + $this->configResolver = $configResolver; } - public function getName() + public function getName(): string { $this->getBlockPrefix(); } - public function getBlockPrefix() + public function getBlockPrefix(): string { return self::FORM_BLOCK_PREFIX; } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { /** @var InformationCollectionStruct $struct */ $struct = $options['data']; foreach ($struct->getFieldsData() as $fieldsDatum) { $builder->add($fieldsDatum->fieldDefinition->identifier, InformationCollectionFieldType::class, [ + //'label' => false, 'languageCode' => $options['languageCode'], 'mainLanguageCode' => $options['mainLanguageCode'], ]); @@ -73,20 +74,21 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->setDataMapper($this); } - public function buildView(FormView $view, FormInterface $form, array $options) + public function buildView(FormView $view, FormInterface $form, array $options): void { $view->vars['languageCode'] = $options['languageCode']; $view->vars['mainLanguageCode'] = $options['mainLanguageCode']; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver - ->setDefaults(['translation_domain' => 'ezplatform_content_forms_content']) - ->setRequired(['languageCode', 'mainLanguageCode']); + ->setRequired(['languageCode', 'mainLanguageCode']) + ->setDefault('translation_domain', 'ezplatform_content_forms_content') + ->setDefault('csrf_protection', $this->configResolver->getParameter('form.use_csrf', 'netgen_information_collection')); } - public function mapDataToForms($viewData, iterable $forms) + public function mapDataToForms($viewData, iterable $forms): void { if (null === $viewData) { return; @@ -104,7 +106,7 @@ public function mapDataToForms($viewData, iterable $forms) } } - public function mapFormsToData(iterable $forms, &$viewData) + public function mapFormsToData(iterable $forms, &$viewData): void { } diff --git a/bundle/EzPlatform/PolicyProvider/InformationCollectionPolicyProvider.php b/bundle/Ibexa/PolicyProvider/InformationCollectionPolicyProvider.php similarity index 55% rename from bundle/EzPlatform/PolicyProvider/InformationCollectionPolicyProvider.php rename to bundle/Ibexa/PolicyProvider/InformationCollectionPolicyProvider.php index 62faa039..20d7ad24 100644 --- a/bundle/EzPlatform/PolicyProvider/InformationCollectionPolicyProvider.php +++ b/bundle/Ibexa/PolicyProvider/InformationCollectionPolicyProvider.php @@ -2,20 +2,15 @@ declare(strict_types=1); -namespace Netgen\Bundle\InformationCollectionBundle\EzPlatform\PolicyProvider; +namespace Netgen\Bundle\InformationCollectionBundle\Ibexa\PolicyProvider; use Netgen\InformationCollection\API\Permissions; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigBuilderInterface; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\ConfigBuilderInterface; +use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface; class InformationCollectionPolicyProvider implements PolicyProviderInterface { - /** - * @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigBuilderInterface $configBuilder - * - * @return array - */ - public function addPolicies(ConfigBuilderInterface $configBuilder) + public function addPolicies(ConfigBuilderInterface $configBuilder): array { $configBuilder->addConfig([ Permissions::NAME => [ diff --git a/bundle/Listener/CaptchaValidationListener.php b/bundle/Listener/CaptchaValidationListener.php index 2e93b1ad..11cfd772 100644 --- a/bundle/Listener/CaptchaValidationListener.php +++ b/bundle/Listener/CaptchaValidationListener.php @@ -15,20 +15,11 @@ class CaptchaValidationListener implements EventSubscriberInterface { - /** - * @var \Symfony\Component\HttpFoundation\RequestStack - */ - private $requestStack; + private RequestStack $requestStack; - /** - * @var \Netgen\InformationCollection\Core\Service\CaptchaService - */ - private $captchaService; + private CaptchaService $captchaService; - /** - * @var \Symfony\Contracts\Translation\TranslatorInterface - */ - private $translator; + private TranslatorInterface $translator; public function __construct(RequestStack $requestStack, CaptchaService $captchaService, TranslatorInterface $translator) { @@ -37,21 +28,24 @@ public function __construct(RequestStack $requestStack, CaptchaService $captchaS $this->translator = $translator; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ FormEvents::POST_SUBMIT => 'onPostSubmit', ]; } - public function onPostSubmit(FormEvent $event) + public function onPostSubmit(FormEvent $event): void { $captchaValue = $event->getForm() ->getConfig() ->getOption('captcha_value'); -// $request = $this->requestStack->getCurrentRequest(); - $request = Request::createFromGlobals(); + $request = $this->requestStack->getCurrentRequest(); +// $request = Request::createFromGlobals(); + + $submittedHostName = $request->getHost(); + $captchaValue->getInnerCaptcha()->setExpectedHostname($submittedHostName); $text = 'The captcha is invalid. Please try again.'; diff --git a/bundle/Listener/InformationCollectedListener.php b/bundle/Listener/InformationCollectedListener.php index 308ee019..44c362be 100644 --- a/bundle/Listener/InformationCollectedListener.php +++ b/bundle/Listener/InformationCollectedListener.php @@ -11,24 +11,13 @@ class InformationCollectedListener implements EventSubscriberInterface { - /** - * @var ActionRegistry - */ - protected $actionAggregate; + protected ActionRegistry $actionAggregate; - /** - * InformationCollectedListener constructor. - * - * @param ActionRegistry $actionAggregate - */ public function __construct(ActionRegistry $actionAggregate) { $this->actionAggregate = $actionAggregate; } - /** - * {@inheritdoc} - */ public static function getSubscribedEvents(): array { return [ @@ -38,8 +27,6 @@ public static function getSubscribedEvents(): array /** * Run all actions. - * - * @param InformationCollected $event */ public function onInformationCollected(InformationCollected $event): void { diff --git a/bundle/NetgenInformationCollectionBundle.php b/bundle/NetgenInformationCollectionBundle.php index 4730b114..b11eaedf 100644 --- a/bundle/NetgenInformationCollectionBundle.php +++ b/bundle/NetgenInformationCollectionBundle.php @@ -2,23 +2,20 @@ namespace Netgen\Bundle\InformationCollectionBundle; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension; -use Netgen\Bundle\InformationCollectionBundle\EzPlatform\PolicyProvider\InformationCollectionPolicyProvider; +use Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension; +use Netgen\Bundle\InformationCollectionBundle\Ibexa\PolicyProvider\InformationCollectionPolicyProvider; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; class NetgenInformationCollectionBundle extends Bundle { - /** - * {@inheritdoc} - */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); - $eZExtension = $container->getExtension('ezpublish'); - if ($eZExtension instanceof EzPublishCoreExtension) { - $eZExtension->addPolicyProvider(new InformationCollectionPolicyProvider()); + $ibexaExtension = $container->getExtension('ibexa'); + if ($ibexaExtension instanceof IbexaCoreExtension) { + $ibexaExtension->addPolicyProvider(new InformationCollectionPolicyProvider()); } } } diff --git a/bundle/ParamConverter/CollectionParamConverter.php b/bundle/ParamConverter/CollectionParamConverter.php index a454dcda..ded5413b 100644 --- a/bundle/ParamConverter/CollectionParamConverter.php +++ b/bundle/ParamConverter/CollectionParamConverter.php @@ -12,10 +12,7 @@ final class CollectionParamConverter implements ParamConverterInterface { - /** - * @var InformationCollection - */ - protected $informationCollection; + protected InformationCollection $informationCollection; public function __construct(InformationCollection $informationCollection) { @@ -24,12 +21,8 @@ public function __construct(InformationCollection $informationCollection) /** * Stores the object in the request. - * - * @param ParamConverter $configuration Contains the name, class and options of the object - * - * @return bool True if the object has been successfully set, else false */ - public function apply(Request $request, ParamConverter $configuration) + public function apply(Request $request, ParamConverter $configuration): bool { if (!$request->attributes->has('collectionId')) { return false; @@ -49,10 +42,8 @@ public function apply(Request $request, ParamConverter $configuration) /** * Checks if the object is supported. - * - * @return bool True if the object is supported, else false */ - public function supports(ParamConverter $configuration) + public function supports(ParamConverter $configuration): bool { return is_a($configuration->getClass(), Collection::class, true); } diff --git a/bundle/Resources/config/controllers.yml b/bundle/Resources/config/controllers.yml index 3d6ddef3..bb45643b 100644 --- a/bundle/Resources/config/controllers.yml +++ b/bundle/Resources/config/controllers.yml @@ -9,20 +9,20 @@ services: netgen_information_collection.controller.admin: class: Netgen\Bundle\InformationCollectionBundle\Controller\Admin\AdminController - parent: ezpublish.controller.base + parent: Ibexa\Core\MVC\Symfony\Controller\Controller public: true arguments: - "@netgen_information_collection.api.service" - "@netgen_information_collection.anonymizer.service" - - "@ezpublish.api.service.content" - - "@ezpublish.config.resolver" + - "@ibexa.api.service.content" + - "@ibexa.config.resolver" - "@translator" netgen_information_collection.controller.export.export: class: Netgen\Bundle\InformationCollectionBundle\Controller\Admin\Export\Export public: true arguments: - - "@ezpublish.api.service.content" + - "@ibexa.api.service.content" - "@netgen_information_collection.service.exporter" - "@netgen_information_collection.core.export.registry" tags: @@ -32,7 +32,7 @@ services: netgen_information_collection.controller.tree: class: Netgen\Bundle\InformationCollectionBundle\Controller\Admin\TreeController - parent: ezpublish.controller.base + parent: Ibexa\Core\MVC\Symfony\Controller\Controller public: true arguments: - "@netgen_information_collection.api.service" diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml index b637a4ec..91036968 100644 --- a/bundle/Resources/config/services.yml +++ b/bundle/Resources/config/services.yml @@ -20,8 +20,8 @@ services: class: Netgen\Bundle\InformationCollectionBundle\DataCollector\InformationCollectionCollector public: false arguments: - - '@ezpublish.api.repository' - - '@ezpublish.translation_helper' + - '@ibexa.api.repository' + - '@Ibexa\Core\Helper\TranslationHelper' tags: - { name: data_collector, template: '@NetgenInformationCollection/data_collector/template.html.twig', id: 'netgen_information_collection_collector' } @@ -32,3 +32,6 @@ services: - '@request_stack' - '@netgen_information_collection.captcha.service' - '@translator' + + Netgen\InformationCollection\API\Service\CaptchaService: + alias: Netgen\InformationCollection\Core\Service\CaptchaService \ No newline at end of file diff --git a/bundle/Resources/config/validation.yml b/bundle/Resources/config/validation.yml index bad9dee8..7e679eac 100644 --- a/bundle/Resources/config/validation.yml +++ b/bundle/Resources/config/validation.yml @@ -1,4 +1,4 @@ -Netgen\InformationCollection\Integration\RepositoryForms\InformationCollectionData: +Netgen\InformationCollection\Integration\ContentForms\InformationCollectionData: properties: fieldsData: - Valid: ~ diff --git a/bundle/Resources/public/admin/css/ezadmin_style.css b/bundle/Resources/public/admin/css/ibexa_admin_style.css similarity index 100% rename from bundle/Resources/public/admin/css/ezadmin_style.css rename to bundle/Resources/public/admin/css/ibexa_admin_style.css diff --git a/bundle/Resources/translations/netgen_information_collection_admin.en.yml b/bundle/Resources/translations/netgen_information_collection_admin.en.yml index 41459350..a59aa6b6 100644 --- a/bundle/Resources/translations/netgen_information_collection_admin.en.yml +++ b/bundle/Resources/translations/netgen_information_collection_admin.en.yml @@ -1,4 +1,7 @@ pagelayout.title: 'Collected information' + +netgen_information_collection_menu_label: 'Information collection' + netgen_information_collection_admin_title: 'Collected information' netgen_information_collection_admin_you_are_here: 'You are here' netgen_information_collection_admin_path_collected_information: 'Collected information' diff --git a/bundle/Resources/views/admin/collection_list.html.twig b/bundle/Resources/views/admin/collection_list.html.twig index 414d884d..a7e2984d 100644 --- a/bundle/Resources/views/admin/collection_list.html.twig +++ b/bundle/Resources/views/admin/collection_list.html.twig @@ -10,7 +10,7 @@ {% include "@NetgenInformationCollection/admin/flash_messages.html.twig" %} -

{{ 'netgen_information_collection_admin_collection_list_title'|trans({'%content_name%': ez_content_name(content), '%count%': objects.count}) }}

+

{{ 'netgen_information_collection_admin_collection_list_title'|trans({'%content_name%': ibexa_content_name(content), '%count%': objects.count}) }}

{% if objects is not empty %} {% set search_text = app.request.query.get('searchText', '') %} @@ -68,7 +68,7 @@ - {{ ez_content_name(object.creator) }} + {{ ibexa_content_name(object.creator) }} {{ object.created|date("Y.m.d H:i") }} diff --git a/bundle/Resources/views/admin/content_fields.html.twig b/bundle/Resources/views/admin/content_fields.html.twig index a35f67be..1d9b0006 100644 --- a/bundle/Resources/views/admin/content_fields.html.twig +++ b/bundle/Resources/views/admin/content_fields.html.twig @@ -10,7 +10,7 @@ {% block ezboolean_field %} {% apply spaceless %} {% set field_value = attribute.value %} - {% if field_value %} + {% if field_value.dataInt %} {{ 'field_value.yes'|trans }} {% else %} {{ 'field_value.no'|trans }} @@ -18,6 +18,14 @@ {% endapply %} {% endblock %} +{% block enhancedezbinaryfile_field %} + {% apply spaceless %} + + Download + + {% endapply %} +{% endblock %} + {% block default_field %} {% apply spaceless %} {{ attribute.value }} diff --git a/bundle/Resources/views/admin/overview.html.twig b/bundle/Resources/views/admin/overview.html.twig index afa2273c..a05d85fe 100644 --- a/bundle/Resources/views/admin/overview.html.twig +++ b/bundle/Resources/views/admin/overview.html.twig @@ -32,8 +32,8 @@ section   - {% if object.hasLocation %}{% endif %} - {{ ez_content_name(object.content) }} + {% if object.hasLocation %}{% endif %} + {{ ibexa_content_name(object.content) }} {% if object.hasLocation %}{% endif %} diff --git a/bundle/Resources/views/admin/path.html.twig b/bundle/Resources/views/admin/path.html.twig index 8ab489c5..a0df48fc 100644 --- a/bundle/Resources/views/admin/path.html.twig +++ b/bundle/Resources/views/admin/path.html.twig @@ -6,11 +6,11 @@ {% if app.request.get('contentId') %} {{ 'netgen_information_collection_admin_path_collected_information'|trans }} / - {{ ez_content_name(content) }} + {{ ibexa_content_name(content) }} {% elseif app.request.get('collectionId') %} {{ 'netgen_information_collection_admin_path_collected_information'|trans }} / - {{ ez_content_name(content) }} + {{ ibexa_content_name(content) }} / {{ collection.id }} {% else %} diff --git a/bundle/Resources/views/admin/view.html.twig b/bundle/Resources/views/admin/view.html.twig index fad83a99..54cf4a85 100644 --- a/bundle/Resources/views/admin/view.html.twig +++ b/bundle/Resources/views/admin/view.html.twig @@ -10,8 +10,8 @@ {% include "@NetgenInformationCollection/admin/flash_messages.html.twig" %} -

{{ 'netgen_information_collection_admin_view_title'|trans({'%collection_id%': collection.id, '%content_name%': ez_content_name(collection.content)}) }}

-
{{ 'netgen_information_collection_admin_view_subtitle'|trans({'%date%': collection.modified|date("Y.m.d H:i"), '%user_name%': ez_content_name(collection.creator)}) }}
+

{{ 'netgen_information_collection_admin_view_title'|trans({'%collection_id%': collection.id, '%content_name%': ibexa_content_name(collection.content)}) }}

+
{{ 'netgen_information_collection_admin_view_subtitle'|trans({'%date%': collection.modified|date("Y.m.d H:i"), '%user_name%': ibexa_content_name(collection.creator)}) }}
@@ -32,7 +32,7 @@