Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: introduce ibexa 4 compatibility #81

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b4316ea
wip: make bundle compatible with ibexa v3
Nov 24, 2021
40f9998
feat: fix ibexa 3 compatibility
Jan 18, 2022
b44dc59
Rename eZ Platform to Ibexa
emodric Feb 23, 2022
d581353
Fix usage of base controller
emodric Feb 23, 2022
1c616e0
EzFormsBundle is not IbexaFormsBundle
emodric Feb 28, 2022
e4aaaca
Fix namespace
emodric Mar 3, 2022
fc742de
Add proper translation for menu item
emodric Mar 4, 2022
3b86f40
Bump PHP CS Fixer to v3
emodric Mar 4, 2022
4a544d6
CS fixes
emodric Mar 4, 2022
18fb23f
Add return and parameter typehints
emodric Mar 4, 2022
d4ca39f
Add property typehints
emodric Mar 4, 2022
5fc27ef
Add missing property typehints
emodric Mar 9, 2022
5c2111a
Remove superfluous typehint due to base property not having it
emodric Mar 9, 2022
2a88fd7
Merge remote-tracking branch 'origin/master' into 3.x
emodric Mar 10, 2022
a3c36c5
CS fixes
emodric Mar 10, 2022
a48513b
Merge branch 'master' into 3.x
emodric Mar 10, 2022
9dd5bbd
Disable isRequired check for info collector fields
emodric Mar 14, 2022
204185c
feat: fix depencency issues
Apr 14, 2022
2af2ecb
feat: default to swiftmailer since swiftmailer is deprecated
Apr 15, 2022
c2ee6cb
feat: remove space that breaks doctrine update schema command
Apr 19, 2022
fbc3778
feat: allow more than ezemail datatype for recipient field
Apr 19, 2022
52b9532
feat: fix default email template
Apr 19, 2022
42a2e14
feat: add basic graphql integration for information collections
Apr 19, 2022
3c764f7
fix: add return types only once
Apr 22, 2022
157f6ba
Implement use_csrf parameter for InformationCollectionType
emodric Jun 8, 2022
3f2cbe5
feat: merge netgen's 3.x branch to ours
Jun 23, 2022
4df5ce7
feat: compatibility with ibexa v4
Jul 11, 2022
88b2a64
feat: fix possible null pointer
Aug 10, 2022
ddcafee
feat: fix exporting collections in the admin backend
Aug 22, 2022
2f65cc5
feat: fix auto_responder action
Jan 3, 2023
54d9726
feat: properly initialize '' array
Jan 12, 2023
3d57022
feat: properly support translated info collection fields
Mar 6, 2023
74d665f
feat: fix displaying correct boolean values in the admin interface
May 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
Expand All @@ -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,
Expand All @@ -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,
])
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------
Expand Down
38 changes: 20 additions & 18 deletions bundle/Command/DataAnonymizerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand All @@ -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.");
Expand All @@ -58,22 +53,26 @@ 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("<error> </error>");
$output->writeln("<error> Missing content-id parameter. </error>");
$output->writeln("<error> </error>");

return $this->displayHelp($input, $output);
$this->displayHelp($input, $output);

return 1;
}

if (is_null($input->getOption('field-identifiers')) && !$input->getOption('all')) {
$output->writeln("<error> </error>");
$output->writeln("<error> Missing field-identifiers parameter. </error>");
$output->writeln("<error> </error>");

return $this->displayHelp($input, $output);
$this->displayHelp($input, $output);

return 1;
}

$contentId = intval($input->getOption('content-id'));
Expand All @@ -87,13 +86,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
$count = $this->anonymizer->anonymize($contentId, $fields, $this->getDateFromPeriod());
$output->writeln("<info>Done.</info>");
$output->writeln("<info>Anonymized #{$count} collections.</info>");

return 0;
}

$output->writeln("<info>Canceled.</info>");

return 0;
}

protected function initialize(InputInterface $input, OutputInterface $output)
protected function initialize(InputInterface $input, OutputInterface $output): void
{
if (!empty($input->getOption('period'))) {

Expand All @@ -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 [];
Expand All @@ -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;
Expand All @@ -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);
Expand Down
103 changes: 20 additions & 83 deletions bundle/Controller/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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]);

Expand All @@ -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(
Expand Down
Loading