@@ -62,7 +62,7 @@
diff --git a/bundle/Resources/views/ezadminui/pagelayout.html.twig b/bundle/Resources/views/ibexa/admin/pagelayout.html.twig
similarity index 89%
rename from bundle/Resources/views/ezadminui/pagelayout.html.twig
rename to bundle/Resources/views/ibexa/admin/pagelayout.html.twig
index f9c78fda..d1ae8cf1 100644
--- a/bundle/Resources/views/ezadminui/pagelayout.html.twig
+++ b/bundle/Resources/views/ibexa/admin/pagelayout.html.twig
@@ -5,7 +5,7 @@
to be able to inject additional markup before and after its
content block.
#}
-{% embed ['@EzPlatformAdminUi/layout.html.twig', '@ezdesign/ui/layout.html.twig'] %}
+{% embed '@ibexadesign/ui/layout.html.twig' %}
{% trans_default_domain 'netgen_information_collection_admin' %}
{% block title %}{{ 'pagelayout.title'|trans }}{% endblock %}
@@ -16,7 +16,7 @@
{{ parent() }}
{% include '@NetgenInformationCollection/admin/stylesheets.html.twig' %}
- {% include '@NetgenInformationCollection/ezadminui/stylesheets.html.twig' %}
+ {% include '@NetgenInformationCollection/ibexa/admin/stylesheets.html.twig' %}
{% endblock %}
{% block javascripts %}
diff --git a/bundle/Resources/views/ezadminui/stylesheets.html.twig b/bundle/Resources/views/ibexa/admin/stylesheets.html.twig
similarity index 55%
rename from bundle/Resources/views/ezadminui/stylesheets.html.twig
rename to bundle/Resources/views/ibexa/admin/stylesheets.html.twig
index f1dae4aa..1f9b3967 100644
--- a/bundle/Resources/views/ezadminui/stylesheets.html.twig
+++ b/bundle/Resources/views/ibexa/admin/stylesheets.html.twig
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/bundle/Templating/Twig/AdminGlobalVariable.php b/bundle/Templating/Twig/AdminGlobalVariable.php
index 0cfcd037..88229fc7 100644
--- a/bundle/Templating/Twig/AdminGlobalVariable.php
+++ b/bundle/Templating/Twig/AdminGlobalVariable.php
@@ -4,19 +4,13 @@
namespace Netgen\Bundle\InformationCollectionBundle\Templating\Twig;
-use eZ\Publish\Core\MVC\ConfigResolverInterface;
+use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
class AdminGlobalVariable
{
- /**
- * @var \eZ\Publish\Core\MVC\ConfigResolverInterface
- */
- protected $configResolver;
+ protected ConfigResolverInterface $configResolver;
- /**
- * @var string|null
- */
- protected $pageLayoutTemplate;
+ protected ?string $pageLayoutTemplate;
public function __construct(ConfigResolverInterface $configResolver)
{
@@ -30,8 +24,6 @@ public function setPageLayoutTemplate(string $pageLayoutTemplate): void
/**
* Returns the pagelayout template.
- *
- * @return string|null
*/
public function getPageLayoutTemplate(): ?string
{
diff --git a/bundle/Templating/Twig/Extensions/CaptchaRuntime.php b/bundle/Templating/Twig/Extensions/CaptchaRuntime.php
index 22e88ed1..c45934cb 100644
--- a/bundle/Templating/Twig/Extensions/CaptchaRuntime.php
+++ b/bundle/Templating/Twig/Extensions/CaptchaRuntime.php
@@ -4,21 +4,13 @@
namespace Netgen\Bundle\InformationCollectionBundle\Templating\Twig\Extensions;
-use eZ\Publish\API\Repository\Values\Content\Location;
+use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Netgen\InformationCollection\API\Service\CaptchaService;
class CaptchaRuntime
{
- /**
- * @var \Netgen\InformationCollection\API\Service\CaptchaService
- */
- protected $captcha;
+ protected CaptchaService $captcha;
- /**
- * CaptchaRuntime constructor.
- *
- * @param \Netgen\InformationCollection\API\Service\CaptchaService $captcha
- */
public function __construct(CaptchaService $captcha)
{
$this->captcha = $captcha;
@@ -26,10 +18,6 @@ public function __construct(CaptchaService $captcha)
/**
* Checks if captcha is enabled for given Location.
- *
- * @param \eZ\Publish\API\Repository\Values\Content\Location $location
- *
- * @return bool
*/
public function isEnabled(Location $location): bool
{
@@ -38,10 +26,6 @@ public function isEnabled(Location $location): bool
/**
* Return configured site key for given Location.
- *
- * @param \eZ\Publish\API\Repository\Values\Content\Location $location
- *
- * @return string
*/
public function getSiteKey(Location $location): string
{
diff --git a/bundle/Templating/Twig/Extensions/FieldRenderingRuntime.php b/bundle/Templating/Twig/Extensions/FieldRenderingRuntime.php
index fac7568f..71c955c7 100644
--- a/bundle/Templating/Twig/Extensions/FieldRenderingRuntime.php
+++ b/bundle/Templating/Twig/Extensions/FieldRenderingRuntime.php
@@ -4,7 +4,7 @@
namespace Netgen\Bundle\InformationCollectionBundle\Templating\Twig\Extensions;
-use eZ\Publish\Core\MVC\ConfigResolverInterface;
+use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Netgen\InformationCollection\API\Value\Attribute;
use Netgen\InformationCollection\API\Value\Collection;
use Twig\Environment;
@@ -14,15 +14,9 @@ class FieldRenderingRuntime
{
public const FIELD_VIEW_SUFFIX = '_field';
- /**
- * @var \Twig\Environment
- */
- protected $environment;
+ protected Environment $environment;
- /**
- * @var \eZ\Publish\Core\MVC\ConfigResolverInterface
- */
- protected $configResolver;
+ protected ConfigResolverInterface $configResolver;
public function __construct(Environment $environment, ConfigResolverInterface $configResolver)
{
diff --git a/composer.json b/composer.json
index 4443ad91..de734570 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,9 @@
{
"name": "netgen/information-collection-bundle",
- "description": "Information collection alike feature for eZ Platform",
- "type": "ezplatform-bundle",
+ "description": "Information collection alike feature for Ibexa Platform",
+ "type": "ibexa-bundle",
"keywords": [
- "ezpublish",
- "ezplatform",
+ "ibexa",
"information collection",
"netgen",
"information-collection-bundle"
@@ -24,12 +23,12 @@
}
],
"require": {
- "php": "^7.3",
+ "php": "^7.4 || ^8.0",
"ext-pdo": "*",
"doctrine/orm": "^2.5",
- "ezsystems/ezplatform-admin-ui": "^2.0",
- "ezsystems/ezplatform-content-forms": "^1.0",
- "ezsystems/ezplatform-kernel": "^1.0",
+ "ibexa/admin-ui": "^4.0",
+ "ibexa/content-forms": "^4.0",
+ "ibexa/core": "^4.0",
"symfony/swiftmailer-bundle": "^3.4",
"twig/twig": "^3.0",
"google/recaptcha": "^1.2",
@@ -41,7 +40,7 @@
"phpunit/phpunit": "^8.2",
"matthiasnoback/symfony-config-test": "~4.0",
"matthiasnoback/symfony-dependency-injection-test": "~4.0",
- "friendsofphp/php-cs-fixer": "^2.16"
+ "friendsofphp/php-cs-fixer": "^3.3"
},
"autoload": {
"psr-4": {
@@ -67,7 +66,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "2.0.x-dev"
+ "dev-feat-ibexa-4-compatibility": "3.0.x-dev"
}
}
}
diff --git a/doc/cookbook/custom_action.rst b/doc/cookbook/custom_action.rst
index 63a2ce99..81d2b13a 100644
--- a/doc/cookbook/custom_action.rst
+++ b/doc/cookbook/custom_action.rst
@@ -18,11 +18,7 @@ Action example:
class CustomAction implements ActionInterface
{
-
- /**
- * @inheritDoc
- */
- public function act(InformationCollected $event)
+ public function act(InformationCollected $event): void
{
// do some magic ...
}
diff --git a/doc/cookbook/custom_field_handler.rst b/doc/cookbook/custom_field_handler.rst
index 93900fa6..1e71eb53 100644
--- a/doc/cookbook/custom_field_handler.rst
+++ b/doc/cookbook/custom_field_handler.rst
@@ -16,24 +16,18 @@ Field handler example:
namespace Acme\Bundle\AcmeBundle\MyCustomFieldHandlers;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomFieldHandlerInterface;
- use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
- use eZ\Publish\Core\FieldType\Value;
- use eZ\Publish\Core\FieldType\Integer\Value as IntegerValue;
+ use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+ use Ibexa\Core\FieldType\Value;
+ use Ibexa\Core\FieldType\Integer\Value as IntegerValue;
class IntegerFieldHandler implements CustomFieldHandlerInterface
{
- /**
- * @inheritdoc
- */
- public function supports(Value $value)
+ public function supports(Value $value): bool
{
return $value instanceof IntegerValue;
}
- /**
- * @inheritdoc
- */
- public function toString(Value $value, FieldDefinition $fieldDefinition)
+ public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
// do some magic ..
}
diff --git a/doc/cookbook/override_something_on_form.rst b/doc/cookbook/override_something_on_form.rst
index 94d31f4b..4e266eee 100644
--- a/doc/cookbook/override_something_on_form.rst
+++ b/doc/cookbook/override_something_on_form.rst
@@ -10,7 +10,7 @@ How to override something on info collector form
namespace Acme\Form;
use Acme\Validator\Constraints\MyValidator;
- use Netgen\Bundle\EzFormsBundle\Form\Type\InformationCollectionType;
+ use Netgen\Bundle\IbexaFormsBundle\Form\Type\InformationCollectionType;
use Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentValueView;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -20,10 +20,7 @@ How to override something on info collector form
final class InvoiceNumberFormExtension extends AbstractTypeExtension
{
- /**
- * @var \Symfony\Component\HttpFoundation\RequestStack
- */
- private $requestStack;
+ private RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
{
@@ -66,4 +63,4 @@ How to override something on info collector form
arguments:
- '@request_stack'
tags:
- - { name: form.type_extension, extended_type: Netgen\Bundle\EzFormsBundle\Form\Type\InformationCollectionType }
+ - { name: form.type_extension, extended_type: Netgen\Bundle\IbexaFormsBundle\Form\Type\InformationCollectionType }
diff --git a/doc/getting_started/configuration.rst b/doc/getting_started/configuration.rst
index cd823a28..137015f9 100644
--- a/doc/getting_started/configuration.rst
+++ b/doc/getting_started/configuration.rst
@@ -5,7 +5,7 @@ Set siteaccess aware configuration
----------------------------------
Here is sample configuration for actions, the developer will need to define a list of actions to be run depending on the content type.
-Configuration needs to be added in `app/config/config.yml` or `app/config/ezplatform.yml`:
+Configuration needs to be added to your `config/packages/` folder:
.. code-block:: yaml
@@ -31,7 +31,7 @@ Don't forget to create default email template.
Clear the caches
----------------
-Clear the eZ Publish caches with the following command:
+Clear the Ibexa Platform caches with the following command:
.. code-block:: bash
diff --git a/doc/getting_started/installation.rst b/doc/getting_started/installation.rst
index a96d9beb..e0445a91 100644
--- a/doc/getting_started/installation.rst
+++ b/doc/getting_started/installation.rst
@@ -4,8 +4,8 @@ Installation instructions
Requirements
------------
-* PHP 7.3+
-* eZ Platform 2.0+
+* PHP 7.4+
+* Ibexa Platform 4.0+
Installation steps
------------------
@@ -20,29 +20,10 @@ Run the following from your website root folder to install NetgenInformationColl
$ composer require netgen/information-collection-bundle
-
-Activate the bundle
-~~~~~~~~~~~~~~~~~~~
-
-Activate required bundles in `app/AppKernel.php` file by adding them to the `$bundles` array in `registerBundles` method:
-
-.. code-block:: php
-
- public function registerBundles()
- {
- ...
- $bundles[] = new Netgen\Bundle\EzFormsBundle\NetgenEzFormsBundle();
- $bundles[] = new Netgen\Bundle\InformationCollectionBundle\NetgenInformationCollectionBundle();
-
- return $bundles;
- }
-
-
Include routing configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-In your main routing configuration file probably `routing.yml` add:
+In your `config/routes` folder add:
.. code-block:: yaml
diff --git a/doc/index.rst b/doc/index.rst
index 75c5fe78..1c1b1fc8 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -14,17 +14,17 @@ When the object is viewed, each collector attribute will be displayed using the
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.
-This bundle re-implements the information collection feature for eZ Platform/Ibexa stack.
+This bundle re-implements the information collection feature for Ibexa Platform stack.
.. note::
This documentation assumes you have a working knowledge of the Symfony
- Framework and eZ Platform DXP. If you're not familiar with Symfony, please start with
- reading the `Quick Tour`_ from the Symfony documentation and for eZ Platform DXP visit the eZ
+ Framework and Ibexa Platform DXP. If you're not familiar with Symfony, please start with
+ reading the `Quick Tour`_ from the Symfony documentation and for Ibexa Platform DXP visit the Ibexa
Platform `Developer Documentation`_.
.. _`Quick Tour`: https://symfony.com/doc/current/quick_tour
-.. _`Developer Documentation`: https://doc.ezplatform.com/
+.. _`Developer Documentation`: https://doc.ibexa.co
:doc:`Overview `
diff --git a/doc/overview/how_it_works.rst b/doc/overview/how_it_works.rst
index 0503cbc6..96884a85 100644
--- a/doc/overview/how_it_works.rst
+++ b/doc/overview/how_it_works.rst
@@ -14,7 +14,7 @@ Then define content view for given content type (*content_view.yml*) specifiying
.. code-block:: yaml
- ezpublish:
+ ibexa:
system:
frontend_group:
content_view:
@@ -26,7 +26,7 @@ Then define content view for given content type (*content_view.yml*) specifiying
Identifier\ContentType: my_content_type
-Controller will return standard eZ ContentView with additional two variables *form* and *is_valid*. *form* contains Symfony form and it is up
+Controller will return standard Ibexa ContentView with additional two variables *form* and *is_valid*. *form* contains Symfony form and it is up
to you it will be rendered and *is_valid* signals when form is valid and submitted.
Example template:
@@ -41,25 +41,25 @@ Example template:
{% if is_valid is defined and is_valid %}
- {% if not ez_is_field_empty( content, "success_text" ) %}
+ {% if not ibexa_field_is_empty( content, "success_text" ) %}
- {{ ez_render_field( content, "success_text" ) }}
+ {{ ibexa_render_field( content, "success_text" ) }}
{% endif %}
{% else %}
-
+
- {% if not ez_is_field_empty( content, "full_intro" ) %}
+ {% if not ibexa_field_is_empty( content, "full_intro" ) %}
- {{ ez_render_field( content, "full_intro" ) }}
+ {{ ibexa_render_field( content, "full_intro" ) }}
{% endif %}
- {% if not ez_is_field_empty( content, "body" ) %}
+ {% if not ibexa_field_is_empty( content, "body" ) %}
- {{ ez_render_field( content, "body" ) }}
+ {{ ibexa_render_field( content, "body" ) }}
{% endif %}
diff --git a/doc/reference/configuration.rst b/doc/reference/configuration.rst
index 7d672bd5..44355ab0 100644
--- a/doc/reference/configuration.rst
+++ b/doc/reference/configuration.rst
@@ -252,7 +252,7 @@ The following lists all available design configuration options:
.. tip::
- In eZ Platform integration, currently active design is siteaccess aware,
+ In Ibexa Platform integration, currently active design is siteaccess aware,
meaning, you can use configuration similar to this:
.. code-block:: yaml
diff --git a/doc/reference/container_parameters.rst b/doc/reference/container_parameters.rst
index 6aea87f2..f407652b 100644
--- a/doc/reference/container_parameters.rst
+++ b/doc/reference/container_parameters.rst
@@ -5,7 +5,5 @@ Available Container parameters:
- `netgen_information_collection.default.admin.max_per_page` - controls how many items will be displayed per page
- `netgen_information_collection.default.form.use_csrf` - controls whenever will CSRF token be used on forms or not
-- `netgen_information_collection.ezadminui.pagelayout` - controls which template will be used for admin pagelayout
-- `netgen_information_collection.default.admin.tree_limit` - controls which template will be used for admin pagelayout
+- `netgen_information_collection.default.admin.tree_limit` - controls how many items will be displayed in the tree
- `netgen_information_collection.default.admin.pagelayout` - controls which template will be used for admin pagelayout
-- `netgen_information_collection.ezadminui.pagelayout` - controls which template will be used for admin pagelayout
diff --git a/doc/reference/ez_policies.rst b/doc/reference/ibexa_policies.rst
similarity index 88%
rename from doc/reference/ez_policies.rst
rename to doc/reference/ibexa_policies.rst
index 13f8f6cd..7c66c288 100644
--- a/doc/reference/ez_policies.rst
+++ b/doc/reference/ibexa_policies.rst
@@ -1,5 +1,5 @@
-eZ Platform Policies
-====================
+Ibexa Platform Policies
+=======================
The following is a list of Symfony commands available in Netgen Layouts used for
exporting/importing Netgen Layouts data.
@@ -7,12 +7,12 @@ exporting/importing Netgen Layouts data.
.. note::
This documentation assumes you have a working knowledge of the Symfony
- Framework and eZ Platform DXP. If you're not familiar with Symfony, please start with
- reading the `Quick Tour`_ from the Symfony documentation and for eZ Platform DXP visit the eZ
+ Framework and Ibexa Platform DXP. If you're not familiar with Symfony, please start with
+ reading the `Quick Tour`_ from the Symfony documentation and for Ibexa Platform DXP visit the Ibexa
Platform `Developer Documentation`_.
.. _`Quick Tour`: https://symfony.com/doc/current/quick_tour
-.. _`Developer Documentation`: https://doc.ezplatform.com/
+.. _`Developer Documentation`: https://doc.ibexa.co
.. rst-class:: responsive
diff --git a/doc/reference/index.rst b/doc/reference/index.rst
index e0895222..41c55504 100644
--- a/doc/reference/index.rst
+++ b/doc/reference/index.rst
@@ -10,7 +10,7 @@ Reference
events
configuration
commands
- ez_policies
+ ibexa_policies
info_collector_actions
diff --git a/doc/reference/info_collector_actions.rst b/doc/reference/info_collector_actions.rst
index fb465aa8..862e031f 100644
--- a/doc/reference/info_collector_actions.rst
+++ b/doc/reference/info_collector_actions.rst
@@ -42,7 +42,7 @@ Some simple email template would look like this:
{% for field_name, field_value in collected_fields %}
{% if content.fields[field_name] is defined and content.fields[field_name] is not empty %}
- {{ ez_field_name(content, field_name) }}:
+ {{ ibexa_field_name(content, field_name) }}:
{{ field_value }}
diff --git a/doc/reference/map.rst.inc b/doc/reference/map.rst.inc
index 003e85cb..bbab5d1d 100644
--- a/doc/reference/map.rst.inc
+++ b/doc/reference/map.rst.inc
@@ -4,5 +4,5 @@
* :doc:`/reference/events`
* :doc:`/reference/configuration`
* :doc:`/reference/commands`
-* :doc:`/reference/ez_policies`
+* :doc:`/reference/ibexa_policies`
* :doc:`/reference/info_collector_actions`
diff --git a/lib/API/Action/ActionInterface.php b/lib/API/Action/ActionInterface.php
index 86da3913..192822e3 100644
--- a/lib/API/Action/ActionInterface.php
+++ b/lib/API/Action/ActionInterface.php
@@ -11,8 +11,6 @@ interface ActionInterface
/**
* Act on InformationCollected event.
*
- * @param \Netgen\InformationCollection\API\Value\Event\InformationCollected $event
- *
* @throws \Netgen\InformationCollection\API\Exception\ActionFailedException
*/
public function act(InformationCollected $event): void;
diff --git a/lib/API/Action/EmailDataProviderInterface.php b/lib/API/Action/EmailDataProviderInterface.php
index ecd2c932..76400e81 100644
--- a/lib/API/Action/EmailDataProviderInterface.php
+++ b/lib/API/Action/EmailDataProviderInterface.php
@@ -1,5 +1,7 @@
container->get('netgen_information_collection.handler');
+
/** @var RequestStack $requestStack */
$requestStack = $this->container->get('request_stack');
diff --git a/lib/API/MailerInterface.php b/lib/API/MailerInterface.php
index 0fd7c3a7..c575c20a 100644
--- a/lib/API/MailerInterface.php
+++ b/lib/API/MailerInterface.php
@@ -11,8 +11,6 @@ interface MailerInterface
/**
* Sends email message.
*
- * @param \Symfony\Component\Mime\Email $content
- *
* @throws \Netgen\InformationCollection\API\Exception\EmailNotSentException
*/
public function sendEmail(Email $content): void;
diff --git a/lib/API/Permissions.php b/lib/API/Permissions.php
index 1b429076..b4d6d79d 100644
--- a/lib/API/Permissions.php
+++ b/lib/API/Permissions.php
@@ -1,5 +1,7 @@
value = $value;
}
- public static function createFromAttributeAndValue(Attribute $attribute, AttributeValue $attributeValue)
+ public static function createFromAttributeAndValue(self $attribute, AttributeValue $attributeValue): self
{
return new self($attribute->getId(), $attribute->getField(), $attribute->getFieldDefinition(), $attributeValue);
}
- /**
- * @return Field
- */
public function getField(): Field
{
return $this->field;
}
- /**
- * @return FieldDefinition
- */
public function getFieldDefinition(): FieldDefinition
{
return $this->fieldDefinition;
}
- /**
- * @return int
- */
public function getId(): int
{
return $this->id;
}
- /**
- * @return AttributeValue
- */
public function getValue(): AttributeValue
{
return $this->value;
diff --git a/lib/API/Value/AttributeValue.php b/lib/API/Value/AttributeValue.php
index 9f8c32e8..66bd5a9b 100644
--- a/lib/API/Value/AttributeValue.php
+++ b/lib/API/Value/AttributeValue.php
@@ -6,20 +6,11 @@
class AttributeValue extends ValueObject
{
- /**
- * @var int
- */
- protected $dataInt;
+ protected int $dataInt;
- /**
- * @var float
- */
- protected $dataFloat;
+ protected float $dataFloat;
- /**
- * @var string
- */
- protected $dataText;
+ protected string $dataText;
public function __construct(int $dataInt, float $dataFloat, string $dataText)
{
@@ -28,42 +19,33 @@ public function __construct(int $dataInt, float $dataFloat, string $dataText)
$this->dataText = $dataText;
}
- public function __toString()
+ public function __toString(): string
{
if (!empty($this->dataText)) {
return $this->dataText;
}
if (!empty($this->dataInt)) {
- return (string)$this->dataInt;
+ return (string) $this->dataInt;
}
if (!empty($this->dataFloat)) {
- return (string)$this->dataFloat;
+ return (string) $this->dataFloat;
}
return '';
}
- /**
- * @return int
- */
public function getDataInt(): int
{
return $this->dataInt;
}
- /**
- * @return float
- */
public function getDataFloat(): float
{
return $this->dataFloat;
}
- /**
- * @return string
- */
public function getDataText(): string
{
return $this->dataText;
diff --git a/lib/API/Value/Captcha/NullObject.php b/lib/API/Value/Captcha/NullObject.php
index 178a1490..a92297c4 100644
--- a/lib/API/Value/Captcha/NullObject.php
+++ b/lib/API/Value/Captcha/NullObject.php
@@ -9,9 +9,6 @@
class NullObject implements CaptchaValue
{
- /**
- * {@inheritdoc}
- */
public function isValid(Request $request): bool
{
return true;
diff --git a/lib/API/Value/Captcha/ReCaptcha.php b/lib/API/Value/Captcha/ReCaptcha.php
index 399c6d03..de454a0c 100644
--- a/lib/API/Value/Captcha/ReCaptcha.php
+++ b/lib/API/Value/Captcha/ReCaptcha.php
@@ -7,27 +7,17 @@
use Netgen\InformationCollection\API\Service\CaptchaValue;
use ReCaptcha\ReCaptcha as BaseReCaptcha;
use Symfony\Component\HttpFoundation\Request;
+use function dump;
class ReCaptcha implements CaptchaValue
{
- /**
- * @var \ReCaptcha\ReCaptcha
- */
- protected $reCaptcha;
+ protected BaseReCaptcha $reCaptcha;
- /**
- * ReCaptcha constructor.
- *
- * @param \ReCaptcha\ReCaptcha $reCaptcha
- */
public function __construct(BaseReCaptcha $reCaptcha)
{
$this->reCaptcha = $reCaptcha;
}
- /**
- * {@inheritdoc}
- */
public function isValid(Request $request): bool
{
$clientIp = $request->getClientIp() === '::1' ? 'localhost' : $request->getClientIp();
@@ -37,15 +27,11 @@ public function isValid(Request $request): bool
$clientIp
);
- dump($response);
-
return $response->isSuccess();
}
/**
* Returns aggregated captcha implementation.
- *
- * @return \ReCaptcha\ReCaptcha
*/
public function getInnerCaptcha(): BaseReCaptcha
{
diff --git a/lib/API/Value/Collection.php b/lib/API/Value/Collection.php
index 04c0c0aa..975f6789 100644
--- a/lib/API/Value/Collection.php
+++ b/lib/API/Value/Collection.php
@@ -5,40 +5,25 @@
namespace Netgen\InformationCollection\API\Value;
use DateTimeInterface;
-use eZ\Publish\API\Repository\Values\Content\Content;
-use eZ\Publish\API\Repository\Values\User\User;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\User\User;
final class Collection extends ValueObject
{
- /**
- * @var int
- */
- protected $id;
+ protected int $id;
- /**
- * @var \eZ\Publish\API\Repository\Values\Content\Content
- */
- protected $content;
+ protected Content $content;
- /**
- * @var \eZ\Publish\API\Repository\Values\User\User
- */
- protected $creator;
+ protected User $creator;
- /**
- * @var \DateTimeInterface
- */
- protected $created;
+ protected DateTimeInterface $created;
- /**
- * @var \DateTimeInterface
- */
- protected $modified;
+ protected DateTimeInterface $modified;
/**
* @var \Netgen\InformationCollection\API\Value\Attribute[]
*/
- protected $attributes;
+ protected array $attributes;
public function __construct(int $id, Content $content, User $creator, DateTimeInterface $created, DateTimeInterface $modified, array $attributes)
{
@@ -50,48 +35,33 @@ public function __construct(int $id, Content $content, User $creator, DateTimeIn
$this->attributes = $attributes;
}
- /**
- * @return int
- */
public function getId(): int
{
return $this->id;
}
- /**
- * @return Content
- */
public function getContent(): Content
{
return $this->content;
}
- /**
- * @return User
- */
public function getCreator(): User
{
return $this->creator;
}
- /**
- * @return \DateTimeInterface
- */
public function getCreated(): DateTimeInterface
{
return $this->created;
}
- /**
- * @return \DateTimeInterface
- */
public function getModified(): DateTimeInterface
{
return $this->modified;
}
/**
- * @return Attribute[]
+ * @return \Netgen\InformationCollection\API\Value\Attribute[]
*/
public function getAttributes(): array
{
diff --git a/lib/API/Value/Collections.php b/lib/API/Value/Collections.php
index aba5dbfb..4a8bb7f1 100644
--- a/lib/API/Value/Collections.php
+++ b/lib/API/Value/Collections.php
@@ -9,12 +9,9 @@ class Collections extends ValueObject
/**
* @var \Netgen\InformationCollection\API\Value\Collection[]
*/
- protected $collections;
+ protected array $collections;
- /**
- * @var int
- */
- protected $count;
+ protected int $count;
public function __construct(array $collections, int $count)
{
@@ -30,9 +27,6 @@ public function getCollections(): array
return $this->collections;
}
- /**
- * @return int
- */
public function getCount(): int
{
return $this->count;
diff --git a/lib/API/Value/Content.php b/lib/API/Value/Content.php
index 9e350e8a..c4875090 100644
--- a/lib/API/Value/Content.php
+++ b/lib/API/Value/Content.php
@@ -4,40 +4,22 @@
namespace Netgen\InformationCollection\API\Value;
-use eZ\Publish\API\Repository\Values\Content\Content as APIContent;
-use eZ\Publish\API\Repository\Values\ContentType\ContentType;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content as APIContent;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
final class Content extends ValueObject
{
- /**
- * @var bool
- */
- protected $hasLocation;
-
- /**
- * @var APIContent
- */
- protected $content;
-
- /**
- * @var ContentType
- */
- protected $contentType;
-
- /**
- * @var Collection
- */
- protected $firstCollection;
-
- /**
- * @var Collection
- */
- protected $lastCollection;
-
- /**
- * @var int
- */
- protected $childCount;
+ protected bool $hasLocation;
+
+ protected APIContent $content;
+
+ protected ContentType $contentType;
+
+ protected Collection $firstCollection;
+
+ protected Collection $lastCollection;
+
+ protected int $childCount;
public function __construct(
APIContent $content,
@@ -55,49 +37,31 @@ public function __construct(
$this->childCount = $childCount;
}
- /**
- * @return APIContent
- */
public function getContent(): APIContent
{
return $this->content;
}
- /**
- * @return ContentType
- */
public function getContentType(): ContentType
{
return $this->contentType;
}
- /**
- * @return Collection
- */
public function getFirstCollection(): Collection
{
return $this->firstCollection;
}
- /**
- * @return Collection
- */
public function getLastCollection(): Collection
{
return $this->lastCollection;
}
- /**
- * @return int
- */
public function getCount(): int
{
return $this->childCount;
}
- /**
- * @return bool
- */
public function hasLocation(): bool
{
return $this->hasLocation;
diff --git a/lib/API/Value/ContentsWithCollections.php b/lib/API/Value/ContentsWithCollections.php
index 353ec003..49cd39b8 100644
--- a/lib/API/Value/ContentsWithCollections.php
+++ b/lib/API/Value/ContentsWithCollections.php
@@ -9,12 +9,9 @@ class ContentsWithCollections extends ValueObject
/**
* @var \Netgen\InformationCollection\API\Value\Content[]
*/
- protected $contents;
+ protected array $contents;
- /**
- * @var int
- */
- protected $count;
+ protected int $count;
public function __construct(array $contents, int $count)
{
@@ -30,9 +27,6 @@ public function getContents(): array
return $this->contents;
}
- /**
- * @return int
- */
public function getCount(): int
{
return $this->count;
diff --git a/lib/API/Value/DataTransfer/AdditionalContent.php b/lib/API/Value/DataTransfer/AdditionalContent.php
index a54c674f..c2817307 100644
--- a/lib/API/Value/DataTransfer/AdditionalContent.php
+++ b/lib/API/Value/DataTransfer/AdditionalContent.php
@@ -4,29 +4,18 @@
namespace Netgen\InformationCollection\API\Value\DataTransfer;
-use eZ\Publish\API\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Netgen\InformationCollection\API\Value\ValueObject;
class AdditionalContent extends ValueObject
{
- /**
- * @var \eZ\Publish\API\Repository\Values\Content\Content|null
- */
- protected $content;
+ protected ?Content $content;
- /**
- * AdditionalContent constructor.
- *
- * @param Content|null $content
- */
public function __construct(?Content $content = null)
{
$this->content = $content;
}
- /**
- * @return \eZ\Publish\API\Repository\Values\Content\Content|null
- */
public function getContent(): ?Content
{
return $this->content;
diff --git a/lib/API/Value/DataTransfer/EmailContent.php b/lib/API/Value/DataTransfer/EmailContent.php
index 4f365750..ff6b74a2 100644
--- a/lib/API/Value/DataTransfer/EmailContent.php
+++ b/lib/API/Value/DataTransfer/EmailContent.php
@@ -4,44 +4,25 @@
namespace Netgen\InformationCollection\API\Value\DataTransfer;
-use eZ\Publish\Core\FieldType\BinaryFile\Value as BinaryFile;
use Netgen\InformationCollection\API\Value\ValueObject;
class EmailContent extends ValueObject
{
- /**
- * @var array
- */
- protected $recipients;
+ protected array $recipients;
- /**
- * @var string
- */
- protected $subject;
+ protected string $subject;
- /**
- * @var array
- */
- protected $sender;
+ protected array $sender;
- /**
- * @var string
- */
- protected $body;
+ protected string $body;
/**
- * @var BinaryFile[]
+ * @var \Ibexa\Core\FieldType\BinaryFile\Value[]
*/
- protected $attachments = [];
+ protected array $attachments = [];
/**
- * EmailData constructor.
- *
- * @param array $recipients
- * @param array $sender
- * @param string $subject
- * @param string $body
- * @param BinaryFile[] $attachments
+ * @param \Ibexa\Core\FieldType\BinaryFile\Value[] $attachments
*/
public function __construct(array $recipients, array $sender, string $subject, string $body, array $attachments = [])
{
@@ -52,48 +33,33 @@ public function __construct(array $recipients, array $sender, string $subject, s
$this->attachments = $attachments;
}
- /**
- * @return array
- */
public function getRecipients(): array
{
return $this->recipients;
}
- /**
- * @return string
- */
public function getSubject(): string
{
return $this->subject;
}
- /**
- * @return array
- */
public function getSender(): array
{
return $this->sender;
}
- /**
- * @return string
- */
public function getBody(): string
{
return $this->body;
}
- /**
- * @return bool
- */
public function hasAttachments(): bool
{
return !empty($this->attachments);
}
/**
- * @return BinaryFile[]
+ * @return \Ibexa\Core\FieldType\BinaryFile\Value[]
*/
public function getAttachments(): array
{
diff --git a/lib/API/Value/DataTransfer/TemplateContent.php b/lib/API/Value/DataTransfer/TemplateContent.php
index bd05dc5f..68a62086 100644
--- a/lib/API/Value/DataTransfer/TemplateContent.php
+++ b/lib/API/Value/DataTransfer/TemplateContent.php
@@ -4,54 +4,33 @@
namespace Netgen\InformationCollection\API\Value\DataTransfer;
-use eZ\Publish\API\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
use Netgen\InformationCollection\API\Value\ValueObject;
use Twig\TemplateWrapper;
class TemplateContent extends ValueObject
{
- /**
- * @var \Netgen\InformationCollection\API\Value\Event\InformationCollected
- */
- protected $event;
-
- /**
- * @var \Twig\TemplateWrapper
- */
- protected $templateWrapper;
-
- /**
- * TemplateData constructor.
- *
- * @param \Netgen\InformationCollection\API\Value\Event\InformationCollected $event
- * @param \Twig\TemplateWrapper $templateWrapper
- */
+ protected InformationCollected $event;
+
+ protected TemplateWrapper $templateWrapper;
+
public function __construct(InformationCollected $event, TemplateWrapper $templateWrapper)
{
$this->event = $event;
$this->templateWrapper = $templateWrapper;
}
- /**
- * @return \Netgen\InformationCollection\API\Value\Event\InformationCollected
- */
public function getEvent(): InformationCollected
{
return $this->event;
}
- /**
- * @return \eZ\Publish\API\Repository\Values\Content\Content
- */
public function getContent(): Content
{
return $this->event->getContent();
}
- /**
- * @return \Twig\TemplateWrapper
- */
public function getTemplateWrapper(): TemplateWrapper
{
return $this->templateWrapper;
diff --git a/lib/API/Value/Event/InformationCollected.php b/lib/API/Value/Event/InformationCollected.php
index 76124519..37382df0 100644
--- a/lib/API/Value/Event/InformationCollected.php
+++ b/lib/API/Value/Event/InformationCollected.php
@@ -4,44 +4,23 @@
namespace Netgen\InformationCollection\API\Value\Event;
-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\Content\ContentInfo;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
+use Ibexa\Contracts\Core\Repository\Values\Content\Location;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Netgen\InformationCollection\API\Exception\MissingAdditionalParameterException;
use Netgen\InformationCollection\API\Value\InformationCollectionStruct;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
use function array_key_exists;
final class InformationCollected extends Event
{
- /**
- * @var \Netgen\InformationCollection\API\Value\InformationCollectionStruct
- */
- protected $struct;
+ protected InformationCollectionStruct $struct;
- /**
- * @var array
- */
- protected $options;
-
- /**
- * @var \eZ\Publish\API\Repository\Values\Content\Location
- */
- protected $location;
+ protected array $options;
- /**
- * @var array
- */
- protected $additionalParameters;
+ protected array $additionalParameters;
- /**
- * InformationCollected constructor.
- *
- * @param \Netgen\InformationCollection\API\Value\InformationCollectionStruct $struct
- * @param array $options
- * @param array $additionalParameters
- */
public function __construct(
InformationCollectionStruct $struct,
array $options,
@@ -54,8 +33,6 @@ public function __construct(
/**
* Return collected data.
- *
- * @return \Netgen\InformationCollection\API\Value\InformationCollectionStruct
*/
public function getInformationCollectionStruct(): InformationCollectionStruct
{
@@ -64,8 +41,6 @@ public function getInformationCollectionStruct(): InformationCollectionStruct
/**
* Return ContentType.
- *
- * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
*/
public function getContentType(): ContentType
{
@@ -75,8 +50,6 @@ public function getContentType(): ContentType
/**
* Return Location.
- *
- * @return \eZ\Publish\API\Repository\Values\Content\Content
*/
public function getContent(): Content
{
@@ -84,9 +57,6 @@ public function getContent(): Content
->getContent();
}
- /**
- * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
- */
public function getContentInfo(): ContentInfo
{
return $this->struct
@@ -94,9 +64,6 @@ public function getContentInfo(): ContentInfo
->contentInfo;
}
- /**
- * @return \eZ\Publish\API\Repository\Values\Content\Location
- */
public function getLocation(): Location
{
return $this->struct
@@ -104,9 +71,7 @@ public function getLocation(): Location
}
/**
- * Returns options
- *
- * @return array
+ * Returns options.
*/
public function getOptions(): array
{
@@ -114,9 +79,7 @@ public function getOptions(): array
}
/**
- * Returns additional parameters
- *
- * @return array
+ * Returns additional parameters.
*/
public function getAdditionalParameters(): array
{
@@ -124,11 +87,7 @@ public function getAdditionalParameters(): array
}
/**
- * Sets additional parameters
- *
- * @param array $additionalParameters
- *
- * @return self
+ * Sets additional parameters.
*/
public function setAdditionalParameters(array $additionalParameters): self
{
@@ -138,13 +97,9 @@ public function setAdditionalParameters(array $additionalParameters): self
}
/**
- * Sets additional parameter value
- *
- * @param string $key
+ * Sets additional parameter value.
*
* @param mixed $value
- *
- * @return self
*/
public function setAdditionalParameter(string $key, $value): self
{
@@ -154,17 +109,15 @@ public function setAdditionalParameter(string $key, $value): self
}
/**
- * Gets additional parameter value
+ * Gets additional parameter value.
*
- * @param string $key
+ * @throws \Netgen\InformationCollection\API\Exception\MissingAdditionalParameterException
*
* @return mixed
- *
- * @throws \Netgen\InformationCollection\API\Exception\MissingAdditionalParameterException
*/
public function getAdditionalParameter(string $key)
{
- if (!array_key_exists($key , $this->additionalParameters)) {
+ if (!array_key_exists($key, $this->additionalParameters)) {
throw new MissingAdditionalParameterException($key);
}
diff --git a/lib/API/Value/Export/Export.php b/lib/API/Value/Export/Export.php
index aad672b8..b6d6c9f6 100644
--- a/lib/API/Value/Export/Export.php
+++ b/lib/API/Value/Export/Export.php
@@ -8,15 +8,9 @@
class Export extends ValueObject
{
- /**
- * @var array
- */
- protected $header;
+ protected array $header;
- /**
- * @var array
- */
- protected $contents;
+ protected array $contents;
public function __construct(array $header, array $contents)
{
@@ -24,17 +18,11 @@ public function __construct(array $header, array $contents)
$this->contents = $contents;
}
- /**
- * @return array
- */
public function getContents(): array
{
return $this->contents;
}
- /**
- * @return array
- */
public function getHeader(): array
{
return $this->header;
diff --git a/lib/API/Value/Export/ExportCriteria.php b/lib/API/Value/Export/ExportCriteria.php
index c26d78b7..0fc12c2b 100644
--- a/lib/API/Value/Export/ExportCriteria.php
+++ b/lib/API/Value/Export/ExportCriteria.php
@@ -10,10 +10,7 @@
final class ExportCriteria extends FilterCriteria
{
- /**
- * @var string
- */
- protected $exportIdentifier;
+ protected string $exportIdentifier;
public function __construct(ContentId $contentId, DateTimeInterface $from, DateTimeInterface $to, string $exportIdentifier)
{
@@ -21,9 +18,6 @@ public function __construct(ContentId $contentId, DateTimeInterface $from, DateT
$this->exportIdentifier = $exportIdentifier;
}
- /**
- * @return string
- */
public function getExportIdentifier(): string
{
return $this->exportIdentifier;
diff --git a/lib/API/Value/Filter/CollectionFields.php b/lib/API/Value/Filter/CollectionFields.php
index 5937e588..979d9a5f 100644
--- a/lib/API/Value/Filter/CollectionFields.php
+++ b/lib/API/Value/Filter/CollectionFields.php
@@ -6,20 +6,11 @@
final class CollectionFields
{
- /**
- * @var int
- */
- private $contentId;
+ private int $contentId;
- /**
- * @var int
- */
- private $collectionId;
+ private int $collectionId;
- /**
- * @var array
- */
- private $fields;
+ private array $fields;
public function __construct(int $contentId, int $collectionId, array $fields)
{
@@ -28,25 +19,16 @@ public function __construct(int $contentId, int $collectionId, array $fields)
$this->fields = $fields;
}
- /**
- * @return int
- */
public function getContentId(): int
{
return $this->contentId;
}
- /**
- * @return int
- */
public function getCollectionId(): int
{
return $this->collectionId;
}
- /**
- * @return array
- */
public function getFields(): array
{
return $this->fields;
diff --git a/lib/API/Value/Filter/CollectionId.php b/lib/API/Value/Filter/CollectionId.php
index c3a5d2e6..7775001c 100644
--- a/lib/API/Value/Filter/CollectionId.php
+++ b/lib/API/Value/Filter/CollectionId.php
@@ -6,10 +6,7 @@
final class CollectionId
{
- /**
- * @var int
- */
- private $id;
+ private int $id;
public function __construct(int $id)
{
diff --git a/lib/API/Value/Filter/Collections.php b/lib/API/Value/Filter/Collections.php
index 3c21b55f..12371a4b 100644
--- a/lib/API/Value/Filter/Collections.php
+++ b/lib/API/Value/Filter/Collections.php
@@ -6,15 +6,9 @@
final class Collections
{
- /**
- * @var array
- */
- private $collections;
+ private array $collections;
- /**
- * @var int
- */
- private $contentId;
+ private int $contentId;
public function __construct(int $contentId, array $collections)
{
@@ -27,9 +21,6 @@ public function getCollectionIds(): array
return $this->collections;
}
- /**
- * @return int
- */
public function getContentId(): int
{
return $this->contentId;
diff --git a/lib/API/Value/Filter/ContentId.php b/lib/API/Value/Filter/ContentId.php
index b5f50b7a..1f6ca159 100644
--- a/lib/API/Value/Filter/ContentId.php
+++ b/lib/API/Value/Filter/ContentId.php
@@ -6,10 +6,7 @@
final class ContentId extends Query
{
- /**
- * @var int
- */
- protected $id;
+ protected int $id;
public function __construct(int $id, int $offset, int $limit)
{
diff --git a/lib/API/Value/Filter/Contents.php b/lib/API/Value/Filter/Contents.php
index 742e249d..8ddfe857 100644
--- a/lib/API/Value/Filter/Contents.php
+++ b/lib/API/Value/Filter/Contents.php
@@ -6,19 +6,13 @@
class Contents
{
- /**
- * @var array
- */
- protected $contents;
+ protected array $contents;
public function __construct(array $contents)
{
$this->contents = $contents;
}
- /**
- * @return array
- */
public function getContentIds(): array
{
return $this->contents;
diff --git a/lib/API/Value/Filter/FilterCriteria.php b/lib/API/Value/Filter/FilterCriteria.php
index 08592645..90c08cc1 100644
--- a/lib/API/Value/Filter/FilterCriteria.php
+++ b/lib/API/Value/Filter/FilterCriteria.php
@@ -1,5 +1,7 @@
to = $to;
}
- /**
- * @return DateTimeInterface
- */
public function getFrom(): DateTimeInterface
{
return $this->from;
}
- /**
- * @return DateTimeInterface
- */
public function getTo(): DateTimeInterface
{
return $this->to;
}
- /**
- * @return ContentId
- */
public function getContentId(): ContentId
{
return $this->contentId;
diff --git a/lib/API/Value/Filter/Query.php b/lib/API/Value/Filter/Query.php
index 0d96d22b..07adf752 100644
--- a/lib/API/Value/Filter/Query.php
+++ b/lib/API/Value/Filter/Query.php
@@ -8,19 +8,9 @@
class Query extends ValueObject
{
- /**
- * Search limit.
- *
- * @var int
- */
- protected $limit = 10;
-
- /**
- * Search offset.
- *
- * @var int
- */
- protected $offset = 0;
+ protected int $limit;
+
+ protected int $offset;
public function __construct(int $offset, int $limit)
{
@@ -28,27 +18,21 @@ public function __construct(int $offset, int $limit)
$this->limit = $limit;
}
- public static function withLimit(int $limit)
+ public static function withLimit(int $limit): self
{
return new self(0, $limit);
}
- public static function countQuery()
+ public static function countQuery(): self
{
return new self(0, 0);
}
- /**
- * @return int
- */
public function getLimit(): int
{
return $this->limit;
}
- /**
- * @return int
- */
public function getOffset(): int
{
return $this->offset;
diff --git a/lib/API/Value/Filter/SearchQuery.php b/lib/API/Value/Filter/SearchQuery.php
index 7a4197b9..c5f50eb2 100644
--- a/lib/API/Value/Filter/SearchQuery.php
+++ b/lib/API/Value/Filter/SearchQuery.php
@@ -6,15 +6,9 @@
class SearchQuery extends Query
{
- /**
- * @var int
- */
- protected $contentId;
+ protected int $contentId;
- /**
- * @var string
- */
- protected $searchText;
+ protected string $searchText;
public function __construct(int $contentId, string $searchText, int $offset, int $limit)
{
@@ -28,17 +22,11 @@ public static function withContentAndSearchText(int $contentId, string $searchTe
return new self($contentId, $searchText, 0, 0);
}
- /**
- * @return int
- */
public function getContentId(): int
{
return $this->contentId;
}
- /**
- * @return string
- */
public function getSearchText(): string
{
return $this->searchText;
diff --git a/lib/API/Value/InformationCollectionStruct.php b/lib/API/Value/InformationCollectionStruct.php
index 56b795d1..a7ea13c9 100644
--- a/lib/API/Value/InformationCollectionStruct.php
+++ b/lib/API/Value/InformationCollectionStruct.php
@@ -4,39 +4,28 @@
namespace Netgen\InformationCollection\API\Value;
-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 EzSystems\RepositoryForms\Data\Content\FieldData;
+use Ibexa\Contracts\ContentForms\Data\Content\FieldData;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\Content\Location;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
final class InformationCollectionStruct extends ValueObject
{
/**
* The language code of the version.
- *
- * @var string
*/
- protected $languageCode;
+ protected string $languageCode;
- /**
- * @var \eZ\Publish\API\Repository\Values\Content\Content
- */
- protected $content;
+ protected Content $content;
- /**
- * @var \eZ\Publish\API\Repository\Values\ContentType\ContentType
- */
- protected $contentType;
+ protected ContentType $contentType;
/**
- * @var \EzSystems\RepositoryForms\Data\Content\FieldData[]
+ * @var \Ibexa\Contracts\ContentForms\Data\Content\FieldData[]
*/
- protected $fields;
+ protected array $fields = [];
- /**
- * @var \eZ\Publish\API\Repository\Values\Content\Location
- */
- private $location;
+ private Location $location;
public function __construct(Content $content, Location $location, ContentType $contentType, array $fields)
{
@@ -49,40 +38,28 @@ public function __construct(Content $content, Location $location, ContentType $c
$this->location = $location;
}
- /**
- * @return string
- */
public function getLanguageCode(): string
{
return $this->content->contentInfo->mainLanguageCode;
}
- /**
- * @return \eZ\Publish\API\Repository\Values\Content\Content
- */
public function getContent(): Content
{
return $this->content;
}
- /**
- * @return \eZ\Publish\API\Repository\Values\Content\Location
- */
public function getLocation(): Location
{
return $this->location;
}
- /**
- * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
- */
public function getContentType(): ContentType
{
return $this->contentType;
}
/**
- * @return \EzSystems\RepositoryForms\Data\Content\FieldData[]
+ * @return \Ibexa\Contracts\ContentForms\Data\Content\FieldData[]
*/
public function getFieldsData(): array
{
@@ -90,14 +67,14 @@ public function getFieldsData(): array
}
/**
- * @return \EzSystems\RepositoryForms\Data\Content\FieldData[]
+ * @return \Ibexa\Contracts\ContentForms\Data\Content\FieldData[]
*/
public function getCollectedFields(): array
{
- return $this->fields;
+ return $this->fields;
}
- protected function addFieldData(FieldData $fieldData)
+ protected function addFieldData(FieldData $fieldData): void
{
$this->fields[$fieldData->fieldDefinition->identifier] = $fieldData;
}
diff --git a/lib/API/Value/Legacy/FieldValue.php b/lib/API/Value/Legacy/FieldValue.php
index 2dbec4ad..09ce1d7d 100644
--- a/lib/API/Value/Legacy/FieldValue.php
+++ b/lib/API/Value/Legacy/FieldValue.php
@@ -8,27 +8,13 @@
class FieldValue extends ValueObject
{
- /**
- * @var int
- *
- * previous $contentClassAttributeId
- */
- protected $fieldDefinitionId;
+ protected int $fieldDefinitionId;
- /**
- * @var float
- */
- protected $dataFloat = 0.0;
+ protected float $dataFloat;
- /**
- * @var int
- */
- protected $dataInt = 0;
+ protected int $dataInt;
- /**
- * @var string
- */
- protected $dataText = '';
+ protected string $dataText;
public function __construct(int $fieldDefinitionId, string $dataText, int $dataInt = 0, float $dataFloat = 0.0)
{
@@ -38,33 +24,21 @@ public function __construct(int $fieldDefinitionId, string $dataText, int $dataI
$this->dataText = $dataText;
}
- /**
- * @return int
- */
public function getFieldDefinitionId(): int
{
return $this->fieldDefinitionId;
}
- /**
- * @return float
- */
public function getDataFloat(): float
{
return $this->dataFloat;
}
- /**
- * @return int
- */
public function getDataInt(): int
{
return $this->dataInt;
}
- /**
- * @return string
- */
public function getDataText(): string
{
return $this->dataText;
diff --git a/lib/API/Value/NullUser.php b/lib/API/Value/NullUser.php
index 4896f4bd..d59bcf2c 100644
--- a/lib/API/Value/NullUser.php
+++ b/lib/API/Value/NullUser.php
@@ -1,31 +1,27 @@
count = $count;
}
- /**
- * @return int
- */
public function getCount(): int
{
return $this->count;
diff --git a/lib/Core/Action/ActionRegistry.php b/lib/Core/Action/ActionRegistry.php
index 4da4fd56..665e57a7 100644
--- a/lib/Core/Action/ActionRegistry.php
+++ b/lib/Core/Action/ActionRegistry.php
@@ -4,50 +4,26 @@
namespace Netgen\InformationCollection\Core\Action;
-use Netgen\InformationCollection\API\Events;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use function in_array;
use Netgen\InformationCollection\API\Action\ActionInterface;
use Netgen\InformationCollection\API\Action\CrucialActionInterface;
+use Netgen\InformationCollection\API\Events;
use Netgen\InformationCollection\API\Exception\ActionFailedException;
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
use Psr\Log\LoggerInterface;
-use function get_class;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
final class ActionRegistry implements ActionInterface
{
- /**
- * @var array
- */
- private $actions;
+ private iterable $actions;
- /**
- * @var \Psr\Log\LoggerInterface
- */
- private $logger;
+ private LoggerInterface $logger;
- /**
- * @var bool
- */
- private $debug = false;
+ private bool $debug = false;
- /**
- * @var \Netgen\InformationCollection\Core\Action\ConfigurationUtility
- */
- private $utility;
+ private ConfigurationUtility $utility;
- /**
- * @var EventDispatcherInterface
- */
- private $eventDispatcher;
+ private EventDispatcherInterface $eventDispatcher;
- /**
- * ActionAggregate constructor.
- *
- * @param array $actions
- * @param \Netgen\InformationCollection\Core\Action\ConfigurationUtility $utility
- * @param \Psr\Log\LoggerInterface $logger
- */
public function __construct(iterable $actions, ConfigurationUtility $utility, LoggerInterface $logger, EventDispatcherInterface $eventDispatcher)
{
$this->actions = $actions;
@@ -62,16 +38,13 @@ public function act(InformationCollected $event): void
foreach ($this->actions as $action) {
if ($this->utility->isActionAllowedToRun($action, $config)) {
-
$event = $this->eventDispatcher->dispatch($event, Events::BEFORE_ACTION_EXECUTION);
try {
$action->act($event);
$event = $this->eventDispatcher->dispatch($event, Events::AFTER_ACTION_EXECUTION);
-
} catch (ActionFailedException $e) {
-
$event = $this->eventDispatcher->dispatch($event, Events::ACTION_EXECUTION_FAIL);
$this->logger
@@ -83,6 +56,7 @@ public function act(InformationCollected $event): void
if ($action instanceof CrucialActionInterface) {
$event = $this->eventDispatcher->dispatch($event, Events::CRUCIAL_ACTION_EXECUTION_FAIL);
+
break;
}
}
@@ -92,10 +66,8 @@ public function act(InformationCollected $event): void
/**
* Sets debug variable based on kernel.debug param.
- *
- * @param bool $debug
*/
- public function setDebug($debug)
+ public function setDebug(bool $debug): void
{
$this->debug = $debug;
}
diff --git a/lib/Core/Action/AutoResponderAction.php b/lib/Core/Action/AutoResponderAction.php
index bac0e343..7b312679 100644
--- a/lib/Core/Action/AutoResponderAction.php
+++ b/lib/Core/Action/AutoResponderAction.php
@@ -9,9 +9,9 @@
final class AutoResponderAction extends BaseEmailAction
{
- public static $defaultName = 'auto_responder';
+ public static string $defaultName = 'auto_responder';
- protected function throwException(EmailNotSentException $exception)
+ protected function throwException(EmailNotSentException $exception): void
{
throw new ActionFailedException(static::$defaultName, $exception->getMessage());
}
diff --git a/lib/Core/Action/BaseEmailAction.php b/lib/Core/Action/BaseEmailAction.php
index 6ca413b6..b4643cd2 100644
--- a/lib/Core/Action/BaseEmailAction.php
+++ b/lib/Core/Action/BaseEmailAction.php
@@ -6,9 +6,10 @@
use Netgen\InformationCollection\API\Action\ActionInterface;
use Netgen\InformationCollection\API\Exception\EmailNotSentException;
-use Netgen\InformationCollection\API\Factory\EmailContentFactoryInterface;
use Netgen\InformationCollection\API\MailerInterface;
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
+use Netgen\InformationCollection\Core\EmailDataProvider\DefaultProvider;
+use Netgen\InformationCollection\Core\Factory\BaseEmailDataFactory;
abstract class BaseEmailAction implements ActionInterface
{
@@ -18,20 +19,15 @@ abstract class BaseEmailAction implements ActionInterface
protected $mailer;
/**
- * @var \Netgen\InformationCollection\API\Factory\EmailContentFactoryInterface
+ * @var DefaultProvider
*/
- protected $factory;
+ protected $emailDataProvider;
- /**
- * EmailAction constructor.
- *
- * @param \Netgen\InformationCollection\API\MailerInterface $mailer
- * @param \Netgen\InformationCollection\API\Factory\EmailContentFactoryInterface $factory
- */
- public function __construct(MailerInterface $mailer, EmailContentFactoryInterface $factory)
+
+ public function __construct(MailerInterface $mailer, DefaultProvider $emailDataProvider)
{
$this->mailer = $mailer;
- $this->factory = $factory;
+ $this->emailDataProvider = $emailDataProvider;
}
/**
@@ -39,10 +35,10 @@ public function __construct(MailerInterface $mailer, EmailContentFactoryInterfac
*/
public function act(InformationCollected $event): void
{
- $emailData = $this->factory->build($event);
+ $emailData = $this->emailDataProvider->provide($event);
try {
- $this->mailer->createAndSendMessage($emailData);
+ $this->mailer->sendEmail($emailData);
} catch (EmailNotSentException $e) {
$this->throwException($e);
}
diff --git a/lib/Core/Action/ConfigurationUtility.php b/lib/Core/Action/ConfigurationUtility.php
index 63e2d6e0..5beb6e92 100644
--- a/lib/Core/Action/ConfigurationUtility.php
+++ b/lib/Core/Action/ConfigurationUtility.php
@@ -1,25 +1,21 @@
informationCollection = $informationCollection;
}
- /**
- * {@inheritdoc}
- */
public function act(InformationCollected $event): void
{
$struct = $event->getInformationCollectionStruct();
diff --git a/lib/Core/Action/EmailAction.php b/lib/Core/Action/EmailAction.php
index b6d41d63..0b75da01 100644
--- a/lib/Core/Action/EmailAction.php
+++ b/lib/Core/Action/EmailAction.php
@@ -9,9 +9,9 @@
final class EmailAction extends BaseEmailAction
{
- public static $defaultName = 'email';
+ public static string $defaultName = 'email';
- protected function throwException(EmailNotSentException $exception)
+ protected function throwException(EmailNotSentException $exception): void
{
throw new ActionFailedException(static::$defaultName, $exception->getMessage());
}
diff --git a/lib/Core/Action/Identifier.php b/lib/Core/Action/Identifier.php
index c8eea954..a5afba35 100644
--- a/lib/Core/Action/Identifier.php
+++ b/lib/Core/Action/Identifier.php
@@ -1,17 +1,17 @@
getHeaders();
-
- $header = new Header
- $headers->add('Content-Type', '');
-
- return $email;
+ // could be replaced by pure service configuration
+ public function __construct(
+ AutoResponderDataFactory $emailDataFactory
+ ) {
+ parent::__construct($emailDataFactory);
}
}
diff --git a/lib/Core/EmailDataProvider/DefaultProvider.php b/lib/Core/EmailDataProvider/DefaultProvider.php
index 61dae1e4..d939472c 100644
--- a/lib/Core/EmailDataProvider/DefaultProvider.php
+++ b/lib/Core/EmailDataProvider/DefaultProvider.php
@@ -2,97 +2,46 @@
namespace Netgen\InformationCollection\Core\EmailDataProvider;
+use Ibexa\Contracts\ContentForms\Data\Content\FieldData;
use Netgen\InformationCollection\API\Action\EmailDataProviderInterface;
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
+use Netgen\InformationCollection\Core\Factory\EmailDataFactory;
use Symfony\Component\Mime\Email;
-use eZ\Publish\Core\MVC\ConfigResolverInterface;
-use Netgen\InformationCollection\Core\Action\EmailAction;
-use function array_key_exists;
-use eZ\Publish\API\Repository\Values\Content\Field;
-use eZ\Publish\Core\FieldType\BinaryFile\Value as BinaryFile;
-use eZ\Publish\Core\Helper\FieldHelper;
-use eZ\Publish\Core\Helper\TranslationHelper;
-use Netgen\InformationCollection\API\Value\DataTransfer\EmailContent;
-use Netgen\InformationCollection\API\Constants;
-use Netgen\InformationCollection\API\ConfigurationConstants;
-use Netgen\InformationCollection\API\Exception\MissingEmailBlockException;
-use Netgen\InformationCollection\API\Exception\MissingValueException;
-use Netgen\InformationCollection\API\Value\DataTransfer\TemplateContent;
-use function trim;
-use Twig\Environment;
class DefaultProvider implements EmailDataProviderInterface
{
- /**
- * @var array
- */
- protected $configResolver;
+ protected $emailDataFactory;
- /**
- * @var \eZ\Publish\Core\Helper\TranslationHelper
- */
- protected $translationHelper;
-
- /**
- * @var \eZ\Publish\Core\Helper\FieldHelper
- */
- protected $fieldHelper;
-
- /**
- * @var \Twig\Environment
- */
- protected $twig;
-
- /**
- * EmailDataFactory constructor.
- *
- * @param array $config
- * @param \eZ\Publish\Core\Helper\TranslationHelper $translationHelper
- * @param \eZ\Publish\Core\Helper\FieldHelper $fieldHelper
- * @param \Twig\Environment $twig
- */
public function __construct(
- ConfigResolverInterface $configResolver,
- TranslationHelper $translationHelper,
- FieldHelper $fieldHelper,
- Environment $twig
+ EmailDataFactory $emailDataFactory
) {
- $this->configResolver = $configResolver;
- $this->config = $this->configResolver->getParameter('action_config', 'netgen_information_collection')[EmailAction::$defaultName];
- $this->translationHelper = $translationHelper;
- $this->fieldHelper = $fieldHelper;
- $this->twig = $twig;
+ $this->emailDataFactory = $emailDataFactory;
}
- /**
- * Factory method.
- *
- * @param InformationCollected $value
- *
- * @return EmailContent
- */
- public function build(InformationCollected $value): EmailContent
+ public function provide(InformationCollected $value): Email
{
- $contentType = $value->getContentType();
-
- $template = $this->resolveTemplate($contentType->identifier);
-
- $templateWrapper = $this->twig->load($template);
- $data = new TemplateContent($value, $templateWrapper);
-
- $body = $this->resolveBody($data);
-
- return new EmailContent(
- $this->resolveEmail($data, Constants::FIELD_RECIPIENT),
- $this->resolveEmail($data, Constants::FIELD_SENDER),
- $this->resolve($data, Constants::FIELD_SUBJECT),
- $body,
- $this->resolveAttachments($contentType->identifier, $value->getInformationCollectionStruct()->getFieldsData())
+ $emailContent = $this->emailDataFactory->build($value);
+
+ $email = (new Email())
+ ->from(...$emailContent->getSender())
+ ->to(...$emailContent->getRecipients())
+ ->subject($emailContent->getSubject())
+ ->html($emailContent->getBody())
+ ->text($emailContent->getBody());
+
+ array_map(
+ function (FieldData $fieldData) use ($email) {
+ $binaryFileValue = $fieldData->value;
+
+ $email->attachFromPath(
+ $binaryFileValue->inputUri,
+ $binaryFileValue->fileName,
+ $binaryFileValue->mimeType
+ );
+ },
+ $emailContent->getAttachments()
);
- }
- public function provide(InformationCollected $value): Email
- {
- return new Email();
+ return $email;
}
}
diff --git a/lib/Core/Export/CsvExportResponseFormatter.php b/lib/Core/Export/CsvExportResponseFormatter.php
index a4f5dade..a22fa36a 100644
--- a/lib/Core/Export/CsvExportResponseFormatter.php
+++ b/lib/Core/Export/CsvExportResponseFormatter.php
@@ -1,34 +1,24 @@
translationHelper = $translationHelper;
@@ -51,11 +41,12 @@ public function format(Export $export, Content $content): Response
$writer->setDelimiter($config['delimiter']);
$writer->setEnclosure($config['enclosure']);
$writer->setNewline($config['newline']);
- $writer->setOutputBOM(Writer::BOM_UTF8); //adding the BOM sequence on output
+ $writer->setOutputBOM(Writer::BOM_UTF8); // adding the BOM sequence on output
$writer->insertOne($export->getHeader());
$writer->insertAll($export->getContents());
$writer->output($contentName . '.csv');
+
return new Response('');
}
}
diff --git a/lib/Core/Export/ExportResponseFormatterRegistry.php b/lib/Core/Export/ExportResponseFormatterRegistry.php
index d6405676..92315cde 100644
--- a/lib/Core/Export/ExportResponseFormatterRegistry.php
+++ b/lib/Core/Export/ExportResponseFormatterRegistry.php
@@ -1,20 +1,21 @@
exportResponseFormatters = $exportResponseFormatters;
}
- /**
- * @param string $identifier
- *
- * @return \Netgen\InformationCollection\API\Export\ExportResponseFormatter
- */
- public function getExportResponseFormatter($identifier): ExportResponseFormatter
+ public function getExportResponseFormatter(string $identifier): ExportResponseFormatter
{
foreach ($this->exportResponseFormatters as $formatter) {
if ($formatter->getIdentifier() === $identifier) {
diff --git a/lib/Core/Export/JsonExportResponseFormatter.php b/lib/Core/Export/JsonExportResponseFormatter.php
index e6e7db7a..f34b76f7 100644
--- a/lib/Core/Export/JsonExportResponseFormatter.php
+++ b/lib/Core/Export/JsonExportResponseFormatter.php
@@ -1,12 +1,15 @@
translationHelper = $translationHelper;
@@ -40,15 +36,14 @@ public function format(Export $export, Content $content): Response
$activeSheet = $spreadsheet->getActiveSheet();
try {
- $activeSheet->setTitle(substr($contentName, 0, 30));
- } catch (\Exception $exception) {
+ $activeSheet->setTitle(mb_substr($contentName, 0, 30));
+ } catch (Exception $exception) {
$activeSheet->setTitle('Information collection export');
}
$activeSheet->fromArray($export->getHeader(), null, 'A1', true);
$activeSheet->fromArray($export->getContents(), null, 'A2', true);
-
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $contentName . '.xls"');
header('Cache-Control: max-age=0');
diff --git a/lib/Core/Export/XlsxExportResponseFormatter.php b/lib/Core/Export/XlsxExportResponseFormatter.php
index 452b9170..9b09b586 100644
--- a/lib/Core/Export/XlsxExportResponseFormatter.php
+++ b/lib/Core/Export/XlsxExportResponseFormatter.php
@@ -1,27 +1,24 @@
translationHelper = $translationHelper;
@@ -40,15 +37,14 @@ public function format(Export $export, Content $content): Response
$activeSheet = $spreadsheet->getActiveSheet();
try {
- $activeSheet->setTitle(substr($contentName, 0, 30));
- } catch (\Exception $exception) {
+ $activeSheet->setTitle(mb_substr($contentName, 0, 30));
+ } catch (Exception $exception) {
$activeSheet->setTitle('Information collection export');
}
$activeSheet->fromArray($export->getHeader(), null, 'A1', true);
$activeSheet->fromArray($export->getContents(), null, 'A2', true);
-
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $contentName . '.xlsx"');
header('Cache-Control: max-age=0');
diff --git a/lib/Core/Factory/AutoResponderDataFactory.php b/lib/Core/Factory/AutoResponderDataFactory.php
index 7e79cd9c..b915de54 100644
--- a/lib/Core/Factory/AutoResponderDataFactory.php
+++ b/lib/Core/Factory/AutoResponderDataFactory.php
@@ -4,7 +4,12 @@
namespace Netgen\InformationCollection\Core\Factory;
-use Netgen\InformationCollection\API\Factory\EmailContentFactoryInterface;
+use eZ\Publish\Core\Helper\FieldHelper;
+use eZ\Publish\Core\Helper\TranslationHelper;
+use eZ\Publish\Core\MVC\ConfigResolverInterface;
+use Netgen\InformationCollection\Core\Action\AutoResponderAction;
+use Netgen\InformationCollection\Core\Action\EmailAction;
+use Twig\Environment;
use function array_key_exists;
use eZ\Publish\API\Repository\Values\Content\Field;
use Netgen\InformationCollection\API\Constants;
@@ -15,8 +20,14 @@
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
use function trim;
-class AutoResponderDataFactory implements EmailContentFactoryInterface
+class AutoResponderDataFactory extends EmailDataFactory
{
+ public function __construct(ConfigResolverInterface $configResolver, TranslationHelper $translationHelper, FieldHelper $fieldHelper, Environment $twig)
+ {
+ parent::__construct($configResolver, $translationHelper, $fieldHelper, $twig);
+ $this->config = $this->configResolver->getParameter('action_config', 'netgen_information_collection')[AutoResponderAction::$defaultName];
+ }
+
/**
* Factory method.
*
@@ -86,7 +97,7 @@ protected function resolveRecipient(TemplateContent $data)
}
if (array_key_exists($field, $fields)) {
- return [$fields[$field]->email];
+ return [$fields[$field]->value->email];
}
throw new MissingValueException($field);
diff --git a/lib/Core/Factory/EmailDataFactory.php b/lib/Core/Factory/EmailDataFactory.php
index 2f4c8518..76ab0def 100644
--- a/lib/Core/Factory/EmailDataFactory.php
+++ b/lib/Core/Factory/EmailDataFactory.php
@@ -4,54 +4,38 @@
namespace Netgen\InformationCollection\Core\Factory;
-use eZ\Publish\Core\MVC\ConfigResolverInterface;
-use Netgen\InformationCollection\API\Factory\EmailContentFactoryInterface;
-use Netgen\InformationCollection\Core\Action\EmailAction;
-use function array_key_exists;
-use eZ\Publish\API\Repository\Values\Content\Field;
-use eZ\Publish\Core\FieldType\BinaryFile\Value as BinaryFile;
-use eZ\Publish\Core\Helper\FieldHelper;
-use eZ\Publish\Core\Helper\TranslationHelper;
-use Netgen\InformationCollection\API\Value\DataTransfer\EmailContent;
-use Netgen\InformationCollection\API\Constants;
+use Ibexa\Contracts\Core\Repository\Values\Content\Field;
+use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
+use Ibexa\Core\FieldType\BinaryFile\Value as BinaryFile;
+use Ibexa\Core\Helper\FieldHelper;
+use Ibexa\Core\Helper\TranslationHelper;
use Netgen\InformationCollection\API\ConfigurationConstants;
+use Netgen\InformationCollection\API\Constants;
use Netgen\InformationCollection\API\Exception\MissingEmailBlockException;
use Netgen\InformationCollection\API\Exception\MissingValueException;
+use Netgen\InformationCollection\API\Factory\EmailContentFactoryInterface;
+use Netgen\InformationCollection\API\Value\DataTransfer\EmailContent;
use Netgen\InformationCollection\API\Value\DataTransfer\TemplateContent;
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
-use function trim;
+use Netgen\InformationCollection\Core\Action\EmailAction;
use Twig\Environment;
+use function array_filter;
+use function array_key_exists;
+use function explode;
+use function filter_var;
+use function trim;
+use const FILTER_VALIDATE_EMAIL;
class EmailDataFactory implements EmailContentFactoryInterface
{
- /**
- * @var array
- */
- protected $configResolver;
+ protected ConfigResolverInterface $configResolver;
- /**
- * @var \eZ\Publish\Core\Helper\TranslationHelper
- */
- protected $translationHelper;
+ protected TranslationHelper $translationHelper;
- /**
- * @var \eZ\Publish\Core\Helper\FieldHelper
- */
- protected $fieldHelper;
+ protected FieldHelper $fieldHelper;
- /**
- * @var \Twig\Environment
- */
- protected $twig;
+ protected Environment $twig;
- /**
- * EmailDataFactory constructor.
- *
- * @param array $config
- * @param \eZ\Publish\Core\Helper\TranslationHelper $translationHelper
- * @param \eZ\Publish\Core\Helper\FieldHelper $fieldHelper
- * @param \Twig\Environment $twig
- */
public function __construct(
ConfigResolverInterface $configResolver,
TranslationHelper $translationHelper,
@@ -67,10 +51,6 @@ public function __construct(
/**
* Factory method.
- *
- * @param InformationCollected $value
- *
- * @return EmailContent
*/
public function build(InformationCollected $value): EmailContent
{
@@ -92,16 +72,7 @@ public function build(InformationCollected $value): EmailContent
);
}
- /**
- * Returns resolved parameter.
- *
- * @param TemplateContent $data
- * @param string $field
- * @param string $property
- *
- * @return string
- */
- protected function resolve(TemplateContent $data, $field, $property = Constants::FIELD_TYPE_TEXT)
+ protected function resolve(TemplateContent $data, string $field, string $property = Constants::FIELD_TYPE_TEXT): string
{
$rendered = '';
if ($data->getTemplateWrapper()->hasBlock($field)) {
@@ -122,8 +93,8 @@ protected function resolve(TemplateContent $data, $field, $property = Constants:
}
$content = $data->getContent();
- if (array_key_exists($field, $content->fields) &&
- !$this->fieldHelper->isFieldEmpty($content, $field)
+ if (array_key_exists($field, $content->fields)
+ && !$this->fieldHelper->isFieldEmpty($content, $field)
) {
$fieldValue = $this->translationHelper->getTranslatedField($content, $field);
@@ -141,13 +112,8 @@ protected function resolve(TemplateContent $data, $field, $property = Constants:
/**
* Returns resolved email parameter.
- *
- * @param TemplateContent $data
- * @param string $field
- *
- * @return array
*/
- protected function resolveEmail(TemplateContent $data, $field)
+ protected function resolveEmail(TemplateContent $data, string $field): array
{
$rendered = '';
if ($data->getTemplateWrapper()->hasBlock($field)) {
@@ -164,12 +130,9 @@ protected function resolveEmail(TemplateContent $data, $field)
}
if (!empty($rendered)) {
-
$emails = explode(',', $rendered);
- $emails = array_filter($emails, function($var) {
- return filter_var($var, FILTER_VALIDATE_EMAIL);
- });
+ $emails = array_filter($emails, static fn ($var) => filter_var($var, FILTER_VALIDATE_EMAIL));
if (!empty($emails)) {
return $emails;
@@ -177,15 +140,14 @@ protected function resolveEmail(TemplateContent $data, $field)
}
$content = $data->getContent();
- if (array_key_exists($field, $content->fields) &&
- !$this->fieldHelper->isFieldEmpty($content, $field)
+ if (array_key_exists($field, $content->fields)
+ && !$this->fieldHelper->isFieldEmpty($content, $field)
) {
$fieldValue = $this->translationHelper->getTranslatedField($content, $field);
if ($fieldValue instanceof Field) {
- return [$fieldValue->value->email];
+ return [(string)$fieldValue->value];
}
-
}
if (!empty($this->config[ConfigurationConstants::DEFAULT_VARIABLES][$field])) {
@@ -197,12 +159,8 @@ protected function resolveEmail(TemplateContent $data, $field)
/**
* Returns resolved template name.
- *
- * @param string $contentTypeIdentifier
- *
- * @return string
*/
- protected function resolveTemplate($contentTypeIdentifier)
+ protected function resolveTemplate(string $contentTypeIdentifier): string
{
if (array_key_exists($contentTypeIdentifier, $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::CONTENT_TYPES])) {
return $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::CONTENT_TYPES][$contentTypeIdentifier];
@@ -214,13 +172,9 @@ protected function resolveTemplate($contentTypeIdentifier)
/**
* Renders email template.
*
- * @param TemplateContent $data
- *
- * @throws MissingEmailBlockException
- *
- * @return string
+ * @throws \Netgen\InformationCollection\API\Exception\MissingEmailBlockException
*/
- protected function resolveBody(TemplateContent $data)
+ protected function resolveBody(TemplateContent $data): string
{
if ($data->getTemplateWrapper()->hasBlock(Constants::BLOCK_EMAIL)) {
return $data->getTemplateWrapper()
@@ -243,12 +197,9 @@ protected function resolveBody(TemplateContent $data)
}
/**
- * @param string $contentTypeIdentifier
- * @param array $collectedFields
- *
- * @return BinaryFile[]
+ * @return \Ibexa\Core\FieldType\BinaryFile\Value[]
*/
- protected function resolveAttachments(string $contentTypeIdentifier, array $collectedFields)
+ protected function resolveAttachments(string $contentTypeIdentifier, array $collectedFields): array
{
if (empty($this->config[ConfigurationConstants::ATTACHMENTS])) {
return [];
@@ -257,7 +208,7 @@ protected function resolveAttachments(string $contentTypeIdentifier, array $coll
if (array_key_exists($contentTypeIdentifier, $this->config[ConfigurationConstants::ATTACHMENTS][ConfigurationConstants::CONTENT_TYPES])) {
$send = $this->config[ConfigurationConstants::ATTACHMENTS][ConfigurationConstants::CONTENT_TYPES][$contentTypeIdentifier];
} else {
- $send = $this->config[ConfigurationConstants::ATTACHMENTS][ConfigurationConstants::SETTINGS_DEFAULT];
+ $send = $this->config[ConfigurationConstants::ATTACHMENTS]['enabled'];
}
if (!$send) {
@@ -268,16 +219,18 @@ protected function resolveAttachments(string $contentTypeIdentifier, array $coll
}
/**
- * @param array $collectedFields
- *
- * @return BinaryFile[]
+ * @return \Ibexa\Core\FieldType\BinaryFile\Value[]
*/
- protected function getBinaryFileFields(array $collectedFields)
+ protected function getBinaryFileFields(array $collectedFields): array
{
$filtered = [];
- foreach ($collectedFields as $identifier => $value) {
- if ($value instanceof BinaryFile) {
- $filtered[] = $value;
+
+ /**
+ * @var $collectedField \EzSystems\EzPlatformContentForms\Data\Content\FieldData
+ */
+ foreach ($collectedFields as $identifier => $collectedField) {
+ if ($collectedField->value instanceof BinaryFile) {
+ $filtered[] = $collectedField;
}
}
diff --git a/lib/Core/Factory/FieldDataFactory.php b/lib/Core/Factory/FieldDataFactory.php
index 6ca0159f..b5474d58 100644
--- a/lib/Core/Factory/FieldDataFactory.php
+++ b/lib/Core/Factory/FieldDataFactory.php
@@ -4,8 +4,8 @@
namespace Netgen\InformationCollection\Core\Factory;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\Factory\FieldValueFactoryInterface;
use Netgen\InformationCollection\API\FieldHandler\CustomFieldHandlerInterface;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
@@ -14,16 +14,8 @@
class FieldDataFactory implements FieldValueFactoryInterface
{
- /**
- * @var \Netgen\InformationCollection\Core\Persistence\FieldHandler\FieldHandlerRegistry
- */
- protected $registry;
+ protected FieldHandlerRegistry $registry;
- /**
- * FieldDataFactory constructor.
- *
- * @param \Netgen\InformationCollection\Core\Persistence\FieldHandler\FieldHandlerRegistry $registry
- */
public function __construct(FieldHandlerRegistry $registry)
{
$this->registry = $registry;
@@ -31,11 +23,6 @@ public function __construct(FieldHandlerRegistry $registry)
/**
* Returns value object that represents legacy value.
- *
- * @param \eZ\Publish\Core\FieldType\Value $value
- * @param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition $fieldDefinition
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Mailer/SwiftMailerBasedMailer.php b/lib/Core/Mailer/SwiftMailerBasedMailer.php
index 964e4e48..a810617d 100644
--- a/lib/Core/Mailer/SwiftMailerBasedMailer.php
+++ b/lib/Core/Mailer/SwiftMailerBasedMailer.php
@@ -6,6 +6,7 @@
use Netgen\InformationCollection\API\Exception\EmailNotSentException;
use Netgen\InformationCollection\API\MailerInterface;
+use Swift_Message;
use Symfony\Component\Mime\Email;
class SwiftMailerBasedMailer implements MailerInterface
@@ -30,31 +31,59 @@ public function __construct(\Swift_Mailer $internalMailer)
*/
public function sendEmail(Email $content): void
{
- $message = new \Swift_Message();
+ $message = new Swift_Message();
try {
- $message->setTo($content->getFrom());
+ $message->setTo(
+ array_map(
+ function(\Symfony\Component\Mime\Address $address) {
+ return $address->getAddress();
+ },
+ $content->getTo()
+ )
+ );
} catch (\Swift_RfcComplianceException $e) {
throw new EmailNotSentException('recipients', $e->getMessage());
}
- try {
- $message->setFrom($data->getSender());
- } catch (\Swift_RfcComplianceException $e) {
- throw new EmailNotSentException('sender', $e->getMessage());
+ if (!$content->getFrom())
+ {
+ throw new EmailNotSentException('sender', "No sender has been set for the email.");
}
- $message->setSubject($data->getSubject());
+ $message->setFrom(
+ array_map(
+ function(\Symfony\Component\Mime\Address $address) {
+ return $address->getAddress();
+ },
+ $content->getFrom()
+ )
+ );
+
+ $message->setSubject($content->getSubject());
+
+ // attachments still todo
+
+ if (!empty($content->getAttachments())) {
+ foreach ($content->getAttachments() as $attachment) {
+ $body = $attachment->getBody();
+ $preparedHeaders = $attachment->getPreparedHeaders();
+
+ $filename = $preparedHeaders->get('content-disposition')->getParameter('filename');
+ $contentType = $preparedHeaders->get('content-type')->getBody();
- if ($data->hasAttachments()) {
- foreach ($data->getAttachments() as $attachment) {
$message->attach(
- \Swift_Attachment::fromPath($attachment->inputUri, $attachment->mimeType)
- ->setFilename($attachment->fileName)
+ new \Swift_Attachment($body, $filename, $contentType)
);
+
}
}
+ $message->setBody(
+ $content->getHtmlBody(),
+ 'text/html'
+ );
+
if (!$this->internalMailer->send($message)) {
throw new EmailNotSentException('send', 'invalid mailer configuration?');
}
diff --git a/lib/Core/Mailer/SymfonyMailerBasedMailer.php b/lib/Core/Mailer/SymfonyMailerBasedMailer.php
index 0c92fad5..a178f550 100644
--- a/lib/Core/Mailer/SymfonyMailerBasedMailer.php
+++ b/lib/Core/Mailer/SymfonyMailerBasedMailer.php
@@ -3,6 +3,7 @@
namespace Netgen\InformationCollection\Core\Mailer;
use Netgen\InformationCollection\API\MailerInterface;
+use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface as SfMailerInterface;
use Symfony\Component\Mime\Email;
@@ -18,12 +19,11 @@ public function __construct(SfMailerInterface $mailer)
$this->mailer = $mailer;
}
+ /**
+ * @throws TransportExceptionInterface
+ */
public function sendEmail(Email $content): void
{
- try {
- $this->mailer->send($content);
- } catch () {
-
- }
+ $this->mailer->send($content);
}
}
diff --git a/lib/Core/Mapper/DomainObjectMapper.php b/lib/Core/Mapper/DomainObjectMapper.php
index 7b9bd130..950323d7 100644
--- a/lib/Core/Mapper/DomainObjectMapper.php
+++ b/lib/Core/Mapper/DomainObjectMapper.php
@@ -6,14 +6,17 @@
use DateTimeImmutable;
use DateTimeInterface;
-use eZ\Publish\API\Repository\Exceptions\NotFoundException;
-use eZ\Publish\API\Repository\Repository;
-use eZ\Publish\API\Repository\Values\Content\Content as APIContent;
-use eZ\Publish\API\Repository\Values\Content\Field;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinitionCollection;
-use eZ\Publish\API\Repository\Values\User\User;
-use eZ\Publish\Core\Repository\Values\ContentType\ContentType as CoreContentType;
+use Ibexa\Contracts\Core\Repository\ContentService;
+use Ibexa\Contracts\Core\Repository\ContentTypeService;
+use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
+use Ibexa\Contracts\Core\Repository\Repository;
+use Ibexa\Contracts\Core\Repository\UserService;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content as APIContent;
+use Ibexa\Contracts\Core\Repository\Values\Content\Field;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCollection;
+use Ibexa\Contracts\Core\Repository\Values\User\User;
+use Ibexa\Core\Repository\Values\ContentType\ContentType as CoreContentType;
use Netgen\InformationCollection\API\Value\Attribute;
use Netgen\InformationCollection\API\Value\AttributeValue;
use Netgen\InformationCollection\API\Value\Collection;
@@ -24,25 +27,13 @@
final class DomainObjectMapper
{
- /**
- * @var \eZ\Publish\API\Repository\Repository
- */
- private $repository;
-
- /**
- * @var \eZ\Publish\API\Repository\ContentService
- */
- private $contentService;
-
- /**
- * @var \eZ\Publish\API\Repository\ContentTypeService
- */
- private $contentTypeService;
-
- /**
- * @var \eZ\Publish\API\Repository\UserService
- */
- private $userService;
+ private Repository $repository;
+
+ private ContentService $contentService;
+
+ private ContentTypeService $contentTypeService;
+
+ private UserService $userService;
public function __construct(Repository $repository)
{
@@ -70,6 +61,7 @@ public function mapContent(array $data, EzInfoCollection $first, EzInfoCollectio
public function mapCollection(EzInfoCollection $collection, array $attributes): Collection
{
$content = $this->contentService->loadContent($collection->getContentObjectId());
+
/** @var CoreContentType $contentType */
$contentType = $this->contentTypeService
->loadContentType(
@@ -80,7 +72,6 @@ public function mapCollection(EzInfoCollection $collection, array $attributes):
$attributeValues = [];
foreach ($attributes as $attr) {
-
$fieldDefinition = $this->getFieldDefinition($fieldDefinitions, $attr);
if (!$fieldDefinition instanceof FieldDefinition) {
@@ -114,6 +105,7 @@ public function mapAttribute(EzInfoCollectionAttribute $attribute, APIContent $c
}
$value = new AttributeValue($attribute->getDataInt(), $attribute->getDataFloat(), $attribute->getDataText());
+
return new Attribute(
$attribute->getId(),
$classField,
@@ -122,14 +114,13 @@ public function mapAttribute(EzInfoCollectionAttribute $attribute, APIContent $c
);
}
- private function getUser($userId): User
+ private function getUser(int $userId): User
{
try {
return $this->repository
->getUserService()
->loadUser($userId);
} catch (NotFoundException $exception) {
-
}
return new NullUser();
@@ -143,9 +134,9 @@ private function getDateTime(int $timestamp): DateTimeInterface
private function getFieldDefinition(FieldDefinitionCollection $fieldDefinitionCollection, EzInfoCollectionAttribute $attribute): ?FieldDefinition
{
/** @var FieldDefinitionCollection $collection */
- $collection = $fieldDefinitionCollection->filter(function(FieldDefinition $definition) use ($attribute) {
- return $definition->id === $attribute->getContentClassAttributeId();
- });
+ $collection = $fieldDefinitionCollection->filter(
+ static fn (FieldDefinition $definition): bool => $definition->id === $attribute->getContentClassAttributeId()
+ );
if ($collection->isEmpty()) {
return null;
diff --git a/lib/Core/Pagination/BaseAdapter.php b/lib/Core/Pagination/BaseAdapter.php
index 148fb59e..caee458b 100644
--- a/lib/Core/Pagination/BaseAdapter.php
+++ b/lib/Core/Pagination/BaseAdapter.php
@@ -9,21 +9,10 @@
abstract class BaseAdapter implements AdapterInterface
{
- /**
- * @var int
- */
- protected $nbResults;
+ protected int $nbResults;
- /**
- * @var \Netgen\InformationCollection\API\Service\InformationCollection
- */
- protected $informationCollectionService;
+ protected InformationCollection $informationCollectionService;
- /**
- * InformationCollectionCollectionListAdapter constructor.
- *
- * @param \Netgen\InformationCollection\API\Service\InformationCollection $informationCollectionService
- */
public function __construct(InformationCollection $informationCollectionService)
{
$this->informationCollectionService = $informationCollectionService;
diff --git a/lib/Core/Pagination/InformationCollectionCollectionListAdapter.php b/lib/Core/Pagination/InformationCollectionCollectionListAdapter.php
index 8313ca00..5bd00456 100644
--- a/lib/Core/Pagination/InformationCollectionCollectionListAdapter.php
+++ b/lib/Core/Pagination/InformationCollectionCollectionListAdapter.php
@@ -9,10 +9,7 @@
class InformationCollectionCollectionListAdapter extends BaseAdapter
{
- /**
- * @var \Netgen\InformationCollection\API\Value\Filter\ContentId
- */
- protected $query;
+ protected ContentId $query;
public function __construct(InformationCollection $informationCollectionService, ContentId $query)
{
@@ -20,7 +17,7 @@ public function __construct(InformationCollection $informationCollectionService,
parent::__construct($informationCollectionService);
}
- public function getNbResults()
+ public function getNbResults(): int
{
if (!isset($this->nbResults)) {
$query = ContentId::countWithContentId($this->query->getContentId());
@@ -33,7 +30,7 @@ public function getNbResults()
return $this->nbResults;
}
- public function getSlice($offset, $length)
+ public function getSlice($offset, $length): iterable
{
$query = new ContentId($this->query->getContentId(), $offset, $length);
diff --git a/lib/Core/Pagination/InformationCollectionCollectionListSearchAdapter.php b/lib/Core/Pagination/InformationCollectionCollectionListSearchAdapter.php
index 88d453d9..01812c7d 100644
--- a/lib/Core/Pagination/InformationCollectionCollectionListSearchAdapter.php
+++ b/lib/Core/Pagination/InformationCollectionCollectionListSearchAdapter.php
@@ -10,10 +10,7 @@
class InformationCollectionCollectionListSearchAdapter extends BaseAdapter
{
- /**
- * @var \Netgen\InformationCollection\API\Value\Filter\SearchQuery
- */
- protected $query;
+ protected SearchQuery $query;
public function __construct(InformationCollection $informationCollectionService, SearchQuery $query)
{
@@ -21,7 +18,7 @@ public function __construct(InformationCollection $informationCollectionService,
parent::__construct($informationCollectionService);
}
- public function getNbResults()
+ public function getNbResults(): int
{
if (!isset($this->nbResults)) {
$query = new SearchCountQuery(
@@ -39,7 +36,7 @@ public function getNbResults()
return $this->nbResults;
}
- public function getSlice($offset, $length)
+ public function getSlice($offset, $length): iterable
{
$query = new SearchQuery(
$this->query->getContentId(),
diff --git a/lib/Core/Pagination/InformationCollectionContentsAdapter.php b/lib/Core/Pagination/InformationCollectionContentsAdapter.php
index 07296680..1f55d04e 100644
--- a/lib/Core/Pagination/InformationCollectionContentsAdapter.php
+++ b/lib/Core/Pagination/InformationCollectionContentsAdapter.php
@@ -9,10 +9,7 @@
class InformationCollectionContentsAdapter extends BaseAdapter
{
- /**
- * @var \Netgen\InformationCollection\API\Value\Filter\Query
- */
- protected $query;
+ protected Query $query;
public function __construct(InformationCollection $informationCollectionService, Query $query)
{
@@ -20,7 +17,7 @@ public function __construct(InformationCollection $informationCollectionService,
parent::__construct($informationCollectionService);
}
- public function getNbResults()
+ public function getNbResults(): int
{
if (!isset($this->nbResults)) {
$this->nbResults = $this->informationCollectionService
@@ -31,7 +28,7 @@ public function getNbResults()
return $this->nbResults;
}
- public function getSlice($offset, $length)
+ public function getSlice($offset, $length): iterable
{
$query = new Query($offset, $length);
diff --git a/lib/Core/Pagination/Pagerfanta/View/InformationCollectionAdminView.php b/lib/Core/Pagination/Pagerfanta/View/InformationCollectionAdminView.php
index 7a4c8783..0d2a64eb 100644
--- a/lib/Core/Pagination/Pagerfanta/View/InformationCollectionAdminView.php
+++ b/lib/Core/Pagination/Pagerfanta/View/InformationCollectionAdminView.php
@@ -4,52 +4,31 @@
namespace Netgen\InformationCollection\Core\Pagination\Pagerfanta\View;
+use BabDev\PagerfantaBundle\RouteGenerator\RouterAwareRouteGenerator;
+use Closure;
use Pagerfanta\PagerfantaInterface;
use Pagerfanta\View\ViewInterface;
use Twig\Environment;
+use function max;
+use function min;
+use function trim;
class InformationCollectionAdminView implements ViewInterface
{
- /**
- * @var \Twig\Environment
- */
- protected $twig;
+ protected Environment $twig;
- /**
- * @var string
- */
- protected $template;
+ protected string $template;
- /**
- * @var \Pagerfanta\Pagerfanta
- */
- protected $pagerfanta;
+ protected PagerfantaInterface $pagerfanta;
- /**
- * @var \Closure
- */
- protected $routeGenerator;
+ protected RouterAwareRouteGenerator $routeGenerator;
- /**
- * @var int
- */
- protected $proximity;
+ protected int $proximity;
- /**
- * @var int
- */
- protected $startPage;
+ protected int $startPage;
- /**
- * @var int
- */
- protected $endPage;
+ protected int $endPage;
- /**
- * Constructor.
- *
- * @param \Twig\Environment $twig
- */
public function __construct(Environment $twig)
{
$this->twig = $twig;
@@ -57,20 +36,16 @@ public function __construct(Environment $twig)
/**
* Sets the default template.
- *
- * @param string $template
*/
- public function setDefaultTemplate($template)
+ public function setDefaultTemplate(string $template): void
{
$this->template = $template;
}
/**
* Returns the canonical name.
- *
- * @return string
*/
- public function getName()
+ public function getName(): string
{
return 'netgen_information_collection_admin';
}
@@ -78,17 +53,10 @@ public function getName()
/**
* Renders a Pagerfanta.
*
- * The route generator can be any callable to generate
- * the routes receiving the page number as first and
- * unique argument.
- *
- * @param \Pagerfanta\PagerfantaInterface $pagerfanta A pagerfanta
- * @param \Closure $routeGenerator A callable to generate the routes
- * @param array $options An array of options (optional)
*
- * @return string
+ * @param RouterAwareRouteGenerator $routeGenerator A callable to generate the routes
*/
- public function render(PagerfantaInterface $pagerfanta, $routeGenerator, array $options = [])
+ public function render(PagerfantaInterface $pagerfanta, $routeGenerator, array $options = []): string
{
$this->pagerfanta = $pagerfanta;
$this->routeGenerator = $routeGenerator;
@@ -107,10 +75,8 @@ public function render(PagerfantaInterface $pagerfanta, $routeGenerator, array $
/**
* Initializes the proximity.
- *
- * @param array $options
*/
- protected function initializeProximity($options)
+ protected function initializeProximity(array $options): void
{
$this->proximity = isset($options['proximity']) ?
(int) $options['proximity'] :
@@ -120,7 +86,7 @@ protected function initializeProximity($options)
/**
* Calculates start and end page that will be shown in the middle of pager.
*/
- protected function calculateStartAndEndPage()
+ protected function calculateStartAndEndPage(): void
{
$currentPage = $this->pagerfanta->getCurrentPage();
$nbPages = $this->pagerfanta->getNbPages();
@@ -144,38 +110,24 @@ protected function calculateStartAndEndPage()
/**
* Calculates the end page when start page is underflowed.
- *
- * @param int $startPage
- * @param int $endPage
- * @param int $nbPages
- *
- * @return int
*/
- protected function calculateEndPageForStartPageUnderflow($startPage, $endPage, $nbPages)
+ protected function calculateEndPageForStartPageUnderflow(int $startPage, int $endPage, int $nbPages): int
{
return min($endPage + (1 - $startPage), $nbPages);
}
/**
* Calculates the start page when end page is overflowed.
- *
- * @param int $startPage
- * @param int $endPage
- * @param int $nbPages
- *
- * @return int
*/
- protected function calculateStartPageForEndPageOverflow($startPage, $endPage, $nbPages)
+ protected function calculateStartPageForEndPageOverflow(int $startPage, int $endPage, int $nbPages): int
{
return max($startPage - ($endPage - $nbPages), 1);
}
/**
* Returns the list of all pages that need to be displayed.
- *
- * @return array
*/
- protected function getPages()
+ protected function getPages(): array
{
$pages = [];
@@ -220,12 +172,8 @@ protected function getPages()
/**
* Generates the URL based on provided page.
- *
- * @param int $page
- *
- * @return string
*/
- protected function generateUrl($page)
+ protected function generateUrl(int $page): string
{
$routeGenerator = $this->routeGenerator;
diff --git a/lib/Core/Persistence/Anonymizer/AnonymizerService.php b/lib/Core/Persistence/Anonymizer/AnonymizerService.php
index a113b4e4..b15f8330 100644
--- a/lib/Core/Persistence/Anonymizer/AnonymizerService.php
+++ b/lib/Core/Persistence/Anonymizer/AnonymizerService.php
@@ -4,39 +4,24 @@
namespace Netgen\InformationCollection\Core\Persistence\Anonymizer;
-use eZ\Publish\API\Repository\Repository;
-use eZ\Publish\API\Repository\Values\ContentType\ContentType;
+use Ibexa\Contracts\Core\Repository\Repository;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer;
use Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor;
use Netgen\InformationCollection\API\Service\InformationCollection;
+use Netgen\InformationCollection\API\Value\Attribute;
use Netgen\InformationCollection\API\Value\Collection;
use Netgen\InformationCollection\API\Value\Filter\CollectionId;
-use Netgen\InformationCollection\API\Value\Attribute;
+use function in_array;
class AnonymizerService implements Anonymizer
{
- /**
- * @var \eZ\Publish\API\Repository\Repository
- */
- protected $repository;
+ protected Repository $repository;
- /**
- * @var \Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor
- */
- protected $fieldAnonymizerVisitor;
+ protected FieldAnonymizerVisitor $fieldAnonymizerVisitor;
- /**
- * @var \Netgen\InformationCollection\API\Service\InformationCollection
- */
- protected $informationCollection;
+ protected InformationCollection $informationCollection;
- /**
- * Anonymizer constructor.
- *
- * @param \eZ\Publish\API\Repository\Repository $repository
- * @param \Netgen\InformationCollection\API\Service\InformationCollection $informationCollection
- * @param \Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor $fieldAnonymizerVisitor
- */
public function __construct(
Repository $repository,
InformationCollection $informationCollection,
@@ -56,13 +41,10 @@ public function anonymizeCollection(int $collectionId, array $fields = []): void
}
/**
- * @param \Netgen\InformationCollection\API\Value\Collection $collection
- * @param array $fields
- *
- * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
- * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
*/
- protected function destroyData(Collection $collection, array $fields = [])
+ protected function destroyData(Collection $collection, array $fields = []): void
{
$contentType = $this->repository
->getContentTypeService()
@@ -71,7 +53,7 @@ protected function destroyData(Collection $collection, array $fields = [])
$attributes = $this->filterAttributes($collection, $fields);
if (empty($attributes)) {
- throw new \OutOfRangeException("The is no valid fields selected for anonymization");
+ throw new \OutOfRangeException('The is no valid fields selected for anonymization');
}
$collectionId = new CollectionId($collection->getId());
@@ -81,7 +63,7 @@ protected function destroyData(Collection $collection, array $fields = [])
/**
* @param \Netgen\InformationCollection\API\Value\Attribute[] $attributes
*/
- protected function anonymize(CollectionId $collectionId, array $attributes, ContentType $contentType)
+ protected function anonymize(CollectionId $collectionId, array $attributes, ContentType $contentType): void
{
foreach ($attributes as $attribute) {
$value = $this->fieldAnonymizerVisitor->visit($attribute, $contentType);
@@ -93,12 +75,7 @@ protected function anonymize(CollectionId $collectionId, array $attributes, Cont
}
/**
- * Filter attributes based on the user selection of fields to anonymize
- *
- * @param Collection $collection
- * @param array $fields
- *
- * @return array
+ * Filter attributes based on the user selection of fields to anonymize.
*/
protected function filterAttributes(Collection $collection, array $fields): array
{
@@ -110,8 +87,7 @@ protected function filterAttributes(Collection $collection, array $fields): arra
$filtered = [];
foreach ($attributes as $attribute) {
-
- if (in_array($attribute->getFieldDefinition()->id, $fields)) {
+ if (in_array($attribute->getFieldDefinition()->id, $fields, true)) {
$filtered[] = $attribute;
}
}
diff --git a/lib/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php b/lib/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php
index 3046ea5f..ee018330 100644
--- a/lib/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php
+++ b/lib/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php
@@ -4,36 +4,21 @@
namespace Netgen\InformationCollection\Core\Persistence\Anonymizer;
-use DateTime;
+use DateTimeImmutable;
use Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer;
use Netgen\InformationCollection\Core\Persistence\ContentTypeUtils;
use Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionRepository;
use OutOfBoundsException;
+use function count;
final class AnonymizerServiceFacade
{
- /**
- * @var \Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer
- */
- private $anonymizer;
+ private Anonymizer $anonymizer;
- /**
- * @var \Netgen\InformationCollection\Core\Persistence\ContentTypeUtils
- */
- private $contentTypeUtils;
+ private ContentTypeUtils $contentTypeUtils;
- /**
- * @var \Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionRepository
- */
- private $ezInfoCollectionRepository;
+ private EzInfoCollectionRepository $ezInfoCollectionRepository;
- /**
- * AnonymizerServiceFacade constructor.
- *
- * @param \Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer $anonymizer
- * @param \Netgen\InformationCollection\Core\Persistence\ContentTypeUtils $contentTypeUtils
- * @param \Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionRepository $ezInfoCollectionRepository
- */
public function __construct(
Anonymizer $anonymizer,
ContentTypeUtils $contentTypeUtils,
@@ -46,14 +31,8 @@ public function __construct(
/**
* Anonymize collections by content id.
- *
- * @param int $contentId Content id
- * @param array $fields Fields list
- * @param \DateTimeImmutable|null $date Anonymize collections older that this date
- *
- * @return int
*/
- public function anonymize($contentId, array $fields = [], ?\DateTimeImmutable $date = null)
+ public function anonymize(int $contentId, array $fields = [], ?DateTimeImmutable $date = null): int
{
$fieldsWithIds = $this->getFieldIds($contentId, $fields);
@@ -72,13 +51,8 @@ public function anonymize($contentId, array $fields = [], ?\DateTimeImmutable $d
/**
* Map field id's to list of field identifiers.
- *
- * @param int $contentId
- * @param array $fieldIdentifiers
- *
- * @return array
*/
- private function getFieldIds(int $contentId, array $fieldIdentifiers)
+ private function getFieldIds(int $contentId, array $fieldIdentifiers): array
{
$ids = [];
foreach ($fieldIdentifiers as $identifier) {
@@ -92,7 +66,7 @@ private function getFieldIds(int $contentId, array $fieldIdentifiers)
return $ids;
}
- private function getCollections($contentId, \DateTimeImmutable $date = null)
+ private function getCollections(int $contentId, ?DateTimeImmutable $date = null): array
{
if (null === $date) {
$collections = $this->ezInfoCollectionRepository->findByContentId($contentId);
diff --git a/lib/Core/Persistence/Anonymizer/Visitor/Field/Aggregate.php b/lib/Core/Persistence/Anonymizer/Visitor/Field/Aggregate.php
index 24547e2e..eb871638 100644
--- a/lib/Core/Persistence/Anonymizer/Visitor/Field/Aggregate.php
+++ b/lib/Core/Persistence/Anonymizer/Visitor/Field/Aggregate.php
@@ -4,7 +4,7 @@
namespace Netgen\InformationCollection\Core\Persistence\Anonymizer\Visitor\Field;
-use eZ\Publish\API\Repository\Values\ContentType\ContentType;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor;
use Netgen\InformationCollection\API\Value\Attribute;
use Netgen\InformationCollection\API\Value\AttributeValue;
@@ -15,37 +15,23 @@ class Aggregate extends FieldAnonymizerVisitor
/**
* @var \Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor[]
*/
- protected $visitors;
+ protected iterable $visitors;
- /**
- * Aggregate constructor.
- *
- * @param array $visitors
- */
public function __construct(iterable $visitors)
{
$this->visitors = $visitors;
}
- /**
- * @param \Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor $visitor
- */
- public function addVisitor(FieldAnonymizerVisitor $visitor)
+ public function addVisitor(FieldAnonymizerVisitor $visitor): void
{
$this->visitors[] = $visitor;
}
- /**
- * {@inheritdoc}
- */
public function accept(Attribute $attribute, ContentType $contentType): bool
{
return true;
}
- /**
- * {@inheritdoc}
- */
public function visit(Attribute $attribute, ContentType $contentType): AttributeValue
{
foreach ($this->visitors as $visitor) {
diff --git a/lib/Core/Persistence/Anonymizer/Visitor/Field/Email.php b/lib/Core/Persistence/Anonymizer/Visitor/Field/Email.php
index 3d276f71..8b3c909b 100644
--- a/lib/Core/Persistence/Anonymizer/Visitor/Field/Email.php
+++ b/lib/Core/Persistence/Anonymizer/Visitor/Field/Email.php
@@ -1,42 +1,41 @@
getFieldDefinition()->fieldTypeIdentifier;
}
- /**
- * {@inheritdoc}
- */
public function visit(Attribute $attribute, ContentType $contentType): AttributeValue
{
$email = $attribute->getValue()->getDataText();
- $split = str_split($email);
+ $split = mb_str_split($email);
$email = [];
foreach ($split as $character) {
- if (!in_array($character, $this->allowedCharacters)) {
+ if (!in_array($character, $this->allowedCharacters, true)) {
$email[] = 'X';
} else {
$email[] = $character;
}
}
- return new AttributeValue(0, 0, implode($email, ''));
+ return new AttributeValue(0, 0, implode('', $email));
}
}
diff --git a/lib/Core/Persistence/Anonymizer/Visitor/Field/Simple.php b/lib/Core/Persistence/Anonymizer/Visitor/Field/Simple.php
index 052641dd..f92d961f 100644
--- a/lib/Core/Persistence/Anonymizer/Visitor/Field/Simple.php
+++ b/lib/Core/Persistence/Anonymizer/Visitor/Field/Simple.php
@@ -4,25 +4,18 @@
namespace Netgen\InformationCollection\Core\Persistence\Anonymizer\Visitor\Field;
-use eZ\Publish\API\Repository\Values\ContentType\ContentType;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor;
-use Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute;
use Netgen\InformationCollection\API\Value\Attribute;
use Netgen\InformationCollection\API\Value\AttributeValue;
class Simple extends FieldAnonymizerVisitor
{
- /**
- * {@inheritdoc}
- */
public function accept(Attribute $attribute, ContentType $contentType): bool
{
return true;
}
- /**
- * {@inheritdoc}
- */
public function visit(Attribute $attribute, ContentType $contentType): AttributeValue
{
return new AttributeValue(0, 0, 'XXXXXXXXXX');
diff --git a/lib/Core/Persistence/ContentTypeUtils.php b/lib/Core/Persistence/ContentTypeUtils.php
index 72d1ae3c..72805a10 100644
--- a/lib/Core/Persistence/ContentTypeUtils.php
+++ b/lib/Core/Persistence/ContentTypeUtils.php
@@ -4,29 +4,18 @@
namespace Netgen\InformationCollection\Core\Persistence;
-use eZ\Publish\API\Repository\ContentService;
-use eZ\Publish\API\Repository\ContentTypeService;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Contracts\Core\Repository\ContentService;
+use Ibexa\Contracts\Core\Repository\ContentTypeService;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
use OutOfBoundsException;
+use function sprintf;
final class ContentTypeUtils
{
- /**
- * @var \eZ\Publish\API\Repository\ContentTypeService
- */
- private $contentTypeService;
+ private ContentTypeService $contentTypeService;
- /**
- * @var \eZ\Publish\API\Repository\ContentService
- */
- private $contentService;
+ private ContentService $contentService;
- /**
- * FieldIdResolver constructor.
- *
- * @param \eZ\Publish\API\Repository\ContentTypeService $contentTypeService
- * @param \eZ\Publish\API\Repository\ContentService $contentService
- */
public function __construct(ContentTypeService $contentTypeService, ContentService $contentService)
{
$this->contentTypeService = $contentTypeService;
@@ -34,18 +23,13 @@ public function __construct(ContentTypeService $contentTypeService, ContentServi
}
/**
- * Return field id for fiven field definition identifier.
- *
- * @param int $contentId
- * @param string $fieldDefIdentifier
+ * Return field id for given field definition identifier.
*
* @throws \OutOfBoundsException
- * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
- * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
- *
- * @return mixed
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
*/
- public function getFieldId($contentId, $fieldDefIdentifier)
+ public function getFieldId(int $contentId, string $fieldDefIdentifier): int
{
$content = $this->contentService->loadContent($contentId);
@@ -64,14 +48,10 @@ public function getFieldId($contentId, $fieldDefIdentifier)
/**
* Returns fields that are marked as info collectors.
*
- * @param int $contentId
- *
- * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
- * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
- *
- * @return array
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
*/
- public function getInfoCollectorFields($contentId)
+ public function getInfoCollectorFields(int $contentId): array
{
$fields = [];
diff --git a/lib/Core/Persistence/FieldHandler/Custom/CheckboxFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/CheckboxFieldHandler.php
index 286055cb..8d416daf 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/CheckboxFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/CheckboxFieldHandler.php
@@ -4,34 +4,26 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
class CheckboxFieldHandler implements CustomLegacyFieldHandlerInterface
{
- /**
- * {@inheritdoc}
- */
public function supports(Value $value): bool
{
return $value instanceof CheckboxValue;
}
- /**
- * {@inheritdoc}
- */
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
return (string) $value;
}
/**
- * @param \eZ\Publish\Core\FieldType\Checkbox\Value $value
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
+ * @param \Ibexa\Core\FieldType\Checkbox\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Persistence/FieldHandler/Custom/CountryFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/CountryFieldHandler.php
index 331f7d1e..65f5ce8f 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/CountryFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/CountryFieldHandler.php
@@ -4,11 +4,13 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Country\Value as CountryValue;
-use eZ\Publish\Core\FieldType\Value;
-use \Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Country\Value as CountryValue;
+use Ibexa\Core\FieldType\Value;
+use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
+use function array_column;
+use function implode;
/**
* Overrides the original country handler to save country alpha2 code to collected info
@@ -23,11 +25,11 @@ public function supports(Value $value): bool
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
- return (string)$value;
+ return (string) $value;
}
/**
- * @param \eZ\Publish\Core\FieldType\Country\Value $value
+ * @param \Ibexa\Core\FieldType\Country\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Persistence/FieldHandler/Custom/DateAndTimeFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/DateAndTimeFieldHandler.php
index e65a89b7..07db39f4 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/DateAndTimeFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/DateAndTimeFieldHandler.php
@@ -4,37 +4,28 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\DateAndTime\Value as DateAndTimeValue;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\DateAndTime\Value as DateAndTimeValue;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
class DateAndTimeFieldHandler implements CustomLegacyFieldHandlerInterface
{
- /**
- * {@inheritdoc}
- */
public function supports(Value $value): bool
{
return $value instanceof DateAndTimeValue;
}
- /**
- * {@inheritdoc}
- */
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
if ($value instanceof DateAndTimeValue) {
return (string) $value;
}
-
}
/**
- * @param \eZ\Publish\Core\FieldType\DateAndTime\Value $value
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
+ * @param \Ibexa\Core\FieldType\DateAndTime\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Persistence/FieldHandler/Custom/DateFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/DateFieldHandler.php
index d390f31e..be53e50b 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/DateFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/DateFieldHandler.php
@@ -4,34 +4,26 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Date\Value as DateValue;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Date\Value as DateValue;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
class DateFieldHandler implements CustomLegacyFieldHandlerInterface
{
- /**
- * {@inheritdoc}
- */
public function supports(Value $value): bool
{
return $value instanceof DateValue;
}
- /**
- * {@inheritdoc}
- */
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
return (string) $value;
}
/**
- * @param \eZ\Publish\Core\FieldType\Date\Value $value
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
+ * @param \Ibexa\Core\FieldType\Date\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Persistence/FieldHandler/Custom/FloatFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/FloatFieldHandler.php
index 70d1e0af..566910aa 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/FloatFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/FloatFieldHandler.php
@@ -4,34 +4,26 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
class FloatFieldHandler implements CustomLegacyFieldHandlerInterface
{
- /**
- * {@inheritdoc}
- */
public function supports(Value $value): bool
{
return $value instanceof FloatValue;
}
- /**
- * {@inheritdoc}
- */
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
return (string) $value;
}
/**
- * @param \eZ\Publish\Core\FieldType\Float\Value $value
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
+ * @param \Ibexa\Core\FieldType\Float\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Persistence/FieldHandler/Custom/IntegerFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/IntegerFieldHandler.php
index 16fc44ba..7f3e5631 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/IntegerFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/IntegerFieldHandler.php
@@ -4,34 +4,26 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Integer\Value as IntegerValue;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Integer\Value as IntegerValue;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
class IntegerFieldHandler implements CustomLegacyFieldHandlerInterface
{
- /**
- * {@inheritdoc}
- */
public function supports(Value $value): bool
{
return $value instanceof IntegerValue;
}
- /**
- * {@inheritdoc}
- */
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
return (string) $value;
}
/**
- * @param \eZ\Publish\Core\FieldType\Integer\Value $value
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
+ * @param \Ibexa\Core\FieldType\Integer\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
diff --git a/lib/Core/Persistence/FieldHandler/Custom/TimeFieldHandler.php b/lib/Core/Persistence/FieldHandler/Custom/TimeFieldHandler.php
index 0dca1d4f..22e97a27 100644
--- a/lib/Core/Persistence/FieldHandler/Custom/TimeFieldHandler.php
+++ b/lib/Core/Persistence/FieldHandler/Custom/TimeFieldHandler.php
@@ -4,37 +4,29 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\FieldType\Time\Value as TimeValue;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\Time\Value as TimeValue;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
class TimeFieldHandler implements CustomLegacyFieldHandlerInterface
{
- /**
- * {@inheritdoc}
- */
public function supports(Value $value): bool
{
return $value instanceof TimeValue;
}
- /**
- * {@inheritdoc}
- */
public function toString(Value $value, FieldDefinition $fieldDefinition): string
{
return (string) $value;
}
/**
- * @param \eZ\Publish\Core\FieldType\Time\Value $value
- *
- * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
+ * @param \Ibexa\Core\FieldType\Time\Value $value
*/
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
{
- return FieldValue::withIntValue($fieldDefinition->id, (int)$value->time);
+ return FieldValue::withIntValue($fieldDefinition->id, (int) $value->time);
}
}
diff --git a/lib/Core/Persistence/FieldHandler/FieldHandlerRegistry.php b/lib/Core/Persistence/FieldHandler/FieldHandlerRegistry.php
index 161ef70a..b3c0e633 100644
--- a/lib/Core/Persistence/FieldHandler/FieldHandlerRegistry.php
+++ b/lib/Core/Persistence/FieldHandler/FieldHandlerRegistry.php
@@ -4,21 +4,13 @@
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler;
-use eZ\Publish\Core\FieldType\Value;
+use Ibexa\Core\FieldType\Value;
use Netgen\InformationCollection\API\FieldHandler\CustomFieldHandlerInterface;
final class FieldHandlerRegistry
{
- /**
- * @var array
- */
- protected $handlers;
+ private iterable $handlers;
- /**
- * FieldHandlerRegistry constructor.
- *
- * @param array $handlers
- */
public function __construct(iterable $handlers)
{
$this->handlers = $handlers;
@@ -26,19 +18,12 @@ public function __construct(iterable $handlers)
/**
* Adds new handler.
- *
- * @param CustomFieldHandlerInterface $handler
*/
public function addHandler(CustomFieldHandlerInterface $handler): void
{
$this->handlers[] = $handler;
}
- /**
- * @param Value $value
- *
- * @return CustomFieldHandlerInterface|null
- */
public function handle(Value $value): ?CustomFieldHandlerInterface
{
/** @var CustomFieldHandlerInterface $handler */
diff --git a/lib/Core/Persistence/Gateway/DoctrineDatabase.php b/lib/Core/Persistence/Gateway/DoctrineDatabase.php
index d1a2eb1f..fe431a46 100644
--- a/lib/Core/Persistence/Gateway/DoctrineDatabase.php
+++ b/lib/Core/Persistence/Gateway/DoctrineDatabase.php
@@ -9,16 +9,8 @@
final class DoctrineDatabase
{
- /**
- * @var \Doctrine\DBAL\Connection
- */
- protected $connection;
+ private Connection $connection;
- /**
- * DoctrineDatabase constructor.
- *
- * @param \Doctrine\DBAL\Connection $connection
- */
public function __construct(Connection $connection)
{
$this->connection = $connection;
@@ -28,15 +20,13 @@ public function __construct(Connection $connection)
* Returns number of content objects that have any collection.
*
* @throws \Doctrine\DBAL\DBALException
- *
- * @return int
*/
public function getContentsWithCollectionsCount(): int
{
$query = $this->connection->createQueryBuilder();
$query->select(
'COUNT(DISTINCT eic.contentobject_id) AS count'
- )
+ )
->from($this->connection->quoteIdentifier('ezinfocollection'), 'eic')
->innerJoin(
'eic',
@@ -65,12 +55,7 @@ public function getContentsWithCollectionsCount(): int
/**
* Returns content objects with their collections.
*
- * @param int $limit
- * @param int $offset
- *
* @throws \Doctrine\DBAL\DBALException
- *
- * @return array
*/
public function getObjectsWithCollections(int $limit, int $offset): array
{
diff --git a/lib/Core/Service/CaptchaService.php b/lib/Core/Service/CaptchaService.php
index 0f2ce802..3a166031 100644
--- a/lib/Core/Service/CaptchaService.php
+++ b/lib/Core/Service/CaptchaService.php
@@ -4,37 +4,27 @@
namespace Netgen\InformationCollection\Core\Service;
-use eZ\Publish\API\Repository\ContentTypeService;
-use eZ\Publish\API\Repository\Values\Content\Location;
-use eZ\Publish\API\Repository\Values\ContentType\ContentType;
-use eZ\Publish\Core\MVC\ConfigResolverInterface;
+use Ibexa\Contracts\Core\Repository\ContentTypeService;
+use Ibexa\Contracts\Core\Repository\Values\Content\Location;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
+use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Netgen\InformationCollection\API\Service\CaptchaService as CaptchaServiceInterface;
use Netgen\InformationCollection\API\Service\CaptchaValue;
-use Netgen\InformationCollection\API\Value\Captcha\ReCaptcha;
use Netgen\InformationCollection\API\Value\Captcha\NullObject;
+use Netgen\InformationCollection\API\Value\Captcha\ReCaptcha;
+use function array_keys;
+use function array_replace;
+use function dump;
+use function in_array;
class CaptchaService implements CaptchaServiceInterface
{
- /**
- * @var array
- */
- protected $config;
+ protected array $config;
- /**
- * @var \eZ\Publish\API\Repository\ContentTypeService
- */
- protected $contentTypeService;
- /**
- * @var ConfigResolverInterface
- */
- private $configResolver;
+ protected ContentTypeService $contentTypeService;
+
+ private ConfigResolverInterface $configResolver;
- /**
- * CaptchaService constructor.
- *
- * @param \eZ\Publish\API\Repository\ContentTypeService $contentTypeService
- * @param array $config
- */
public function __construct(ContentTypeService $contentTypeService, ConfigResolverInterface $configResolver)
{
$this->config = $configResolver->getParameter('captcha', 'netgen_information_collection');
@@ -42,9 +32,6 @@ public function __construct(ContentTypeService $contentTypeService, ConfigResolv
$this->configResolver = $configResolver;
}
- /**
- * {@inheritdoc}
- */
public function isEnabled(Location $location): bool
{
$config = $this->getConfig($location);
@@ -52,9 +39,6 @@ public function isEnabled(Location $location): bool
return $config['enabled'];
}
- /**
- * {@inheritdoc}
- */
public function getSiteKey(Location $location): string
{
$config = $this->getConfig($location);
@@ -62,9 +46,6 @@ public function getSiteKey(Location $location): string
return $config['site_key'];
}
- /**
- * {@inheritdoc}
- */
public function getCaptcha(Location $location): CaptchaValue
{
$config = $this->getConfig($location);
@@ -74,7 +55,7 @@ public function getCaptcha(Location $location): CaptchaValue
if (!empty($config['options'])) {
// if (!empty($config['options']['hostname'])) {
- $reCaptcha->setExpectedHostname('localhost');
+ $reCaptcha->setExpectedHostname('localhost');
// }
// if (!empty($config['options']['apk_package_name'])) {
// $reCaptcha->setExpectedApkPackageName($config['options']['apk_package_name']);
@@ -91,6 +72,7 @@ public function getCaptcha(Location $location): CaptchaValue
}
dump($reCaptcha);
+
return new ReCaptcha($reCaptcha);
}
@@ -100,11 +82,7 @@ public function getCaptcha(Location $location): CaptchaValue
/**
* Returns filtered config for current Location.
*
- * @param \eZ\Publish\API\Repository\Values\Content\Location $location
- *
- * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
- *
- * @return array
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
*/
public function getConfig(Location $location): array
{
@@ -112,17 +90,13 @@ public function getConfig(Location $location): array
$this->getContentType($location)
);
- return (array)array_replace($this->config, $contentTypeConfig);
+ return array_replace($this->config, $contentTypeConfig);
}
/**
* Returns filtered config for current ContentType.
- *
- * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
- *
- * @return array
*/
- protected function getConfigForContentType(ContentType $contentType)
+ protected function getConfigForContentType(ContentType $contentType): array
{
if ($this->hasConfigForContentType($contentType)) {
return $this->config['override_by_type'][$contentType->identifier];
@@ -133,12 +107,8 @@ protected function getConfigForContentType(ContentType $contentType)
/**
* Checks if override exist for given ContentType.
- *
- * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
- *
- * @return bool
*/
- protected function hasConfigForContentType(ContentType $contentType)
+ protected function hasConfigForContentType(ContentType $contentType): bool
{
if (!empty($this->config['override_by_type'])) {
if (in_array($contentType->identifier, array_keys($this->config['override_by_type']), true)) {
@@ -152,13 +122,9 @@ protected function hasConfigForContentType(ContentType $contentType)
/**
* Helper method for retrieving ContentType from Location.
*
- * @param \eZ\Publish\API\Repository\Values\Content\Location $location
- *
- * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
- *
- * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
+ * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
*/
- protected function getContentType(Location $location)
+ protected function getContentType(Location $location): ContentType
{
return $this->contentTypeService
->loadContentType($location->contentInfo->contentTypeId);
diff --git a/lib/Core/Service/ExporterService.php b/lib/Core/Service/ExporterService.php
index b3060c34..705387e9 100644
--- a/lib/Core/Service/ExporterService.php
+++ b/lib/Core/Service/ExporterService.php
@@ -12,23 +12,18 @@
use Netgen\InformationCollection\API\Value\Filter\ContentId;
use Netgen\InformationCollection\Core\Persistence\ContentTypeUtils;
use Symfony\Contracts\Translation\TranslatorInterface;
+use function array_values;
+use function preg_replace;
+use function str_replace;
+use function strip_tags;
class ExporterService implements Exporter
{
- /**
- * @var \Symfony\Contracts\Translation\TranslatorInterface
- */
- protected $translator;
+ protected TranslatorInterface $translator;
- /**
- * @var \Netgen\InformationCollection\Core\Persistence\ContentTypeUtils
- */
- protected $contentTypeUtils;
+ protected ContentTypeUtils $contentTypeUtils;
- /**
- * @var \Netgen\InformationCollection\API\Service\InformationCollection
- */
- protected $informationCollection;
+ protected InformationCollection $informationCollection;
public function __construct(
InformationCollection $informationCollection,
@@ -40,9 +35,6 @@ public function __construct(
$this->informationCollection = $informationCollection;
}
- /**
- * {@inheritdoc}
- */
public function export(ExportCriteria $criteria): Export
{
$fields = $this->contentTypeUtils
@@ -50,8 +42,8 @@ public function export(ExportCriteria $criteria): Export
$fields['created'] = $this->translator->trans('netgen_information_collection_admin_export_created', [], 'netgen_information_collection_admin');
- $collections = $this->informationCollection->getCollections(
- new ContentId($criteria->getContentId()->getContentId(), $criteria->getContentId()->getOffset(), $criteria->getContentId()->getLimit())
+ $collections = $this->informationCollection->filterCollections(
+ $criteria
);
$rows = [];
@@ -66,7 +58,7 @@ public function export(ExportCriteria $criteria): Export
continue;
}
- $row[] = $this->getAttributeValue((int)$fieldId, $collection->getAttributes());
+ $row[] = $this->getAttributeValue((int) $fieldId, $collection->getAttributes());
}
$rows[] = $row;
@@ -79,20 +71,15 @@ public function export(ExportCriteria $criteria): Export
/**
* Get attribute value string.
- *
- * @param int $fieldId
- * @param array $attributes
- *
- * @return string
*/
- protected function getAttributeValue(int $fieldId, array $attributes)
+ protected function getAttributeValue(int $fieldId, array $attributes): string
{
/** @var Attribute $attribute */
foreach ($attributes as $attribute) {
if ($fieldId === $attribute->getFieldDefinition()->id) {
$value = $attribute->getValue();
- $value = str_replace('"', '""', (string)$value);
- $value = str_replace(';', ', ', (string)$value);
+ $value = str_replace('"', '""', (string) $value);
+ $value = str_replace(';', ', ', (string) $value);
$value = strip_tags($value);
$res = preg_replace(['/\r|\n/'], [' '], $value);
diff --git a/lib/Core/Service/InformationCollectionService.php b/lib/Core/Service/InformationCollectionService.php
index 75fdbd33..88f1268d 100644
--- a/lib/Core/Service/InformationCollectionService.php
+++ b/lib/Core/Service/InformationCollectionService.php
@@ -4,12 +4,13 @@
namespace Netgen\InformationCollection\Core\Service;
-use eZ\Publish\API\Repository\Exceptions\NotFoundException;
-use eZ\Publish\API\Repository\Repository;
-use eZ\Publish\API\Repository\Values\User\UserReference;
+use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
+use Ibexa\Contracts\Core\Repository\Repository;
+use Ibexa\Contracts\Core\Repository\Values\User\User;
use Netgen\InformationCollection\API\Exception\PersistingFailedException;
use Netgen\InformationCollection\API\Exception\StoringAttributeFailedException;
use Netgen\InformationCollection\API\Exception\StoringCollectionFailedException;
+use Netgen\InformationCollection\API\Factory\FieldValueFactoryInterface;
use Netgen\InformationCollection\API\Service\InformationCollection;
use Netgen\InformationCollection\API\Value\Attribute;
use Netgen\InformationCollection\API\Value\Collection;
@@ -28,54 +29,26 @@
use Netgen\InformationCollection\API\Value\InformationCollectionStruct;
use Netgen\InformationCollection\API\Value\ObjectCount;
use Netgen\InformationCollection\API\Value\SearchCount;
-use Netgen\InformationCollection\API\Factory\FieldValueFactoryInterface;
use Netgen\InformationCollection\Core\Mapper\DomainObjectMapper;
use Netgen\InformationCollection\Core\Persistence\Gateway\DoctrineDatabase;
use Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionAttributeRepository;
use Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionRepository;
+use function count;
class InformationCollectionService implements InformationCollection
{
- /**
- * @var \Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionRepository
- */
- protected $ezInfoCollectionRepository;
-
- /**
- * @var \Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionAttributeRepository
- */
- protected $ezInfoCollectionAttributeRepository;
-
- /**
- * @var \eZ\Publish\API\Repository\Repository
- */
- protected $repository;
-
- /**
- * @var \Netgen\InformationCollection\Core\Persistence\Gateway\DoctrineDatabase
- */
- protected $gateway;
-
- /**
- * @var \Netgen\InformationCollection\API\Factory\FieldValueFactoryInterface
- */
- protected $fieldsFactory;
-
- /**
- * @var \Netgen\InformationCollection\Core\Mapper\DomainObjectMapper
- */
- protected $objectMapper;
-
- /**
- * InformationCollectionService constructor.
- *
- * @param \Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionRepository $ezInfoCollectionRepository
- * @param \Netgen\InformationCollection\Doctrine\Repository\EzInfoCollectionAttributeRepository $ezInfoCollectionAttributeRepository
- * @param \eZ\Publish\API\Repository\Repository $repository
- * @param \Netgen\InformationCollection\Core\Persistence\Gateway\DoctrineDatabase $gateway
- * @param \Netgen\InformationCollection\API\Factory\FieldValueFactoryInterface $factory
- * @param \Netgen\InformationCollection\Core\Mapper\DomainObjectMapper $objectMapper
- */
+ protected EzInfoCollectionRepository $ezInfoCollectionRepository;
+
+ protected EzInfoCollectionAttributeRepository $ezInfoCollectionAttributeRepository;
+
+ protected Repository $repository;
+
+ protected DoctrineDatabase $gateway;
+
+ protected FieldValueFactoryInterface $fieldsFactory;
+
+ protected DomainObjectMapper $objectMapper;
+
public function __construct(
EzInfoCollectionRepository $ezInfoCollectionRepository,
EzInfoCollectionAttributeRepository $ezInfoCollectionAttributeRepository,
@@ -138,9 +111,6 @@ public function getObjectsWithCollectionsCount(): ObjectCount
);
}
- /**
- * {@inheritdoc}
- */
public function getObjectsWithCollections(Query $query): ContentsWithCollections
{
$objects = $this->gateway->getObjectsWithCollections($query->getLimit(), $query->getOffset());
@@ -191,7 +161,13 @@ public function getCollections(ContentId $contentId): Collections
public function filterCollections(FilterCriteria $criteria): Collections
{
- // TODO: Implement filterCollections() method.
+ $collections = $this->ezInfoCollectionRepository->findByExportCriteria($criteria);
+
+ $mapped = array_map(function($collection) {
+ return $this->loadCollection($collection->getId());
+ }, $collections);
+
+ return new Collections($mapped, sizeof($mapped));
}
public function searchCount(SearchCountQuery $query): SearchCount
@@ -209,9 +185,6 @@ public function searchCount(SearchCountQuery $query): SearchCount
return new SearchCount(count($collections));
}
- /**
- * {@inheritdoc}
- */
public function search(SearchQuery $query): Collections
{
$collections = $this->ezInfoCollectionAttributeRepository
@@ -234,17 +207,11 @@ public function search(SearchQuery $query): Collections
return new Collections($objects, count($objects));
}
- /**
- * {@inheritdoc}
- */
public function getCollection(CollectionId $collectionId): Collection
{
return $this->loadCollection($collectionId->getCollectionId());
}
- /**
- * {@inheritdoc}
- */
public function deleteCollectionFields(CollectionFields $collectionFields): void
{
$attributes = $this->ezInfoCollectionAttributeRepository
@@ -259,9 +226,6 @@ public function deleteCollectionFields(CollectionFields $collectionFields): void
$this->ezInfoCollectionAttributeRepository->remove($attributes);
}
- /**
- * {@inheritdoc}
- */
public function deleteCollections(FilterCollections $collections): void
{
$collections = $this->ezInfoCollectionRepository
@@ -278,9 +242,6 @@ public function deleteCollections(FilterCollections $collections): void
$this->ezInfoCollectionRepository->remove($collections);
}
- /**
- * {@inheritdoc}
- */
public function deleteCollectionByContent(Contents $contents): void
{
$collections = $this->ezInfoCollectionRepository
@@ -296,21 +257,12 @@ public function deleteCollectionByContent(Contents $contents): void
$this->ezInfoCollectionRepository->remove($collections);
}
- /**
- * {@inheritdoc}
- */
public function updateCollectionAttribute(CollectionId $collectionId, Attribute $attribute): void
{
$this->ezInfoCollectionAttributeRepository->updateByCollectionId($collectionId, $attribute);
}
- /**
- * @param int $userId
- * @param mixed $userId
- *
- * @return \eZ\Publish\API\Repository\Values\User\User
- */
- protected function getUser($userId)
+ protected function getUser(int $userId): User
{
try {
return $this->repository
@@ -320,12 +272,7 @@ protected function getUser($userId)
}
}
- /**
- * @param int $collectionId
- *
- * @return \Netgen\InformationCollection\API\Value\Collection
- */
- protected function loadCollection($collectionId)
+ protected function loadCollection(int $collectionId): Collection
{
$collection = $this->ezInfoCollectionRepository->loadCollection($collectionId);
$attributes = $this->ezInfoCollectionAttributeRepository->findBy(
diff --git a/lib/Doctrine/Entity/EzInfoCollection.php b/lib/Doctrine/Entity/EzInfoCollection.php
index ff29ee31..25dab7b2 100644
--- a/lib/Doctrine/Entity/EzInfoCollection.php
+++ b/lib/Doctrine/Entity/EzInfoCollection.php
@@ -6,128 +6,74 @@
class EzInfoCollection
{
- /**
- * @var int
- */
- private $id;
-
- /**
- * @var int
- */
- private $contentObjectId;
-
- /**
- * @var int
- */
- private $created;
-
- /**
- * @var int
- */
- private $creatorId;
-
- /**
- * @var int
- */
- private $modified;
-
- /**
- * @var string
- */
- private $userIdentifier;
-
- /**
- * @return int
- */
- public function getId()
+ private int $id;
+
+ private int $contentObjectId;
+
+ private int $created;
+
+ private int $creatorId;
+
+ private int $modified;
+
+ private string $userIdentifier;
+
+ public function getId(): int
{
return $this->id;
}
- /**
- * @return int
- */
- public function getContentObjectId()
+ public function getContentObjectId(): int
{
return $this->contentObjectId;
}
- /**
- * @param int $id
- */
- public function setId($id)
+ public function setId(int $id): void
{
$this->id = $id;
}
- /**
- * @param int $contentObjectId
- */
- public function setContentObjectId($contentObjectId)
+ public function setContentObjectId(int $contentObjectId): void
{
$this->contentObjectId = $contentObjectId;
}
- /**
- * @param int $created
- */
- public function setCreated($created)
+ public function setCreated(int $created): void
{
$this->created = $created;
}
- /**
- * @param int $creatorId
- */
- public function setCreatorId($creatorId)
+ public function setCreatorId(int $creatorId): void
{
$this->creatorId = $creatorId;
}
- /**
- * @param int $modified
- */
- public function setModified($modified)
+ public function setModified(int $modified): void
{
$this->modified = $modified;
}
- /**
- * @param string $userIdentifier
- */
- public function setUserIdentifier($userIdentifier)
+ public function setUserIdentifier(string $userIdentifier): void
{
$this->userIdentifier = $userIdentifier;
}
- /**
- * @return int
- */
- public function getCreated()
+ public function getCreated(): int
{
return $this->created;
}
- /**
- * @return int
- */
- public function getCreatorId()
+ public function getCreatorId(): int
{
return $this->creatorId;
}
- /**
- * @return int
- */
- public function getModified()
+ public function getModified(): int
{
return $this->modified;
}
- /**
- * @return string
- */
- public function getUserIdentifier()
+ public function getUserIdentifier(): string
{
return $this->userIdentifier;
}
diff --git a/lib/Doctrine/Entity/EzInfoCollectionAttribute.php b/lib/Doctrine/Entity/EzInfoCollectionAttribute.php
index 548ec999..1c0fd90f 100644
--- a/lib/Doctrine/Entity/EzInfoCollectionAttribute.php
+++ b/lib/Doctrine/Entity/EzInfoCollectionAttribute.php
@@ -6,170 +6,98 @@
class EzInfoCollectionAttribute
{
- /**
- * @var int
- */
- private $id;
-
- /**
- * @var int
- */
- private $contentClassAttributeId;
-
- /**
- * @var int
- */
- private $contentObjectAttributeId;
-
- /**
- * @var int
- */
- private $contentObjectId;
-
- /**
- * @var float
- */
- private $dataFloat;
-
- /**
- * @var int
- */
- private $dataInt;
-
- /**
- * @var string
- */
- private $dataText;
-
- /**
- * @var int
- */
- private $informationCollectionId;
-
- /**
- * @param int $id
- */
- public function setId($id)
+ private int $id;
+
+ private int $contentClassAttributeId;
+
+ private int $contentObjectAttributeId;
+
+ private int $contentObjectId;
+
+ private float $dataFloat;
+
+ private int $dataInt;
+
+ private string $dataText;
+
+ private int $informationCollectionId;
+
+ public function setId(int $id): void
{
$this->id = $id;
}
- /**
- * @param int $contentClassAttributeId
- */
- public function setContentClassAttributeId($contentClassAttributeId)
+ public function setContentClassAttributeId(int $contentClassAttributeId): void
{
$this->contentClassAttributeId = $contentClassAttributeId;
}
- /**
- * @param int $contentObjectAttributeId
- */
- public function setContentObjectAttributeId($contentObjectAttributeId)
+ public function setContentObjectAttributeId(int $contentObjectAttributeId): void
{
$this->contentObjectAttributeId = $contentObjectAttributeId;
}
- /**
- * @param int $contentObjectId
- */
- public function setContentObjectId($contentObjectId)
+ public function setContentObjectId(int $contentObjectId): void
{
$this->contentObjectId = $contentObjectId;
}
- /**
- * @param float $dataFloat
- */
- public function setDataFloat($dataFloat)
+ public function setDataFloat(float $dataFloat): void
{
$this->dataFloat = $dataFloat;
}
- /**
- * @param int $dataInt
- */
- public function setDataInt($dataInt)
+ public function setDataInt(int $dataInt): void
{
$this->dataInt = $dataInt;
}
- /**
- * @param string $dataText
- */
- public function setDataText($dataText)
+ public function setDataText(string $dataText): void
{
$this->dataText = $dataText;
}
- /**
- * @param int $informationCollectionId
- */
- public function setInformationCollectionId($informationCollectionId)
+ public function setInformationCollectionId(int $informationCollectionId): void
{
$this->informationCollectionId = $informationCollectionId;
}
- /**
- * @return int
- */
- public function getId()
+ public function getId(): int
{
return $this->id;
}
- /**
- * @return int
- */
- public function getContentClassAttributeId()
+ public function getContentClassAttributeId(): int
{
return $this->contentClassAttributeId;
}
- /**
- * @return int
- */
- public function getContentObjectAttributeId()
+ public function getContentObjectAttributeId(): int
{
return $this->contentObjectAttributeId;
}
- /**
- * @return int
- */
- public function getContentObjectId()
+ public function getContentObjectId(): int
{
return $this->contentObjectId;
}
- /**
- * @return float
- */
- public function getDataFloat()
+ public function getDataFloat(): float
{
return $this->dataFloat;
}
- /**
- * @return int
- */
- public function getDataInt()
+ public function getDataInt(): int
{
return $this->dataInt;
}
- /**
- * @return string
- */
- public function getDataText()
+ public function getDataText(): string
{
return $this->dataText;
}
- /**
- * @return int
- */
- public function getInformationCollectionId()
+ public function getInformationCollectionId(): int
{
return $this->informationCollectionId;
}
diff --git a/lib/Doctrine/Repository/EzInfoCollectionAttributeRepository.php b/lib/Doctrine/Repository/EzInfoCollectionAttributeRepository.php
index 7924a27b..f4069e79 100644
--- a/lib/Doctrine/Repository/EzInfoCollectionAttributeRepository.php
+++ b/lib/Doctrine/Repository/EzInfoCollectionAttributeRepository.php
@@ -9,8 +9,8 @@
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\ORMInvalidArgumentException;
-use eZ\Publish\API\Repository\Values\Content\Content;
-use eZ\Publish\API\Repository\Values\Content\Field;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\Content\Field;
use Netgen\InformationCollection\API\Exception\RemoveAttributeFailedException;
use Netgen\InformationCollection\API\Exception\RetrieveCountException;
use Netgen\InformationCollection\API\Exception\StoringAttributeFailedException;
@@ -19,15 +19,15 @@
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
use Netgen\InformationCollection\Doctrine\Entity\EzInfoCollection;
use Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute;
+use function array_column;
+use function mb_strtolower;
class EzInfoCollectionAttributeRepository extends EntityRepository
{
/**
* Get new \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute instance.
- *
- * @return \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute
*/
- public function getInstance()
+ public function getInstance(): EzInfoCollectionAttribute
{
return new EzInfoCollectionAttribute();
}
@@ -55,16 +55,14 @@ public function createNewFromValues(Content $content, EzInfoCollection $collecti
/**
* Save object.
*
- * @param \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute $infoCollectionAttribute
- *
- * @throws StoringAttributeFailedException
+ * @throws \Netgen\InformationCollection\API\Exception\StoringAttributeFailedException
*/
- public function save(EzInfoCollectionAttribute $infoCollectionAttribute)
+ public function save(EzInfoCollectionAttribute $infoCollectionAttribute): void
{
try {
$this->_em->persist($infoCollectionAttribute);
$this->_em->flush($infoCollectionAttribute);
- } catch (ORMException | ORMInvalidArgumentException $exception) {
+ } catch (ORMException|ORMInvalidArgumentException $exception) {
throw new StoringAttributeFailedException('', '');
}
}
@@ -72,9 +70,9 @@ public function save(EzInfoCollectionAttribute $infoCollectionAttribute)
/**
* @param \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute[] $attributes
*
- * @throws ORMException
+ * @throws \Doctrine\ORM\ORMException
*/
- public function remove(array $attributes)
+ public function remove(array $attributes): void
{
try {
foreach ($attributes as $attribute) {
@@ -82,12 +80,12 @@ public function remove(array $attributes)
}
$this->_em->flush();
- } catch (ORMException | ORMInvalidArgumentException $exception) {
- throw new RemoveAttributeFailedException('', '');
+ } catch (ORMException|ORMInvalidArgumentException $exception) {
+ throw new RemoveAttributeFailedException('', '');
}
}
- public function findByCollectionIdAndFieldDefinitionIds($collectionId, $fieldDefinitionIds)
+ public function findByCollectionIdAndFieldDefinitionIds(int $collectionId, array $fieldDefinitionIds): array
{
$qb = $this->createQueryBuilder('eica');
@@ -100,7 +98,7 @@ public function findByCollectionIdAndFieldDefinitionIds($collectionId, $fieldDef
->getResult();
}
- public function updateByCollectionId(CollectionId $collectionId, Attribute $attribute)
+ public function updateByCollectionId(CollectionId $collectionId, Attribute $attribute): void
{
$entity = $this->findOneBy([
'informationCollectionId' => $collectionId->getCollectionId(),
@@ -119,7 +117,7 @@ public function updateByCollectionId(CollectionId $collectionId, Attribute $attr
$this->_em->flush();
}
- public function findByCollectionId($collectionId)
+ public function findByCollectionId(int $collectionId): array
{
$qb = $this->createQueryBuilder('eica');
@@ -130,7 +128,7 @@ public function findByCollectionId($collectionId)
->getResult();
}
- public function getCountByContentId($contentId)
+ public function getCountByContentId(int $contentId): int
{
try {
return (int) $this->createQueryBuilder('eica')
@@ -139,12 +137,12 @@ public function getCountByContentId($contentId)
->select('COUNT(eica) as children_count')
->getQuery()
->getSingleScalarResult();
- } catch (NonUniqueResultException | NoResultException $exception) {
+ } catch (NonUniqueResultException|NoResultException $exception) {
throw new RetrieveCountException('', '');
}
}
- public function search($contentId, $searchText)
+ public function search(int $contentId, string $searchText): array
{
$searchText = mb_strtolower($searchText);
diff --git a/lib/Doctrine/Repository/EzInfoCollectionRepository.php b/lib/Doctrine/Repository/EzInfoCollectionRepository.php
index a12f562b..4273863b 100644
--- a/lib/Doctrine/Repository/EzInfoCollectionRepository.php
+++ b/lib/Doctrine/Repository/EzInfoCollectionRepository.php
@@ -10,37 +10,32 @@
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\ORMInvalidArgumentException;
-use eZ\Publish\API\Repository\Values\Content\Content;
-use eZ\Publish\API\Repository\Values\User\User;
+use Ibexa\Contracts\Core\Repository\Values\Content\Content;
+use Ibexa\Contracts\Core\Repository\Values\User\User;
use Netgen\InformationCollection\API\Exception\RemoveCollectionFailedException;
use Netgen\InformationCollection\API\Exception\RetrieveCountException;
use Netgen\InformationCollection\API\Exception\StoringCollectionFailedException;
+use Netgen\InformationCollection\API\Value\Filter\FilterCriteria;
use Netgen\InformationCollection\Doctrine\Entity\EzInfoCollection;
class EzInfoCollectionRepository extends EntityRepository
{
/**
* Get new \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollection instance.
- *
- * @return \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollection
*/
- public function getInstance()
+ public function getInstance(): EzInfoCollection
{
return new EzInfoCollection();
}
- public function loadCollection(int $collectionId)
+ public function loadCollection(int $collectionId): ?EzInfoCollection
{
- $collection = $this->findOneBy(['id' => $collectionId]);
-
- if ($collection instanceof EzInfoCollection) {
- return $collection;
- }
+ return $this->findOneBy(['id' => $collectionId]);
}
- public function getFirstCollection(int $contentId): EzInfoCollection
+ public function getFirstCollection(int $contentId): ?EzInfoCollection
{
- $collection = $this->findOneBy(
+ return $this->findOneBy(
[
'contentObjectId' => $contentId,
],
@@ -48,15 +43,11 @@ public function getFirstCollection(int $contentId): EzInfoCollection
'created' => 'ASC',
]
);
-
- if ($collection instanceof EzInfoCollection) {
- return $collection;
- }
}
- public function getLastCollection(int $contentId): EzInfoCollection
+ public function getLastCollection(int $contentId): ?EzInfoCollection
{
- $collection = $this->findOneBy(
+ return $this->findOneBy(
[
'contentObjectId' => $contentId,
],
@@ -64,10 +55,6 @@ public function getLastCollection(int $contentId): EzInfoCollection
'created' => 'DESC',
]
);
-
- if ($collection instanceof EzInfoCollection) {
- return $collection;
- }
}
public function createNewFromValues(Content $content, User $user): EzInfoCollection
@@ -87,26 +74,22 @@ public function createNewFromValues(Content $content, User $user): EzInfoCollect
/**
* Save object.
*
- * @param \Netgen\InformationCollection\Doctrine\Entity\EzInfoCollection $informationCollection
- *
- * @throws StoringCollectionFailedException
+ * @throws \Netgen\InformationCollection\API\Exception\StoringCollectionFailedException
*/
- public function save(EzInfoCollection $informationCollection)
+ public function save(EzInfoCollection $informationCollection): void
{
try {
$this->_em->persist($informationCollection);
$this->_em->flush($informationCollection);
- } catch (ORMException | ORMInvalidArgumentException $e) {
+ } catch (ORMException|ORMInvalidArgumentException $e) {
throw new StoringCollectionFailedException('', '');
}
}
/**
- * @param array $collections
- *
- * @throws RemoveCollectionFailedException
+ * @throws \Netgen\InformationCollection\API\Exception\RemoveCollectionFailedException
*/
- public function remove(array $collections)
+ public function remove(array $collections): void
{
try {
foreach ($collections as $collection) {
@@ -114,12 +97,12 @@ public function remove(array $collections)
}
$this->_em->flush();
- } catch (ORMException | ORMInvalidArgumentException $e) {
+ } catch (ORMException|ORMInvalidArgumentException $e) {
throw new RemoveCollectionFailedException('', '');
}
}
- public function findByContentId($contentId)
+ public function findByContentId(int $contentId): array
{
$qb = $this->createQueryBuilder('ezc');
@@ -130,7 +113,7 @@ public function findByContentId($contentId)
->getResult();
}
- public function findByContentIdOlderThan($contentId, DateTimeImmutable $date)
+ public function findByContentIdOlderThan(int $contentId, DateTimeImmutable $date): array
{
$qb = $this->createQueryBuilder('ezc');
@@ -142,7 +125,7 @@ public function findByContentIdOlderThan($contentId, DateTimeImmutable $date)
->getResult();
}
- public function getChildrenCount($contentId)
+ public function getChildrenCount(int $contentId): int
{
try {
return (int) $this->createQueryBuilder('ezc')
@@ -151,8 +134,28 @@ public function getChildrenCount($contentId)
->select('COUNT(ezc) as children_count')
->getQuery()
->getSingleScalarResult();
- } catch (NonUniqueResultException | NoResultException $e) {
+ } catch (NonUniqueResultException|NoResultException $e) {
throw new RetrieveCountException('', '');
}
}
+
+ public function findByExportCriteria(FilterCriteria $criteria): array
+ {
+ $qb = $this->createQueryBuilder('ezc');
+
+ $query = $qb->select('ezc')
+ ->where('ezc.contentObjectId = :contentObjectId')
+ ->setParameter('contentObjectId', $criteria->getContentId()->getContentId())
+ ->setParameter('from', $criteria->getFrom()->getTimestamp())
+ ->setParameter('to', $criteria->getTo()->getTimestamp())
+ ->andWhere($qb->expr()->andX(
+ $qb->expr()->gte('ezc.created', ':from'),
+ $qb->expr()->lte('ezc.created', ':to')
+ ))
+ ->getQuery();
+
+ $sql = $query->getSQL();
+
+ return $query->getResult();
+ }
}
diff --git a/lib/Doctrine/mappings/EzInfoCollection.orm.xml b/lib/Doctrine/mappings/EzInfoCollection.orm.xml
index 3d3e8068..385e739d 100644
--- a/lib/Doctrine/mappings/EzInfoCollection.orm.xml
+++ b/lib/Doctrine/mappings/EzInfoCollection.orm.xml
@@ -10,7 +10,7 @@
table="ezinfocollection"
>
-
+
diff --git a/lib/GraphQL/Mutation/CollectInformationMutation.php b/lib/GraphQL/Mutation/CollectInformationMutation.php
new file mode 100644
index 00000000..2e2bce96
--- /dev/null
+++ b/lib/GraphQL/Mutation/CollectInformationMutation.php
@@ -0,0 +1,107 @@
+locationService = $locationService;
+ $this->informationCollectionHandler = $informationCollectionHandler;
+ $this->formFactory = $formFactory;
+ $this->nameHelper = $nameHelper;
+ }
+
+ public function performInformationCollection(int $locationId, array $input)
+ {
+ $location = $this->locationService->loadLocation($locationId);
+
+ $content = $location->getContent();
+ $contentType = $content->getContentType();
+ $informationCollectionMapper = new InformationCollectionMapper();
+
+ $data = $informationCollectionMapper->mapToFormData($content, $location, $contentType);
+
+ $form = $this->formFactory->create(
+ InformationCollectionType::class,
+ $data,
+ [
+ 'languageCode' => $content->contentInfo->mainLanguageCode,
+ 'mainLanguageCode' => $content->contentInfo->mainLanguageCode,
+ 'csrf_protection' => false
+ ]
+ );
+
+ $transformedInput = [];
+ /** @var FieldDefinition $fieldDefinition */
+ foreach ($contentType->getFieldDefinitions() as $fieldDefinition) {
+ $graphQlFieldName = $this->nameHelper->fieldDefinitionField($fieldDefinition);
+ $inputElement = $input[$graphQlFieldName] ?? null;
+ if (!$inputElement) {
+ continue;
+ }
+
+ $transformedInput[$fieldDefinition->identifier] = [
+ 'value' => $fieldDefinition->fieldTypeIdentifier === 'ezselection' ? implode("-", (array)$inputElement) : $inputElement
+ ];
+ }
+
+ $form->submit($transformedInput);
+ if ($form->isSubmitted() && $form->isValid()) {
+ $collectedData = $form->getData();
+ $this->informationCollectionHandler->handle($collectedData, []);
+ return [
+ 'success' => true
+ ];
+ }
+
+ return [
+ 'success' => false,
+ 'errors' => array_map(
+ static function (FormError $formError) {
+ return [
+ 'message' => $formError->getMessage(),
+ 'fieldIdentifier' => $formError->getOrigin() ? $formError->getOrigin()->getParent()->getName() : "unknown"
+ ];
+ },
+ iterator_to_array($form->getErrors(true))
+ )
+ ];
+ }
+
+
+ public static function getAliases(): array
+ {
+ return [
+ 'performInformationCollection' => 'CollectInformation'
+ ];
+ }
+}
\ No newline at end of file
diff --git a/lib/GraphQL/Schema/Domain/InformationCollectionDomain.php b/lib/GraphQL/Schema/Domain/InformationCollectionDomain.php
new file mode 100644
index 00000000..9ea18c91
--- /dev/null
+++ b/lib/GraphQL/Schema/Domain/InformationCollectionDomain.php
@@ -0,0 +1,205 @@
+contentTypeService = $contentTypeService;
+ $this->nameHelper = $nameHelper;
+ $this->typesMap = $typesMap;
+ }
+
+ public function init(Builder $schema)
+ {
+ $contentTypes = $this->getCollectingContentTypes();
+ if ($contentTypes === null) {
+ return;
+ }
+
+ $schema->addType(
+ new Builder\Input\Type(
+ 'InformationCollectionContentTypes',
+ 'enum'
+ )
+ );
+
+ foreach ($contentTypes as $contentType) {
+ $schema->addValueToEnum(
+ 'InformationCollectionContentTypes',
+ new Builder\Input\EnumValue($this->nameHelper->domainContentTypeName($contentType))
+ );
+ }
+
+ $this->addInformationCollectionResultTypes($schema);
+ }
+
+ public function iterate(): Generator
+ {
+ $types = $this->getCollectingContentTypes();
+ foreach ($types as $type) {
+ yield [self::ARG => $type];
+ }
+ }
+
+ public function work(Builder $schema, array $args)
+ {
+ /** @var ContentType $contentType */
+ $contentType = $args[self::ARG];
+ $fieldDefinitions = $this->getCollectingFieldDefinitions($contentType);
+
+ $collectionContentTypeName = "Collect" . $this->nameHelper->domainContentName($contentType);
+
+ $schema->addType(new Builder\Input\Type(
+ $collectionContentTypeName,
+ 'input-object'
+ ));
+
+ array_walk($fieldDefinitions, function (FieldDefinition $fieldDefinition) use ($schema, $collectionContentTypeName, $contentType) {
+ $schema->addFieldToType(
+ $collectionContentTypeName,
+ new Builder\Input\Field(
+ $this->nameHelper->fieldDefinitionField($fieldDefinition),
+ $this->typesMap[$fieldDefinition->fieldTypeIdentifier]['input_type'] ?? $this->typesMap[$fieldDefinition->fieldTypeIdentifier]['value_type']
+ )
+ );
+ });
+
+ $collectionMutationFieldName = str_replace("create", "collect", $this->nameHelper->domainMutationCreateContentField($contentType));
+
+ // add the specific mutation
+ $schema->addFieldToType(
+ 'DomainContentMutation',
+ new Builder\Input\Field(
+ $collectionMutationFieldName,
+ 'InformationCollectionResult', // update: Return value of collectInformation
+ [
+ 'resolve' => '@=mutation("CollectInformation", [args["locationId"], args["input"]])'
+ ]
+ )
+ );
+
+ $schema->addArgToField(
+ 'DomainContentMutation',
+ $collectionMutationFieldName,
+ new Builder\Input\Arg(
+ 'input',
+ $collectionContentTypeName
+ )
+ );
+
+ $schema->addArgToField(
+ 'DomainContentMutation',
+ $collectionMutationFieldName,
+ new Builder\Input\Arg(
+ 'locationId',
+ "Int!"
+ )
+ );
+ }
+
+ private function addInformationCollectionResultTypes(Builder $schema)
+ {
+ // InformationCollectionError
+ $schema->addType(
+ new Builder\Input\Type(
+ 'InformationCollectionError',
+ 'object'
+ )
+ );
+
+ $schema->addFieldToType(
+ 'InformationCollectionError',
+ new Builder\Input\Field(
+ 'message',
+ 'String!'
+ )
+ );
+
+ $schema->addFieldToType(
+ 'InformationCollectionError',
+ new Builder\Input\Field(
+ 'fieldIdentifier',
+ 'String!'
+ )
+ );
+
+ // InformationCollectionResult
+ $schema->addType(
+ new Builder\Input\Type(
+ 'InformationCollectionResult',
+ 'object'
+ )
+ );
+
+ $schema->addFieldToType(
+ 'InformationCollectionResult',
+ new Builder\Input\Field(
+ 'errors',
+ '[InformationCollectionError]'
+ )
+ );
+
+ $schema->addFieldToType(
+ 'InformationCollectionResult',
+ new Builder\Input\Field(
+ 'success',
+ 'Boolean!'
+ )
+ );
+
+ }
+
+ public function canWork(Builder $schema, array $args)
+ {
+ return array_key_exists(self::ARG, $args);
+ }
+
+ private function getCollectingContentTypes(): Generator
+ {
+ foreach ($this->contentTypeService->loadContentTypeGroups() as $group) {
+ foreach ($this->contentTypeService->loadContentTypes($group) as $type) {
+ if ($this->contentTypeCollectsInformation($type)) {
+ yield $type;
+ }
+ }
+ }
+ }
+
+ private function contentTypeCollectsInformation(ContentType $contentType): bool
+ {
+ return !empty($this->getCollectingFieldDefinitions($contentType));
+ }
+
+ /**
+ * @param ContentType $contentType
+ * @return FieldDefinition[]
+ */
+ private function getCollectingFieldDefinitions(ContentType $contentType): array
+ {
+ $definitions = $contentType->getFieldDefinitions();
+ return array_filter($definitions->toArray(), function (FieldDefinition $fieldDefinition) {
+ return $fieldDefinition->isInfoCollector;
+ });
+ }
+}
\ No newline at end of file
diff --git a/lib/Handler.php b/lib/Handler.php
index b5840d84..bd308093 100644
--- a/lib/Handler.php
+++ b/lib/Handler.php
@@ -1,41 +1,43 @@
formFactory = $formFactory;
$this->contentTypeService = $contentTypeService;
$this->eventDispatcher = $eventDispatcher;
+ $this->configResolver = $configResolver;
}
public function getForm(Content $content, Location $location): FormInterface
@@ -47,11 +49,31 @@ public function getForm(Content $content, Location $location): FormInterface
$data = $informationCollectionMapper->mapToFormData($content, $location, $contentType);
return $this->formFactory->create(InformationCollectionType::class, $data, [
- 'languageCode' => $content->contentInfo->mainLanguageCode,
+ 'languageCode' => $this->determineLanguageToLoad($content),
'mainLanguageCode' => $content->contentInfo->mainLanguageCode,
]);
}
+ /**
+ * @param Content $content
+ * @return string
+ */
+ private function determineLanguageToLoad(Content $content): string
+ {
+ $versionInfo = $content->getVersionInfo();
+
+ $siteAccessLanguagesCodes = (array)$this->configResolver->getParameter('languages');
+ foreach($siteAccessLanguagesCodes as $languageCode)
+ {
+ if (in_array($languageCode, $versionInfo->languageCodes, true))
+ {
+ return $languageCode;
+ }
+ }
+
+ return $content->contentInfo->mainLanguageCode;
+ }
+
public function handle(InformationCollectionStruct $struct, array $options): void
{
$event = new InformationCollected($struct, $options);
diff --git a/lib/Resources/config/actions.yml b/lib/Resources/config/actions.yml
index 45a206f9..3e32d182 100644
--- a/lib/Resources/config/actions.yml
+++ b/lib/Resources/config/actions.yml
@@ -3,36 +3,32 @@ services:
class: Netgen\InformationCollection\Core\Action\ActionRegistry
arguments:
- !tagged_iterator netgen_information_collection.action
- - "@netgen_information_collection.action.config_utility"
+ - '@Netgen\InformationCollection\Core\Action\ConfigurationUtility'
- "@logger"
- "@event_dispatcher"
calls:
- [setDebug, ['%kernel.debug%']]
- netgen_information_collection.action.config_utility:
- class: Netgen\InformationCollection\Core\Action\ConfigurationUtility
+ Netgen\InformationCollection\Core\Action\ConfigurationUtility:
arguments:
- - "@ezpublish.config.resolver"
+ - '@ibexa.config.resolver'
- netgen_information_collection.action.db:
- class: Netgen\InformationCollection\Core\Action\DatabaseAction
+ Netgen\InformationCollection\Core\Action\DatabaseAction:
arguments:
- '@netgen_information_collection.api.service'
tags:
- { name: netgen_information_collection.action, priority: 300 }
- netgen_information_collection.action.email:
- class: Netgen\InformationCollection\Core\Action\EmailAction
+ Netgen\InformationCollection\Core\Action\EmailAction:
arguments:
- - '@netgen_information_collection.mailer'
- - '@netgen_information_collection.factory.email_data'
+ - '@Netgen\InformationCollection\API\MailerInterface'
+ - '@Netgen\InformationCollection\Core\EmailDataProvider\DefaultProvider'
tags:
- { name: netgen_information_collection.action }
-# netgen_information_collection.action.auto_responder:
-# class: Netgen\InformationCollection\Core\Action\AutoResponderAction
-# arguments:
-# - '@netgen_information_collection.factory.auto_responder_data'
-# - '@netgen_information_collection.mailer'
-# tags:
-# - { name: netgen_information_collection.action, alias: auto_responder }
+ Netgen\InformationCollection\Core\Action\AutoResponderAction:
+ arguments:
+ - '@Netgen\InformationCollection\API\MailerInterface'
+ - '@Netgen\InformationCollection\Core\EmailDataProvider\AutoResponderProvider'
+ tags:
+ - { name: netgen_information_collection.action }
diff --git a/lib/Resources/config/admin.yml b/lib/Resources/config/admin.yml
index 5aee1e4c..05388ff4 100644
--- a/lib/Resources/config/admin.yml
+++ b/lib/Resources/config/admin.yml
@@ -5,7 +5,7 @@ services:
arguments:
- "@netgen_information_collection.repository.ez_info_collection"
- "@netgen_information_collection.repository.ez_info_collection_attribute"
- - "@ezpublish.api.repository"
+ - "@ibexa.api.repository"
- "@netgen_information_collection.core.persistence.gateway.doctrine"
- "@netgen_information_collection.factory.field_data"
- "@netgen_information_collection.domain_object_mapper"
@@ -14,7 +14,7 @@ services:
class: Netgen\Bundle\InformationCollectionBundle\Templating\Twig\AdminGlobalVariable
public: true
arguments:
- - "@ezpublish.config.resolver"
+ - "@ibexa.config.resolver"
netgen_information_collection.core.persistence.gateway.doctrine:
class: Netgen\InformationCollection\Core\Persistence\Gateway\DoctrineDatabase
@@ -22,11 +22,10 @@ services:
arguments:
- '@database_connection'
- netgen_information_collection.pagerfanta.view.eztags_admin:
+ netgen_information_collection.pagerfanta.view.information_collection_admin:
class: Netgen\InformationCollection\Core\Pagination\Pagerfanta\View\InformationCollectionAdminView
public: false
- # Not being lazy results in out of memory exceptions on eZ Platform 2.0,
- # probably due to @twig dependency
+ # Not being lazy results in out of memory exceptions, probably due to @twig dependency
lazy: true
arguments:
- "@twig"
@@ -45,8 +44,8 @@ services:
netgen_information_collection.utils.content_type:
class: Netgen\InformationCollection\Core\Persistence\ContentTypeUtils
arguments:
- - "@ezpublish.api.service.content_type"
- - "@ezpublish.api.service.content"
+ - "@ibexa.api.service.content_type"
+ - "@ibexa.api.service.content"
netgen_information_collection.core.export.registry:
class: Netgen\InformationCollection\Core\Export\ExportResponseFormatterRegistry
diff --git a/lib/Resources/config/anonymizers.yml b/lib/Resources/config/anonymizers.yml
index 0ff130bc..1ad4de28 100644
--- a/lib/Resources/config/anonymizers.yml
+++ b/lib/Resources/config/anonymizers.yml
@@ -9,7 +9,7 @@ services:
netgen_information_collection.anonymizer.service:
class: Netgen\InformationCollection\Core\Persistence\Anonymizer\AnonymizerService
arguments:
- - "@ezpublish.api.repository"
+ - "@ibexa.api.repository"
- "@netgen_information_collection.api.service"
- "@netgen_information_collection.anonymizer.visitor.field.aggregate"
diff --git a/lib/Resources/config/email_data_providers.yml b/lib/Resources/config/email_data_providers.yml
new file mode 100644
index 00000000..37e41f26
--- /dev/null
+++ b/lib/Resources/config/email_data_providers.yml
@@ -0,0 +1,8 @@
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Netgen\InformationCollection\Core\EmailDataProvider\:
+ resource: '../../Core/EmailDataProvider/'
+ exclude: '../../Core/EmailDataProvider/AbstractProvider.php'
\ No newline at end of file
diff --git a/lib/Resources/config/ezplatform_admin.yml b/lib/Resources/config/ezplatform_admin.yml
deleted file mode 100644
index 7089a18a..00000000
--- a/lib/Resources/config/ezplatform_admin.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-parameters:
- netgen_information_collection.ezadminui.pagelayout: '@@NetgenInformationCollection/ezadminui/pagelayout.html.twig'
-
-services:
- netgen_information_collection.ezplatform_admin.menu:
- class: Netgen\Bundle\InformationCollectionBundle\EzPlatform\EzPlatformAdmin\MenuListener
- public: true
- tags:
- - { name: kernel.event_subscriber }
-
- netgen_information_collection.ezadminui.event_listener.set_page_layout:
- class: Netgen\Bundle\InformationCollectionBundle\EzPlatform\EzPlatformAdmin\EventListener\SetPageLayoutListener
- arguments:
- - "@netgen_information_collection.templating.admin_global_variable"
- - "%ezpublish.siteaccess.groups_by_siteaccess%"
- - "%netgen_information_collection.ezadminui.pagelayout%"
- tags:
- - { name: kernel.event_subscriber }
diff --git a/lib/Resources/config/factories.yml b/lib/Resources/config/factories.yml
index 049b43c7..c20847cf 100644
--- a/lib/Resources/config/factories.yml
+++ b/lib/Resources/config/factories.yml
@@ -1,18 +1,23 @@
services:
netgen_information_collection.factory.email_data:
- class: Netgen\InformationCollection\Core\Factory\EmailDataFactory
+ alias: Netgen\InformationCollection\Core\Factory\EmailDataFactory
+
+ Netgen\InformationCollection\Core\Factory\EmailDataFactory:
arguments:
- - '@ezpublish.config.resolver'
- - '@ezpublish.translation_helper'
- - '@ezpublish.field_helper'
+ - '@ibexa.config.resolver'
+ - '@Ibexa\Core\Helper\TranslationHelper'
+ - '@Ibexa\Core\Helper\FieldHelper'
- '@twig'
+
netgen_information_collection.factory.auto_responder_data:
- class: Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory
+ alias: Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory
+
+ Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory:
arguments:
- - '@ezpublish.config.resolver'
- - '@ezpublish.translation_helper'
- - '@ezpublish.field_helper'
+ - '@ibexa.config.resolver'
+ - '@Ibexa\Core\Helper\TranslationHelper'
+ - '@Ibexa\Core\Helper\FieldHelper'
- '@twig'
netgen_information_collection.factory.field_data:
diff --git a/lib/Resources/config/graphql.yml b/lib/Resources/config/graphql.yml
new file mode 100644
index 00000000..65437e32
--- /dev/null
+++ b/lib/Resources/config/graphql.yml
@@ -0,0 +1,15 @@
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Netgen\InformationCollection\GraphQL\Mutation\CollectInformationMutation:
+ arguments:
+ $informationCollectionHandler: '@netgen_information_collection.handler'
+
+ Netgen\InformationCollection\GraphQL\Schema\Domain\InformationCollectionDomain:
+ tags:
+ - "ezplatform_graphql.schema_domain_iterator"
+ - "ezplatform_graphql.domain_schema_worker"
+ arguments:
+ $typesMap: '%ezplatform_graphql.schema.content.mapping.field_definition_type%'
\ No newline at end of file
diff --git a/lib/Resources/config/ibexa_admin.yml b/lib/Resources/config/ibexa_admin.yml
new file mode 100644
index 00000000..49d2697c
--- /dev/null
+++ b/lib/Resources/config/ibexa_admin.yml
@@ -0,0 +1,18 @@
+parameters:
+ netgen_information_collection.ibexa.admin.pagelayout: '@@NetgenInformationCollection/ibexa/admin/pagelayout.html.twig'
+
+services:
+ netgen_information_collection.ibexa_admin.menu:
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\Admin\MenuListener
+ public: true
+ tags:
+ - { name: kernel.event_subscriber }
+
+ netgen_information_collection.ibexa.admin.event_listener.set_page_layout:
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\Admin\EventListener\SetPageLayoutListener
+ arguments:
+ - "@netgen_information_collection.templating.admin_global_variable"
+ - "%ibexa.site_access.groups_by_site_access%"
+ - "%netgen_information_collection.ibexa.admin.pagelayout%"
+ tags:
+ - { name: kernel.event_subscriber }
diff --git a/lib/Resources/config/mailers.yml b/lib/Resources/config/mailers.yml
new file mode 100644
index 00000000..fc3bcb78
--- /dev/null
+++ b/lib/Resources/config/mailers.yml
@@ -0,0 +1,9 @@
+services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+
+ Netgen\InformationCollection\Core\Mailer\:
+ resource: '../../Core/Mailer/'
+
+ Netgen\InformationCollection\API\MailerInterface: '@Netgen\InformationCollection\Core\Mailer\SymfonyMailerBasedMailer'
diff --git a/lib/Resources/config/parameters.yml b/lib/Resources/config/parameters.yml
index c6060a83..c0dd0d3f 100644
--- a/lib/Resources/config/parameters.yml
+++ b/lib/Resources/config/parameters.yml
@@ -1,3 +1,3 @@
parameters:
- netgen.default.information_collection.form.use_csrf: true
+ netgen_information_collection.default.form.use_csrf: true
netgen_information_collection.default.action_config.auto_responder: []
diff --git a/lib/Resources/config/services.yml b/lib/Resources/config/services.yml
index 399266dc..7c6eda72 100644
--- a/lib/Resources/config/services.yml
+++ b/lib/Resources/config/services.yml
@@ -5,7 +5,7 @@ imports:
- { resource: legacy_handlers.yml }
- { resource: admin.yml }
- { resource: anonymizers.yml }
- - { resource: ezplatform_admin.yml }
+ - { resource: ibexa_admin.yml }
parameters:
@@ -25,17 +25,27 @@ services:
netgen_information_collection.mailer:
class: Netgen\InformationCollection\Core\Mailer\Mailer
arguments:
- - '@mailer'
+ - 'Netgen\InformationCollection\API\MailerInterface'
netgen_information_collection.form.extension.field_definition:
- class: Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\FieldDefinitionTypeExtension
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms\FieldDefinitionTypeExtension
tags:
- - { name: form.type_extension, extended_type: EzSystems\EzPlatformAdminUi\Form\Type\FieldDefinition\FieldDefinitionType }
+ - { name: form.type_extension, extended_type: Ibexa\AdminUi\Form\Type\FieldDefinition\FieldDefinitionType }
+
+ netgen_information_collection.form.extension.content_field:
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms\ContentFieldTypeExtension
+ tags:
+ - { name: form.type_extension, extended_type: Ibexa\ContentForms\Form\Type\Content\ContentFieldType }
+
+ netgen_information_collection.validator.info_collector:
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms\InfoCollectorContentValidator
+ tags:
+ - { name: ibexa.repository.content.validator, priority: 255 }
netgen_information_collection.domain_object_mapper:
class: Netgen\InformationCollection\Core\Mapper\DomainObjectMapper
arguments:
- - '@ezpublish.api.repository'
+ - '@ibexa.api.repository'
netgen_information_collection.twig.extension.rendering:
@@ -49,21 +59,32 @@ services:
# public: false
arguments:
- '@twig'
- - '@ezpublish.config.resolver'
+ - '@ibexa.config.resolver'
+ tags:
+ - { name: twig.runtime }
+
+ Netgen\Bundle\InformationCollectionBundle\Templating\Twig\Extensions\CaptchaExtension:
+ autowire: true
+ autoconfigure: true
+
+ Netgen\Bundle\InformationCollectionBundle\Templating\Twig\Extensions\CaptchaRuntime:
+ autowire: true
+ autoconfigure: true
tags:
- { name: twig.runtime }
netgen_information_collection.form.information_collection_type:
- class: Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionType
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms\InformationCollectionType
arguments:
- '@netgen_information_collection.captcha.service'
+ - '@ibexa.config.resolver'
tags:
- { name: form.type }
netgen_information_collection.form.information_collection_field_type:
- class: Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionFieldType
+ class: Netgen\Bundle\InformationCollectionBundle\Ibexa\ContentForms\InformationCollectionFieldType
arguments:
- - "@ezplatform.content_forms.field_type_form_mapper.dispatcher"
+ - '@Ibexa\ContentForms\FieldType\FieldTypeFormMapperDispatcher'
tags:
- { name: form.type }
@@ -72,23 +93,31 @@ services:
public: true
arguments:
- "@form.factory"
- - "@ezpublish.api.service.content_type"
+ - "@ibexa.api.service.content_type"
- "@event_dispatcher"
+ - "@ibexa.config.resolver"
+
+ Netgen\InformationCollection\Core\Service\CaptchaService:
+ autowire: true
netgen_information_collection.captcha.service:
class: Netgen\InformationCollection\Core\Service\CaptchaService
arguments:
- - '@ezpublish.api.service.content_type'
- - '@ezpublish.config.resolver'
+ - '@ibexa.api.service.content_type'
+ - '@ibexa.config.resolver'
- netgen_information_collection.export.json:
- class: Netgen\InformationCollection\Core\Export\JsonExportResponseFormatter
+ Netgen\InformationCollection\Core\Export\JsonExportResponseFormatter:
tags:
- { name: netgen_information_collection.export.formatter }
+ netgen_information_collection.export.json:
+ alias: Netgen\InformationCollection\Core\Export\JsonExportResponseFormatter
+
netgen_information_collection.form.captcha_type:
class: Netgen\Bundle\InformationCollectionBundle\Form\CaptchaType
arguments:
- '@netgen_information_collection.listener.captcha_validation'
tags:
- { name: form.type }
+
+ # Autowire the providers
diff --git a/phpstan.neon b/phpstan.neon
index 61fb3047..44f352dc 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -12,16 +12,16 @@ parameters:
- '#Cannot call method fetchColumn\(\) on Doctrine\\DBAL\\Driver\\Statement\|int#'
- '#Parameter \#2 \$y of method Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder::in\(\) expects array\\|string, array\ given#'
- # eZ Platform related errors
+ # Ibexa Platform related errors
-
- message: '#Access to protected property eZ\\Publish\\API\\Repository\\Values\\Content\\Field::\$value#'
+ message: '#Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Field::\$value#'
path: lib/Core/Factory/EmailDataFactory.php
-
- message: '#Access to protected property eZ\\Publish\\Core\\Repository\\Values\\ContentType\\ContentType::\$fieldDefinitionsById#'
+ message: '#Access to protected property Ibexa\\Core\\Repository\\Values\\ContentType\\ContentType::\$fieldDefinitionsById#'
path: lib/Core/Mapper/DomainObjectMapper.php
- - '#Access to protected property eZ\\Publish\\API\\Repository\\Values\\Content\\Field::\$value#'
- - '#Access to an undefined property EzSystems\\RepositoryForms\\Data\\Content\\FieldData::\$email#'
+ - '#Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Field::\$value#'
+ - '#Access to an undefined property Ibexa\\Contracts\\ContentForms\\Data\\Content\\FieldData::\$email#'
# Pagerfanta
- '#Property Netgen\\InformationCollection\\Core\\Pagination\\Pagerfanta\\View\\InformationCollectionAdminView::\$pagerfanta \(Pagerfanta\\Pagerfanta\) does not accept Pagerfanta\\PagerfantaInterface#'
diff --git a/tests/lib/FakeTest.php b/tests/lib/FakeTest.php
index a83b7748..5048a383 100644
--- a/tests/lib/FakeTest.php
+++ b/tests/lib/FakeTest.php
@@ -6,7 +6,7 @@
class FakeTest extends TestCase
{
- public function testItWorks()
+ public function testItWorks(): void
{
$this->assertTrue(true);
}
diff --git a/tests/old/API/Value/InformationCollection/QueryTest.php b/tests/old/API/Value/InformationCollection/QueryTest.php
index 16ccfe39..ea1112cb 100644
--- a/tests/old/API/Value/InformationCollection/QueryTest.php
+++ b/tests/old/API/Value/InformationCollection/QueryTest.php
@@ -7,7 +7,7 @@
class QueryTest extends TestCase
{
- public function testWithContent()
+ public function testWithContent(): void
{
$query = Query::withContent(12);
@@ -17,7 +17,7 @@ public function testWithContent()
$this->assertEmpty($query->fields);
}
- public function testCount()
+ public function testCount(): void
{
$query = Query::count();
@@ -25,7 +25,7 @@ public function testCount()
$this->assertEquals(0, $query->offset);
}
- public function testConstructor()
+ public function testConstructor(): void
{
$values = [
'offset' => 15,
diff --git a/tests/old/Action/ActionRegistryTest.php b/tests/old/Action/ActionRegistryTest.php
index 3ebcf956..5e894671 100644
--- a/tests/old/Action/ActionRegistryTest.php
+++ b/tests/old/Action/ActionRegistryTest.php
@@ -2,92 +2,48 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Action;
-use eZ\Publish\Core\Repository\Values\ContentType\ContentType;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
+use Ibexa\Core\Repository\Values\ContentType\ContentType;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
use Netgen\Bundle\InformationCollectionBundle\Action\ActionInterface;
use Netgen\Bundle\InformationCollectionBundle\Action\ActionRegistry;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use ReflectionObject;
class ActionRegistryTest extends TestCase
{
- /**
- * @var ActionRegistry
- */
- protected $registry;
+ protected ActionRegistry $registry;
- /**
- * @var ActionRegistry
- */
- protected $registryForPriority;
+ protected ActionRegistry $registryForPriority;
- /**
- * @var ActionRegistry
- */
- protected $registryWithEmptyConf;
+ protected ActionRegistry $registryWithEmptyConf;
- /**
- * @var ActionRegistry
- */
- protected $registryWithOnlyDefaultConf;
+ protected ActionRegistry $registryWithOnlyDefaultConf;
- /**
- * @var array
- */
- protected $config;
+ protected array $config;
- /**
- * @var array
- */
- protected $config2;
+ protected array $config2;
- /**
- * @var array
- */
- protected $onlyDefaultConfig;
+ protected array $onlyDefaultConfig;
- /**
- * @var array
- */
- protected $emptyConfig;
+ protected array $emptyConfig;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $action1;
+ protected MockObject $action1;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $action2;
+ protected MockObject $action2;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $action3;
+ protected MockObject $action3;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $action4;
+ protected MockObject $action4;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $logger;
+ protected MockObject $logger;
- /**
- * @var InformationCollected
- */
- protected $event;
+ protected InformationCollected $event;
- /**
- * @var InformationCollected
- */
- protected $event2;
+ protected InformationCollected $event2;
public function setUp(): void
{
@@ -173,13 +129,13 @@ public function setUp(): void
parent::setUp();
}
- public function testAddingActions()
+ public function testAddingActions(): void
{
$this->registry->addAction('database', $this->action1, 1);
$this->registry->addAction('email', $this->action2, 100);
}
- public function testAct()
+ public function testAct(): void
{
$this->registry->addAction('database', $this->action1, 1);
$this->registry->addAction('email', $this->action2, 2);
@@ -194,7 +150,7 @@ public function testAct()
$this->registry->act($this->event);
}
- public function testActWithContentTypeThatDoesNotHaveConfiguration()
+ public function testActWithContentTypeThatDoesNotHaveConfiguration(): void
{
$this->registry->addAction('database', $this->action1, 1);
$this->registry->addAction('email', $this->action2, 2);
@@ -208,7 +164,7 @@ public function testActWithContentTypeThatDoesNotHaveConfiguration()
$this->registry->act($this->event2);
}
- public function testActWithDefaultConfigOnly()
+ public function testActWithDefaultConfigOnly(): void
{
$this->registryWithOnlyDefaultConf->addAction('database', $this->action1, 1);
$this->registryWithOnlyDefaultConf->addAction('email', $this->action2, 2);
@@ -222,7 +178,7 @@ public function testActWithDefaultConfigOnly()
$this->registryWithOnlyDefaultConf->act($this->event2);
}
- public function testActWithEmptyConfig()
+ public function testActWithEmptyConfig(): void
{
$this->registryWithEmptyConf->addAction('database', $this->action1, 1);
$this->registryWithEmptyConf->addAction('email', $this->action2, 2);
@@ -236,7 +192,7 @@ public function testActWithEmptyConfig()
$this->registryWithEmptyConf->act($this->event2);
}
- public function testActWithActionFailedException()
+ public function testActWithActionFailedException(): void
{
$this->registry->addAction('database', $this->action1, 1);
$this->registry->addAction('email', $this->action2, 2);
@@ -257,7 +213,7 @@ public function testActWithActionFailedException()
$this->registry->act($this->event);
}
- public function testActionsAreExecutedByPriority()
+ public function testActionsAreExecutedByPriority(): void
{
$prioritizedActions = array(
array(
@@ -308,7 +264,7 @@ public function testActionsAreExecutedByPriority()
$this->assertEquals($prioritizedActions, $actions->getValue($this->registryForPriority));
}
- public function testActionsAreExecutedByPriorityWithSamePriorities()
+ public function testActionsAreExecutedByPriorityWithSamePriorities(): void
{
$prioritizedActions = array(
array(
@@ -359,7 +315,7 @@ public function testActionsAreExecutedByPriorityWithSamePriorities()
$this->assertEquals($prioritizedActions, $actions->getValue($this->registryForPriority));
}
- public function testSetDebugMethod()
+ public function testSetDebugMethod(): void
{
$this->registryForPriority->addAction('database', $this->action1, 44);
@@ -380,7 +336,7 @@ public function testSetDebugMethod()
* @expectedExceptionMessage InformationCollection action database failed with reason cannot write to database
*/
- public function testThrowExceptionWhenDebugIsTrue()
+ public function testThrowExceptionWhenDebugIsTrue(): void
{
$this->registry->addAction('database', $this->action1, 1);
$this->registry->addAction('email', $this->action2, 2);
diff --git a/tests/old/Action/AutoResponderActionTest.php b/tests/old/Action/AutoResponderActionTest.php
index fbfb82f8..52b9f8d4 100644
--- a/tests/old/Action/AutoResponderActionTest.php
+++ b/tests/old/Action/AutoResponderActionTest.php
@@ -2,39 +2,28 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Action;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
-use Netgen\Bundle\EzFormsBundle\Form\Payload\InformationCollectionStruct;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\Payload\InformationCollectionStruct;
use Netgen\Bundle\InformationCollectionBundle\Action\AutoResponderAction;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException;
use Netgen\Bundle\InformationCollectionBundle\Factory\AutoResponderDataFactory;
use Netgen\Bundle\InformationCollectionBundle\Mailer\MailerInterface;
use Netgen\Bundle\InformationCollectionBundle\Value\EmailData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class AutoResponderActionTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Action\AutoResponderAction
- */
- protected $action;
+ protected AutoResponderAction $action;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $factory;
+ protected MockObject $factory;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $mailer;
+ protected MockObject $mailer;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $emailData;
+ protected MockObject $emailData;
- public function setUp()
+ public function setUp(): void
{
$this->factory = $this->getMockBuilder(AutoResponderDataFactory::class)
->disableOriginalConstructor()
@@ -55,7 +44,7 @@ public function setUp()
parent::setUp();
}
- public function testAct()
+ public function testAct(): void
{
$informationCollectionStruct = new InformationCollectionStruct();
$dataWrapper = new DataWrapper($informationCollectionStruct, null, null);
@@ -77,7 +66,7 @@ public function testAct()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException
* @expectedExceptionMessage Error occurred while trying to send email: test@example.com failed with error invalid email address
*/
- public function testActWithException()
+ public function testActWithException(): void
{
$informationCollectionStruct = new InformationCollectionStruct();
$dataWrapper = new DataWrapper($informationCollectionStruct, null, null);
diff --git a/tests/old/Action/DatabaseActionTest.php b/tests/old/Action/DatabaseActionTest.php
index 24001747..785ac9e7 100644
--- a/tests/old/Action/DatabaseActionTest.php
+++ b/tests/old/Action/DatabaseActionTest.php
@@ -3,18 +3,18 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Action;
use Doctrine\DBAL\DBALException;
-use eZ\Publish\API\Repository\Values\Content\Field;
-use eZ\Publish\Core\FieldType\TextLine\Value as TextLineValue;
-use eZ\Publish\Core\Repository\ContentService;
-use eZ\Publish\Core\Repository\Repository;
-use eZ\Publish\Core\Repository\Values\Content\Content;
-use eZ\Publish\Core\Repository\Values\Content\Location;
-use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
-use eZ\Publish\Core\Repository\Values\ContentType\ContentType;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\User\User;
-use eZ\Publish\SPI\Persistence\Content\ContentInfo;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
+use Ibexa\Contracts\Core\Repository\Values\Content\Field;
+use Ibexa\Core\FieldType\TextLine\Value as TextLineValue;
+use Ibexa\Core\Repository\ContentService;
+use Ibexa\Core\Repository\Repository;
+use Ibexa\Core\Repository\Values\Content\Content;
+use Ibexa\Core\Repository\Values\Content\Location;
+use Ibexa\Core\Repository\Values\Content\VersionInfo;
+use Ibexa\Core\Repository\Values\ContentType\ContentType;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\User\User;
+use Ibexa\Contracts\Core\Persistence\Content\ContentInfo;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
use Netgen\Bundle\InformationCollectionBundle\Form\Payload\InformationCollectionStruct;
use Netgen\Bundle\InformationCollectionBundle\Action\DatabaseAction;
use Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollection;
@@ -24,61 +24,32 @@
use Netgen\Bundle\InformationCollectionBundle\Repository\EzInfoCollectionAttributeRepository;
use Netgen\Bundle\InformationCollectionBundle\Repository\EzInfoCollectionRepository;
use Netgen\Bundle\InformationCollectionBundle\Value\LegacyData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class DatabaseActionTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Action\DatabaseAction
- */
- protected $action;
+ protected DatabaseAction $action;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $factory;
+ protected MockObject $factory;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $repository;
+ protected MockObject $repository;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $secondRepository;
+ protected MockObject $secondRepository;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $ezRepository;
+ protected MockObject $ibexaRepository;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $contentType;
+ protected MockObject $contentType;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $contentService;
+ protected MockObject $contentService;
- /**
- * @var array
- */
- protected $fields;
+ protected array $fields;
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Form\Payload\InformationCollectionStruct
- */
- protected $struct;
+ protected InformationCollectionStruct $struct;
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Value\LegacyData
- */
- protected $legacyData;
+ protected LegacyData $legacyData;
- public function setUp()
+ public function setUp(): void
{
$this->factory = $this->getMockBuilder(FieldDataFactory::class)
->disableOriginalConstructor()
@@ -95,7 +66,7 @@ public function setUp()
->setMethods(array('getInstance', 'save'))
->getMock();
- $this->ezRepository = $this->getMockBuilder(Repository::class)
+ $this->ibexaRepository = $this->getMockBuilder(Repository::class)
->disableOriginalConstructor()
->setMethods(array('getContentService', 'getCurrentUser'))
->getMock();
@@ -160,11 +131,11 @@ public function setUp()
$this->legacyData = new LegacyData(123, 0, 0.0, 'some value');
- $this->action = new DatabaseAction($this->factory, $this->repository, $this->secondRepository, $this->ezRepository);
+ $this->action = new DatabaseAction($this->factory, $this->repository, $this->secondRepository, $this->ibexaRepository);
parent::setUp();
}
- public function testAct()
+ public function testAct(): void
{
$location = new Location(array(
'contentInfo' => new ContentInfo(array(
@@ -198,7 +169,7 @@ public function testAct()
$ezInfoCollection = new EzInfoCollection();
$ezInfoCollectionAttribute = new EzInfoCollectionAttribute();
- $this->ezRepository->expects($this->once())
+ $this->ibexaRepository->expects($this->once())
->method('getContentService')
->willReturn($this->contentService);
@@ -207,7 +178,7 @@ public function testAct()
->with(123)
->willReturn($content);
- $this->ezRepository->expects($this->once())
+ $this->ibexaRepository->expects($this->once())
->method('getCurrentUser')
->willReturn($user);
@@ -237,7 +208,7 @@ public function testAct()
/**
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException
*/
- public function testActWithExceptionOnInformationCollectionRepository()
+ public function testActWithExceptionOnInformationCollectionRepository(): void
{
$location = new Location(array(
'contentInfo' => new ContentInfo(array(
@@ -270,7 +241,7 @@ public function testActWithExceptionOnInformationCollectionRepository()
$ezInfoCollection = new EzInfoCollection();
- $this->ezRepository->expects($this->once())
+ $this->ibexaRepository->expects($this->once())
->method('getContentService')
->willReturn($this->contentService);
@@ -279,7 +250,7 @@ public function testActWithExceptionOnInformationCollectionRepository()
->with(123)
->willReturn($content);
- $this->ezRepository->expects($this->once())
+ $this->ibexaRepository->expects($this->once())
->method('getCurrentUser')
->willReturn($user);
@@ -307,7 +278,7 @@ public function testActWithExceptionOnInformationCollectionRepository()
/**
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException
*/
- public function testActWithExceptionOnInformationCollectionAttributeRepository()
+ public function testActWithExceptionOnInformationCollectionAttributeRepository(): void
{
$location = new Location(array(
'contentInfo' => new ContentInfo(array(
@@ -341,7 +312,7 @@ public function testActWithExceptionOnInformationCollectionAttributeRepository()
$ezInfoCollection = new EzInfoCollection();
$ezInfoCollectionAttribute = new EzInfoCollectionAttribute();
- $this->ezRepository->expects($this->once())
+ $this->ibexaRepository->expects($this->once())
->method('getContentService')
->willReturn($this->contentService);
@@ -350,7 +321,7 @@ public function testActWithExceptionOnInformationCollectionAttributeRepository()
->with(123)
->willReturn($content);
- $this->ezRepository->expects($this->once())
+ $this->ibexaRepository->expects($this->once())
->method('getCurrentUser')
->willReturn($user);
diff --git a/tests/old/Action/EmailActionTest.php b/tests/old/Action/EmailActionTest.php
index bfede996..65c361d1 100644
--- a/tests/old/Action/EmailActionTest.php
+++ b/tests/old/Action/EmailActionTest.php
@@ -2,39 +2,28 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Action;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
-use Netgen\Bundle\EzFormsBundle\Form\Payload\InformationCollectionStruct;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\Payload\InformationCollectionStruct;
use Netgen\Bundle\InformationCollectionBundle\Action\EmailAction;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException;
use Netgen\Bundle\InformationCollectionBundle\Factory\EmailDataFactory;
use Netgen\Bundle\InformationCollectionBundle\Mailer\MailerInterface;
use Netgen\Bundle\InformationCollectionBundle\Value\EmailData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class EmailActionTest extends TestCase
{
- /**
- * @var EmailAction
- */
- protected $action;
+ protected EmailAction $action;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $factory;
+ protected MockObject $factory;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $mailer;
+ protected MockObject $mailer;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $emailData;
+ protected MockObject $emailData;
- public function setUp()
+ public function setUp(): void
{
$this->factory = $this->getMockBuilder(EmailDataFactory::class)
->disableOriginalConstructor()
diff --git a/tests/old/ContentViewStub.php b/tests/old/ContentViewStub.php
index 5114ea24..073dc01e 100644
--- a/tests/old/ContentViewStub.php
+++ b/tests/old/ContentViewStub.php
@@ -2,14 +2,11 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests;
-use eZ\Publish\Core\MVC\Symfony\View\ContentValueView;
+use Ibexa\Core\MVC\Symfony\View\ContentValueView;
class ContentViewStub implements ContentValueView
{
- /**
- * {@inheritdoc}
- */
- public function getContent()
+ public function getContent(): void
{
}
}
diff --git a/tests/old/Controller/InformationCollectionControllerTest.php b/tests/old/Controller/InformationCollectionControllerTest.php
index dc91eca5..9cf5b375 100644
--- a/tests/old/Controller/InformationCollectionControllerTest.php
+++ b/tests/old/Controller/InformationCollectionControllerTest.php
@@ -2,63 +2,41 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Controller;
-use eZ\Publish\Core\MVC\Symfony\View\ContentView;
-use eZ\Publish\Core\Repository\Values\Content\Location;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
-use Netgen\Bundle\EzFormsBundle\Form\Payload\InformationCollectionStruct;
+use Ibexa\Core\MVC\Symfony\View\ContentView;
+use Ibexa\Core\Repository\Values\Content\Location;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\Payload\InformationCollectionStruct;
use Netgen\Bundle\InformationCollectionBundle\Controller\InformationCollectionController;
use Netgen\Bundle\InformationCollectionBundle\Form\Builder\FormBuilder;
use Netgen\Bundle\InformationCollectionBundle\Tests\ContentViewStub;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Form;
+use Symfony\Component\Form\FormBuilder as SymfonyFormBuilder;
use Symfony\Component\HttpFoundation\Request;
class InformationCollectionControllerTest extends TestCase
{
- /**
- * @var InformationCollectionController
- */
- protected $controller;
+ protected InformationCollectionController $controller;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $dispatcher;
+ protected MockObject $dispatcher;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $builder;
+ protected MockObject $builder;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $contentView;
+ protected MockObject $contentView;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $request;
+ protected MockObject $request;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $formBuilder;
+ protected MockObject $formBuilder;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $form;
+ protected MockObject $form;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $container;
+ protected MockObject $container;
- public function setUp()
+ public function setUp(): void
{
if (!class_exists(ContentView::class)) {
$this->markTestSkipped();
@@ -89,7 +67,7 @@ public function setUp()
->setMethods(array())
->getMock();
- $this->formBuilder = $this->getMockBuilder(\Symfony\Component\Form\FormBuilder::class)
+ $this->formBuilder = $this->getMockBuilder(SymfonyFormBuilder::class)
->disableOriginalConstructor()
->setMethods(array('getForm'))
->getMock();
@@ -105,12 +83,12 @@ public function setUp()
parent::setUp();
}
- public function testInstanceOfContainerAwareInterface()
+ public function testInstanceOfContainerAwareInterface(): void
{
$this->assertInstanceOf(ContainerAwareInterface::class, $this->controller);
}
- public function testDisplayAndHandleWithValidFormSubmission()
+ public function testDisplayAndHandleWithValidFormSubmission(): void
{
$location = new Location();
@@ -163,7 +141,7 @@ public function testDisplayAndHandleWithValidFormSubmission()
$this->controller->displayAndHandle($this->contentView, $this->request);
}
- public function testDisplayAndHandleWithInvalidFormSubmission()
+ public function testDisplayAndHandleWithInvalidFormSubmission(): void
{
$location = new Location();
@@ -211,9 +189,9 @@ public function testDisplayAndHandleWithInvalidFormSubmission()
/**
* @expectedException \BadMethodCallException
- * @expectedExceptionMessage eZ view needs to implement LocationValueView interface
+ * @expectedExceptionMessage Ibexa view needs to implement LocationValueView interface
*/
- public function testIfLocationValueViewIsNotProvidedThrowBadMethodCallException()
+ public function testIfLocationValueViewIsNotProvidedThrowBadMethodCallException(): void
{
$this->container->expects($this->never())
->method('get')
@@ -223,7 +201,7 @@ public function testIfLocationValueViewIsNotProvidedThrowBadMethodCallException(
$this->controller->displayAndHandle(new ContentViewStub(), $this->request);
}
- public function getService($id)
+ public function getService(string $id): object
{
switch ($id) {
case 'netgen_information_collection.form.builder':
diff --git a/tests/old/DependencyInjection/Compiler/ActionsPassTest.php b/tests/old/DependencyInjection/Compiler/ActionsPassTest.php
index bccdc7ad..6b8e0da6 100644
--- a/tests/old/DependencyInjection/Compiler/ActionsPassTest.php
+++ b/tests/old/DependencyInjection/Compiler/ActionsPassTest.php
@@ -11,7 +11,7 @@
class ActionsPassTest extends AbstractCompilerPassTestCase
{
- public function testCompilerPassCollectsValidServices()
+ public function testCompilerPassCollectsValidServices(): void
{
$actionsRegistry = new Definition();
$this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -37,7 +37,7 @@ public function testCompilerPassCollectsValidServices()
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage 'netgen_information_collection.action' service tag needs an 'alias' attribute to identify the action. None given.
*/
- public function testCompilerPassMustThrowExceptionIfActionServiceHasntGotAlias()
+ public function testCompilerPassMustThrowExceptionIfActionServiceHasntGotAlias(): void
{
$actionsRegistry = new Definition();
$this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -61,7 +61,7 @@ public function testCompilerPassMustThrowExceptionIfActionServiceHasntGotAlias()
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage Service my_action uses priority less than allowed. Priority must be greater than or equal to -255.
*/
- public function testCompilerWithServicePriorityLessThanAllowed()
+ public function testCompilerWithServicePriorityLessThanAllowed(): void
{
$actionsRegistry = new Definition();
$this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -88,7 +88,7 @@ public function testCompilerWithServicePriorityLessThanAllowed()
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage Service my_action uses priority greater than allowed. Priority must be lower than or equal to 255.
*/
- public function testCompilerWithServicePriorityGreaterThanAllowed()
+ public function testCompilerWithServicePriorityGreaterThanAllowed(): void
{
$actionsRegistry = new Definition();
$this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -111,7 +111,7 @@ public function testCompilerWithServicePriorityGreaterThanAllowed()
);
}
- public function testCompilerWithServiceThatIsMissingPriority()
+ public function testCompilerWithServiceThatIsMissingPriority(): void
{
$actionsRegistry = new Definition();
$this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -133,7 +133,7 @@ public function testCompilerWithServiceThatIsMissingPriority()
);
}
- public function testCompilerWithDatabasePriority()
+ public function testCompilerWithDatabasePriority(): void
{
$actionsRegistry = new Definition();
$this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -155,7 +155,7 @@ public function testCompilerWithDatabasePriority()
);
}
- protected function registerCompilerPass(ContainerBuilder $container)
+ protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new ActionsPass());
}
diff --git a/tests/old/DependencyInjection/Compiler/CustomFieldHandlersPassTest.php b/tests/old/DependencyInjection/Compiler/CustomFieldHandlersPassTest.php
index ee5279bf..188c89f5 100644
--- a/tests/old/DependencyInjection/Compiler/CustomFieldHandlersPassTest.php
+++ b/tests/old/DependencyInjection/Compiler/CustomFieldHandlersPassTest.php
@@ -10,7 +10,7 @@
class CustomFieldHandlersPassTest extends AbstractCompilerPassTestCase
{
- public function testCompilerPassCollectsValidServices()
+ public function testCompilerPassCollectsValidServices(): void
{
$registry = new Definition();
$this->setDefinition(CustomFieldHandlersPass::FIELD_HANDLER_REGISTRY, $registry);
@@ -30,7 +30,7 @@ public function testCompilerPassCollectsValidServices()
);
}
- protected function registerCompilerPass(ContainerBuilder $container)
+ protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new CustomFieldHandlersPass());
}
diff --git a/tests/old/DependencyInjection/Compiler/FieldAnonymizerVisitorPassTest.php b/tests/old/DependencyInjection/Compiler/FieldAnonymizerVisitorPassTest.php
index e3b7c191..fb519fe1 100644
--- a/tests/old/DependencyInjection/Compiler/FieldAnonymizerVisitorPassTest.php
+++ b/tests/old/DependencyInjection/Compiler/FieldAnonymizerVisitorPassTest.php
@@ -11,7 +11,7 @@
class FieldAnonymizerVisitorPassTest extends AbstractCompilerPassTestCase
{
- public function testCompilerPassCollectsValidServices()
+ public function testCompilerPassCollectsValidServices(): void
{
$aggregate = new Definition();
$this->setDefinition('netgen_information_collection.anonymizer.visitor.field.aggregate', $aggregate);
@@ -31,7 +31,7 @@ public function testCompilerPassCollectsValidServices()
);
}
- public function testCompilerPassCollectsAndSortsServices()
+ public function testCompilerPassCollectsAndSortsServices(): void
{
$aggregate = new Definition();
$this->setDefinition('netgen_information_collection.anonymizer.visitor.field.aggregate', $aggregate);
@@ -65,7 +65,7 @@ public function testCompilerPassCollectsAndSortsServices()
// * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
// * @expectedExceptionMessage 'netgen_information_collection.action' service tag needs an 'alias' attribute to identify the action. None given.
// */
-// public function testCompilerPassMustThrowExceptionIfActionServiceHasntGotAlias()
+// public function testCompilerPassMustThrowExceptionIfActionServiceHasntGotAlias(): void
// {
// $actionsRegistry = new Definition();
// $this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -89,7 +89,7 @@ public function testCompilerPassCollectsAndSortsServices()
// * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
// * @expectedExceptionMessage Service my_action uses priority less than allowed. Priority must be greater than or equal to -255.
// */
-// public function testCompilerWithServicePriorityLessThanAllowed()
+// public function testCompilerWithServicePriorityLessThanAllowed(): void
// {
// $actionsRegistry = new Definition();
// $this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -116,7 +116,7 @@ public function testCompilerPassCollectsAndSortsServices()
// * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
// * @expectedExceptionMessage Service my_action uses priority greater than allowed. Priority must be lower than or equal to 255.
// */
-// public function testCompilerWithServicePriorityGreaterThanAllowed()
+// public function testCompilerWithServicePriorityGreaterThanAllowed(): void
// {
// $actionsRegistry = new Definition();
// $this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -139,7 +139,7 @@ public function testCompilerPassCollectsAndSortsServices()
// );
// }
//
-// public function testCompilerWithServiceThatIsMissingPriority()
+// public function testCompilerWithServiceThatIsMissingPriority(): void
// {
// $actionsRegistry = new Definition();
// $this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -161,7 +161,7 @@ public function testCompilerPassCollectsAndSortsServices()
// );
// }
//
-// public function testCompilerWithDatabasePriority()
+// public function testCompilerWithDatabasePriority(): void
// {
// $actionsRegistry = new Definition();
// $this->setDefinition('netgen_information_collection.action.registry', $actionsRegistry);
@@ -183,7 +183,7 @@ public function testCompilerPassCollectsAndSortsServices()
// );
// }
- protected function registerCompilerPass(ContainerBuilder $container)
+ protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new FieldAnonymizerVisitorPass());
}
diff --git a/tests/old/DependencyInjection/ConfigurationTest.php b/tests/old/DependencyInjection/ConfigurationTest.php
index 6591cf03..13b836eb 100644
--- a/tests/old/DependencyInjection/ConfigurationTest.php
+++ b/tests/old/DependencyInjection/ConfigurationTest.php
@@ -10,7 +10,7 @@ class ConfigurationTest extends TestCase
{
use ConfigurationTestCaseTrait;
- public function testConfigurationValuesAreOkAndValid()
+ public function testConfigurationValuesAreOkAndValid(): void
{
$this->assertConfigurationIsValid(
array(
@@ -56,7 +56,7 @@ public function testConfigurationValuesAreOkAndValid()
);
}
- public function testConfigurationIsInvalidForDefaultTemplateValue()
+ public function testConfigurationIsInvalidForDefaultTemplateValue(): void
{
$this->assertConfigurationIsInvalid(
array(
@@ -103,7 +103,7 @@ public function testConfigurationIsInvalidForDefaultTemplateValue()
);
}
- public function testConfigurationIsInvalidForDefaultActionsValue()
+ public function testConfigurationIsInvalidForDefaultActionsValue(): void
{
$this->assertConfigurationIsInvalid(
array(
@@ -149,7 +149,7 @@ public function testConfigurationIsInvalidForDefaultActionsValue()
);
}
- protected function getConfiguration()
+ protected function getConfiguration(): Configuration
{
return new Configuration();
}
diff --git a/tests/old/DependencyInjection/NetgenInformationCollectionExtensionTest.php b/tests/old/DependencyInjection/NetgenInformationCollectionExtensionTest.php
index 7fc75e3c..219aae38 100644
--- a/tests/old/DependencyInjection/NetgenInformationCollectionExtensionTest.php
+++ b/tests/old/DependencyInjection/NetgenInformationCollectionExtensionTest.php
@@ -7,20 +7,20 @@
class NetgenInformationCollectionExtensionTest extends AbstractExtensionTestCase
{
- public function testItSetsValidContainerParameters()
+ public function testItSetsValidContainerParameters(): void
{
- $this->container->setParameter('ezpublish.siteaccess.list', array());
+ $this->container->setParameter('ibexa.site_access.list', array());
$this->load();
}
- protected function getContainerExtensions()
+ protected function getContainerExtensions(): array
{
return array(
new NetgenInformationCollectionExtension(),
);
}
- protected function getMinimalConfiguration()
+ protected function getMinimalConfiguration(): array
{
return array(
'system' => array(
diff --git a/tests/old/Entity/EzInfoCollectionAttributeTest.php b/tests/old/Entity/EzInfoCollectionAttributeTest.php
index 0764cc13..806bab1f 100644
--- a/tests/old/Entity/EzInfoCollectionAttributeTest.php
+++ b/tests/old/Entity/EzInfoCollectionAttributeTest.php
@@ -7,18 +7,15 @@
class EzInfoCollectionAttributeTest extends TestCase
{
- /**
- * @var EzInfoCollectionAttribute
- */
- protected $entity;
+ protected EzInfoCollectionAttribute $entity;
- public function setUp()
+ public function setUp(): void
{
$this->entity = new EzInfoCollectionAttribute();
parent::setUp();
}
- public function testSetters()
+ public function testSetters(): void
{
$this->entity->setId(2342);
$this->entity->setContentObjectId(24343);
diff --git a/tests/old/Entity/EzInfoCollectionTest.php b/tests/old/Entity/EzInfoCollectionTest.php
index 9ea18bcd..df2050ea 100644
--- a/tests/old/Entity/EzInfoCollectionTest.php
+++ b/tests/old/Entity/EzInfoCollectionTest.php
@@ -7,18 +7,15 @@
class EzInfoCollectionTest extends TestCase
{
- /**
- * @var EzInfoCollection
- */
- protected $entity;
+ protected EzInfoCollection $entity;
- public function setUp()
+ public function setUp(): void
{
$this->entity = new EzInfoCollection();
parent::setUp();
}
- public function testGettersAndSetters()
+ public function testGettersAndSetters(): void
{
$id = 123;
$this->entity->setId($id);
diff --git a/tests/old/Event/InformationCollectedTest.php b/tests/old/Event/InformationCollectedTest.php
index b842db27..224098f8 100644
--- a/tests/old/Event/InformationCollectedTest.php
+++ b/tests/old/Event/InformationCollectedTest.php
@@ -2,18 +2,15 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Event;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use PHPUnit\Framework\TestCase;
class InformationCollectedTest extends TestCase
{
- /**
- * @var InformationCollected
- */
- protected $event;
+ protected InformationCollected $event;
- public function setUp()
+ public function setUp(): void
{
$data = new DataWrapper('payload', 'definition', 'target');
$this->event = new InformationCollected($data, 'additional content');
@@ -21,7 +18,7 @@ public function setUp()
parent::setUp();
}
- public function testGetters()
+ public function testGetters(): void
{
$this->assertEquals('payload', $this->event->getInformationCollectionStruct());
$this->assertEquals('definition', $this->event->getContentType());
diff --git a/tests/old/Exception/ActionFailedExceptionTest.php b/tests/old/Exception/ActionFailedExceptionTest.php
index 69b4f8a0..bb43aa3a 100644
--- a/tests/old/Exception/ActionFailedExceptionTest.php
+++ b/tests/old/Exception/ActionFailedExceptionTest.php
@@ -11,7 +11,7 @@ class ActionFailedExceptionTest extends TestCase
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException
* @expectedExceptionMessage InformationCollection action test failed with reason some reason
*/
- public function testException()
+ public function testException(): void
{
throw new ActionFailedException('test', 'some reason');
}
diff --git a/tests/old/Exception/EmailNotSentExceptionTest.php b/tests/old/Exception/EmailNotSentExceptionTest.php
index 2e04424c..505243a1 100644
--- a/tests/old/Exception/EmailNotSentExceptionTest.php
+++ b/tests/old/Exception/EmailNotSentExceptionTest.php
@@ -11,7 +11,7 @@ class EmailNotSentExceptionTest extends TestCase
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException
* @expectedExceptionMessage Error occurred while trying to send email: test@example.com failed with error invalid email
*/
- public function testException()
+ public function testException(): void
{
throw new EmailNotSentException('test@example.com', 'invalid email');
}
diff --git a/tests/old/Exception/MissingEmailBlockExceptionTest.php b/tests/old/Exception/MissingEmailBlockExceptionTest.php
index 9f0ef78b..f75b06ad 100644
--- a/tests/old/Exception/MissingEmailBlockExceptionTest.php
+++ b/tests/old/Exception/MissingEmailBlockExceptionTest.php
@@ -11,7 +11,7 @@ class MissingEmailBlockExceptionTest extends TestCase
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\MissingEmailBlockException
* @expectedExceptionMessage Missing email block in @Acme/email.html.twig template, currently there is none available.
*/
- public function testExceptionWithNoBlocks()
+ public function testExceptionWithNoBlocks(): void
{
throw new MissingEmailBlockException('@Acme/email.html.twig', array());
}
@@ -20,7 +20,7 @@ public function testExceptionWithNoBlocks()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\MissingEmailBlockException
* @expectedExceptionMessage Missing email block in @Acme/email.html.twig template, currently there is email available.
*/
- public function testExceptionWithSingleBlock()
+ public function testExceptionWithSingleBlock(): void
{
throw new MissingEmailBlockException('@Acme/email.html.twig', array('email'));
}
@@ -29,7 +29,7 @@ public function testExceptionWithSingleBlock()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\MissingEmailBlockException
* @expectedExceptionMessage Missing email block in @Acme/email.html.twig template, currently there are recipient, email available.
*/
- public function testExceptionWithMultipleBlocks()
+ public function testExceptionWithMultipleBlocks(): void
{
throw new MissingEmailBlockException('@Acme/email.html.twig', array('recipient', 'email'));
}
diff --git a/tests/old/Exception/MissingValueExceptionTest.php b/tests/old/Exception/MissingValueExceptionTest.php
index ccfe0e6b..6bd2b830 100644
--- a/tests/old/Exception/MissingValueExceptionTest.php
+++ b/tests/old/Exception/MissingValueExceptionTest.php
@@ -11,7 +11,7 @@ class MissingValueExceptionTest extends TestCase
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\MissingValueException
* @expectedExceptionMessage There is no value for field my_field specified.
*/
- public function testException()
+ public function testException(): void
{
throw new MissingValueException('my_field');
}
diff --git a/tests/old/Factory/AutoResponderDataFactoryTest.php b/tests/old/Factory/AutoResponderDataFactoryTest.php
index 6a0090e9..1105ee8d 100644
--- a/tests/old/Factory/AutoResponderDataFactoryTest.php
+++ b/tests/old/Factory/AutoResponderDataFactoryTest.php
@@ -3,80 +3,51 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Factory;
use Netgen\Bundle\InformationCollectionBundle\Factory\AutoResponderDataFactory;
-use eZ\Publish\API\Repository\Values\Content\ContentInfo;
-use eZ\Publish\API\Repository\Values\Content\Field;
-use eZ\Publish\Core\FieldType\EmailAddress\Value as EmailValue;
-use eZ\Publish\Core\FieldType\TextLine\Value as TextLineValue;
-use eZ\Publish\Core\Helper\FieldHelper;
-use eZ\Publish\Core\Helper\TranslationHelper;
-use eZ\Publish\Core\Repository\ContentService;
-use eZ\Publish\Core\Repository\Values\Content\Content;
-use eZ\Publish\Core\Repository\Values\Content\Location;
-use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
-use eZ\Publish\Core\Repository\Values\ContentType\ContentType;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
-use Netgen\Bundle\EzFormsBundle\Form\Payload\InformationCollectionStruct;
+use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
+use Ibexa\Contracts\Core\Repository\Values\Content\Field;
+use Ibexa\Core\FieldType\EmailAddress\Value as EmailValue;
+use Ibexa\Core\FieldType\TextLine\Value as TextLineValue;
+use Ibexa\Core\Helper\FieldHelper;
+use Ibexa\Core\Helper\TranslationHelper;
+use Ibexa\Core\Repository\ContentService;
+use Ibexa\Core\Repository\Values\Content\Content;
+use Ibexa\Core\Repository\Values\Content\Location;
+use Ibexa\Core\Repository\Values\Content\VersionInfo;
+use Ibexa\Core\Repository\Values\ContentType\ContentType;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\Payload\InformationCollectionStruct;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Factory\EmailDataFactory;
use Netgen\Bundle\InformationCollectionBundle\Value\EmailData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Twig_Environment;
-use Twig_Loader_Array;
-use Twig_TemplateWrapper;
+use Twig\Environment;
+use Twig\Loader\ArrayLoader;
+use Twig\TemplateWrapper;
class AutoResponderDataFactoryTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Factory\AutoResponderDataFactory
- */
- protected $factory;
-
- /**
- * @var array
- */
- protected $config;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $translationHelper;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $fieldHelper;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $contentService;
-
- /**
- * @var \eZ\Publish\Core\Repository\Values\ContentType\ContentType
- */
- protected $contentType;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $twig;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $templateWrapper;
-
- /**
- * @var \eZ\Publish\Core\Repository\Values\ContentType\ContentType
- */
- protected $contentType2;
-
- /**
- * @var \eZ\Publish\Core\Repository\Values\Content\VersionInfo
- */
- protected $versionInfo;
-
- public function setUp()
+ protected AutoResponderDataFactory $factory;
+
+ protected array $config;
+
+ protected MockObject $translationHelper;
+
+ protected MockObject $fieldHelper;
+
+ protected MockObject $contentService;
+
+ protected MockObject $contentType;
+
+ protected MockObject $twig;
+
+ protected MockObject $templateWrapper;
+
+ protected ContentType $contentType2;
+
+ protected VersionInfo $versionInfo;
+
+ public function setUp(): void
{
$this->config = array(
'templates' => array(
@@ -107,7 +78,7 @@ public function setUp()
->setMethods(array('loadContent'))
->getMock();
- $this->twig = $this->getMockBuilder(\Twig_Environment::class)
+ $this->twig = $this->getMockBuilder(Environment::class)
->disableOriginalConstructor()
->setMethods(array('load'))
->getMock();
@@ -138,17 +109,17 @@ public function setUp()
parent::setUp();
}
- public function testBuildingWithSenderAndSubjectFromContent()
+ public function testBuildingWithSenderAndSubjectFromContent(): void
{
- $twig = new Twig_Environment(
- new Twig_Loader_Array(
+ $twig = new Environment(
+ new ArrayLoader(
array(
'index' => '{% block email %}{{ "email body" }}{% endblock %}',
)
)
);
- $templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$this->factory = new AutoResponderDataFactory(
$this->config,
@@ -227,17 +198,17 @@ public function testBuildingWithSenderAndSubjectFromContent()
$this->assertEquals('email body', $value->getBody());
}
- public function testBuildingWithSenderFromContentAndSubjectFromTemplate()
+ public function testBuildingWithSenderFromContentAndSubjectFromTemplate(): void
{
- $twig = new Twig_Environment(
- new Twig_Loader_Array(
+ $twig = new Environment(
+ new ArrayLoader(
array(
'index' => '{% block email %}{{ "email body" }}{% endblock %}{% block auto_responder_subject %}{{ "subject from template" }}{% endblock %}',
)
)
);
- $templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$this->factory = new AutoResponderDataFactory(
$this->config,
diff --git a/tests/old/Factory/EmailDataFactoryTest.php b/tests/old/Factory/EmailDataFactoryTest.php
index e41b3ece..d54000c5 100644
--- a/tests/old/Factory/EmailDataFactoryTest.php
+++ b/tests/old/Factory/EmailDataFactoryTest.php
@@ -2,80 +2,51 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Factory;
-use eZ\Publish\API\Repository\Values\Content\ContentInfo;
-use eZ\Publish\API\Repository\Values\Content\Field;
-use eZ\Publish\Core\FieldType\EmailAddress\Value as EmailValue;
-use eZ\Publish\Core\FieldType\TextLine\Value as TextLineValue;
-use eZ\Publish\Core\Helper\FieldHelper;
-use eZ\Publish\Core\Helper\TranslationHelper;
-use eZ\Publish\Core\Repository\ContentService;
-use eZ\Publish\Core\Repository\Values\Content\Content;
-use eZ\Publish\Core\Repository\Values\Content\Location;
-use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
-use eZ\Publish\Core\Repository\Values\ContentType\ContentType;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
-use Netgen\Bundle\EzFormsBundle\Form\Payload\InformationCollectionStruct;
+use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
+use Ibexa\Contracts\Core\Repository\Values\Content\Field;
+use Ibexa\Core\FieldType\EmailAddress\Value as EmailValue;
+use Ibexa\Core\FieldType\TextLine\Value as TextLineValue;
+use Ibexa\Core\Helper\FieldHelper;
+use Ibexa\Core\Helper\TranslationHelper;
+use Ibexa\Core\Repository\ContentService;
+use Ibexa\Core\Repository\Values\Content\Content;
+use Ibexa\Core\Repository\Values\Content\Location;
+use Ibexa\Core\Repository\Values\Content\VersionInfo;
+use Ibexa\Core\Repository\Values\ContentType\ContentType;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\Payload\InformationCollectionStruct;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Factory\EmailDataFactory;
use Netgen\Bundle\InformationCollectionBundle\Value\EmailData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
-use Twig_Environment;
-use Twig_Loader_Array;
-use Twig_TemplateWrapper;
+use Twig\Environment;
+use Twig\Loader\ArrayLoader;
+use Twig\TemplateWrapper;
class EmailDataFactoryTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Factory\EmailDataFactory
- */
- protected $factory;
+ protected EmailDataFactory $factory;
- /**
- * @var array
- */
- protected $config;
+ protected array $config;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $translationHelper;
+ protected TranslationHelper $translationHelper;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $fieldHelper;
+ protected MockObject $fieldHelper;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $contentService;
+ protected MockObject $contentService;
- /**
- * @var \eZ\Publish\Core\Repository\Values\ContentType\ContentType
- */
- protected $contentType;
+ protected ContentType $contentType;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $twig;
+ protected MockObject $twig;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $templateWrapper;
+ protected MockObject $templateWrapper;
- /**
- * @var \eZ\Publish\Core\Repository\Values\ContentType\ContentType
- */
- protected $contentType2;
+ protected ContentType $contentType2;
- /**
- * @var \eZ\Publish\Core\Repository\Values\Content\VersionInfo
- */
- protected $versionInfo;
+ protected VersionInfo $versionInfo;
- public function setUp()
+ public function setUp(): void
{
$this->config = array(
'templates' => array(
@@ -106,7 +77,7 @@ public function setUp()
->setMethods(array('loadContent'))
->getMock();
- $this->twig = $this->getMockBuilder(\Twig_Environment::class)
+ $this->twig = $this->getMockBuilder(Environment::class)
->disableOriginalConstructor()
->setMethods(array('load'))
->getMock();
@@ -137,17 +108,17 @@ public function setUp()
parent::setUp();
}
- public function testBuildingWithSenderRecipientAndSubjectFromContent()
+ public function testBuildingWithSenderRecipientAndSubjectFromContent(): void
{
- $twig = new Twig_Environment(
- new Twig_Loader_Array(
+ $twig = new Environment(
+ new ArrayLoader(
array(
'index' => '{% block email %}{{ "email body" }}{% endblock %}',
)
)
);
- $templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$this->factory = new EmailDataFactory(
$this->config,
@@ -237,7 +208,7 @@ public function testBuildingWithSenderRecipientAndSubjectFromContent()
$this->assertEquals('email body', $value->getBody());
}
- public function testBuildingWithSenderRecipientAndSubjectFromTemplate()
+ public function testBuildingWithSenderRecipientAndSubjectFromTemplate(): void
{
$template = << $template,
)
)
);
- $templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$this->factory = new EmailDataFactory(
$this->config,
@@ -334,17 +305,17 @@ public function testBuildingWithSenderRecipientAndSubjectFromTemplate()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\MissingEmailBlockException
* @expectedExceptionMessage Missing email block in index template, currently there is foo available.
*/
- public function testBuildingWithNoEmailBlockInTemplate()
+ public function testBuildingWithNoEmailBlockInTemplate(): void
{
- $twig = new Twig_Environment(
- new Twig_Loader_Array(
+ $twig = new Environment(
+ new ArrayLoader(
array(
'index' => '{% block foo %}{% endblock %}',
)
)
);
- $templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$recipientField = new Field(array(
'value' => new EmailValue('recipient@test.com'),
@@ -412,17 +383,17 @@ public function testBuildingWithNoEmailBlockInTemplate()
$this->assertEquals('body test', $value->getBody());
}
- public function testBuildingWithSenderRecipientAndSubjectFromConfiguration()
+ public function testBuildingWithSenderRecipientAndSubjectFromConfiguration(): void
{
- $twig = new Twig_Environment(
- new Twig_Loader_Array(
+ $twig = new Environment(
+ new ArrayLoader(
array(
'index' => '{% block email %}{% endblock %}',
)
)
);
- $templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$recipientField = new Field(array(
'value' => new EmailValue('recipient@test.com'),
diff --git a/tests/old/Factory/FieldDataFactoryTest.php b/tests/old/Factory/FieldDataFactoryTest.php
index 43c0a990..8c03f5a6 100644
--- a/tests/old/Factory/FieldDataFactoryTest.php
+++ b/tests/old/Factory/FieldDataFactoryTest.php
@@ -2,28 +2,23 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Factory;
-use eZ\Publish\Core\FieldType\TextLine\Value as TextValue;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\FieldType\TextLine\Value as TextValue;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition;
use Netgen\Bundle\InformationCollectionBundle\Factory\FieldDataFactory;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomFieldHandlerInterface;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\FieldHandlerRegistry;
use Netgen\Bundle\InformationCollectionBundle\Value\LegacyData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class FieldDataFactoryTest extends TestCase
{
- /**
- * @var FieldDataFactory
- */
- protected $factory;
+ protected FieldDataFactory $factory;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $registry;
+ protected MockObject $registry;
- public function setUp()
+ public function setUp(): void
{
$this->registry = $this->getMockBuilder(FieldHandlerRegistry::class)
->disableOriginalConstructor()
@@ -35,7 +30,7 @@ public function setUp()
parent::setUp();
}
- public function testGetLegacyValueWithoutCustomHandler()
+ public function testGetLegacyValueWithoutCustomHandler(): void
{
$value = new TextValue('some value');
$definition = new FieldDefinition(array(
@@ -56,7 +51,7 @@ public function testGetLegacyValueWithoutCustomHandler()
$this->assertEquals((string) $value, $data->getDataText());
}
- public function testGetLegacyValueWithCustomHandler()
+ public function testGetLegacyValueWithCustomHandler(): void
{
$value = new TextValue('some value');
$definition = new FieldDefinition(array(
@@ -87,7 +82,7 @@ public function testGetLegacyValueWithCustomHandler()
$this->assertEquals((string) $value, $data->getDataText());
}
- public function testGetLegacyValueWithCustomLegacyHandler()
+ public function testGetLegacyValueWithCustomLegacyHandler(): void
{
$value = new TextValue('some value');
$definition = new FieldDefinition(array(
diff --git a/tests/old/FieldHandler/Custom/CheckboxFieldHandlerTest.php b/tests/old/FieldHandler/Custom/CheckboxFieldHandlerTest.php
index eed48564..28484380 100644
--- a/tests/old/FieldHandler/Custom/CheckboxFieldHandlerTest.php
+++ b/tests/old/FieldHandler/Custom/CheckboxFieldHandlerTest.php
@@ -2,47 +2,44 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler\Custom;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Integer\Value as IntegerValue;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Integer\Value as IntegerValue;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CheckboxFieldHandler;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
use PHPUnit\Framework\TestCase;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
class CheckboxFieldHandlerTest extends TestCase
{
- /**
- * @var CustomLegacyFieldHandlerInterface
- */
- protected $handler;
+ protected CustomLegacyFieldHandlerInterface $handler;
- public function setUp()
+ public function setUp(): void
{
$this->handler = new CheckboxFieldHandler();
}
- public function testInstanceOfCustomLegacyFieldHandler()
+ public function testInstanceOfCustomLegacyFieldHandler(): void
{
$this->assertInstanceOf(CustomLegacyFieldHandlerInterface::class, $this->handler);
}
- public function testSupportsHasValidBehaviour()
+ public function testSupportsHasValidBehaviour(): void
{
$this->assertTrue($this->handler->supports(new CheckboxValue(true)));
$this->assertFalse($this->handler->supports(new IntegerValue(1)));
$this->assertFalse($this->handler->supports(new FloatValue(2.0)));
}
- public function testToString()
+ public function testToString(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
$this->assertEquals('1', $this->handler->toString(new CheckboxValue(true), $fieldDefinition));
$this->assertEquals('0', $this->handler->toString(new CheckboxValue(false), $fieldDefinition));
}
- public function testGetLegacyValue()
+ public function testGetLegacyValue(): void
{
$fieldDefinition = new CoreFieldDefinition([
'id' => 123,
diff --git a/tests/old/FieldHandler/Custom/DateAndTimeFieldHandlerTest.php b/tests/old/FieldHandler/Custom/DateAndTimeFieldHandlerTest.php
index 05358be3..9f716f05 100644
--- a/tests/old/FieldHandler/Custom/DateAndTimeFieldHandlerTest.php
+++ b/tests/old/FieldHandler/Custom/DateAndTimeFieldHandlerTest.php
@@ -2,11 +2,11 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler\Custom;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
-use eZ\Publish\Core\FieldType\DateAndTime\Value as DateAndTimeValue;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Core\FieldType\DateAndTime\Value as DateAndTimeValue;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\DateAndTimeFieldHandler;
use PHPUnit\Framework\TestCase;
@@ -14,35 +14,29 @@
class DateAndTimeFieldHandlerTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface
- */
- protected $handler;
+ protected CustomLegacyFieldHandlerInterface $handler;
- /**
- * @var \DateTime
- */
- protected $dt;
+ protected DateTime $dt;
- public function setUp()
+ public function setUp(): void
{
$this->handler = new DateAndTimeFieldHandler();
$this->dt = new DateTime();
}
- public function testInstanceOfCustomLegacyFieldHandler()
+ public function testInstanceOfCustomLegacyFieldHandler(): void
{
$this->assertInstanceOf(CustomLegacyFieldHandlerInterface::class, $this->handler);
}
- public function testSupportsHasValidBehaviour()
+ public function testSupportsHasValidBehaviour(): void
{
$this->assertFalse($this->handler->supports(new CheckboxValue(true)));
$this->assertTrue($this->handler->supports(new DateAndTimeValue($this->dt)));
$this->assertFalse($this->handler->supports(new FloatValue(2.0)));
}
- public function testToString()
+ public function testToString(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
@@ -51,7 +45,7 @@ public function testToString()
$this->assertEquals($this->dt->format('U'), $this->handler->toString($value, $fieldDefinition));
}
- public function testGetLegacyValue()
+ public function testGetLegacyValue(): void
{
$fieldDefinition = new CoreFieldDefinition([
'id' => 123,
diff --git a/tests/old/FieldHandler/Custom/DateFieldHandlerTest.php b/tests/old/FieldHandler/Custom/DateFieldHandlerTest.php
index 5f1a9233..5655f44f 100644
--- a/tests/old/FieldHandler/Custom/DateFieldHandlerTest.php
+++ b/tests/old/FieldHandler/Custom/DateFieldHandlerTest.php
@@ -2,11 +2,11 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler\Custom;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
-use eZ\Publish\Core\FieldType\Date\Value as DateValue;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Core\FieldType\Date\Value as DateValue;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\DateFieldHandler;
use PHPUnit\Framework\TestCase;
@@ -14,36 +14,30 @@
class DateFieldHandlerTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface
- */
- protected $handler;
+ protected CustomLegacyFieldHandlerInterface $handler;
- /**
- * @var \DateTime
- */
- protected $dt;
+ protected DateTime $dt;
- public function setUp()
+ public function setUp(): void
{
$this->handler = new DateFieldHandler();
$this->dt = new DateTime();
$this->dt->setTime(0, 0, 0);
}
- public function testInstanceOfCustomLegacyFieldHandler()
+ public function testInstanceOfCustomLegacyFieldHandler(): void
{
$this->assertInstanceOf(CustomLegacyFieldHandlerInterface::class, $this->handler);
}
- public function testSupportsHasValidBehaviour()
+ public function testSupportsHasValidBehaviour(): void
{
$this->assertFalse($this->handler->supports(new CheckboxValue(true)));
$this->assertTrue($this->handler->supports(new DateValue($this->dt)));
$this->assertFalse($this->handler->supports(new FloatValue(2.0)));
}
- public function testToString()
+ public function testToString(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
@@ -52,7 +46,7 @@ public function testToString()
$this->assertEquals($this->dt->format('l d F Y'), $this->handler->toString($value, $fieldDefinition));
}
- public function testGetLegacyValue()
+ public function testGetLegacyValue(): void
{
$fieldDefinition = new CoreFieldDefinition([
'id' => 123,
diff --git a/tests/old/FieldHandler/Custom/FloatFieldHandlerTest.php b/tests/old/FieldHandler/Custom/FloatFieldHandlerTest.php
index 111e834c..37beaf57 100644
--- a/tests/old/FieldHandler/Custom/FloatFieldHandlerTest.php
+++ b/tests/old/FieldHandler/Custom/FloatFieldHandlerTest.php
@@ -2,40 +2,37 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler\Custom;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Integer\Value as IntegerValue;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Integer\Value as IntegerValue;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\FloatFieldHandler;
use PHPUnit\Framework\TestCase;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
class FloatFieldHandlerTest extends TestCase
{
- /**
- * @var CustomLegacyFieldHandlerInterface
- */
- protected $handler;
+ protected CustomLegacyFieldHandlerInterface $handler;
- public function setUp()
+ public function setUp(): void
{
$this->handler = new FloatFieldHandler();
}
- public function testInstanceOfCustomLegacyFieldHandler()
+ public function testInstanceOfCustomLegacyFieldHandler(): void
{
$this->assertInstanceOf(CustomLegacyFieldHandlerInterface::class, $this->handler);
}
- public function testSupportsHasValidBehaviour()
+ public function testSupportsHasValidBehaviour(): void
{
$this->assertFalse($this->handler->supports(new CheckboxValue(true)));
$this->assertFalse($this->handler->supports(new IntegerValue(1)));
$this->assertTrue($this->handler->supports(new FloatValue(2.0)));
}
- public function testToString()
+ public function testToString(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
@@ -43,7 +40,7 @@ public function testToString()
$this->assertEquals('55.7', $this->handler->toString(new FloatValue(55.7), $fieldDefinition));
}
- public function testGetLegacyValue()
+ public function testGetLegacyValue(): void
{
$fieldDefinition = new CoreFieldDefinition([
'id' => 123,
diff --git a/tests/old/FieldHandler/Custom/IntegerFieldHandlerTest.php b/tests/old/FieldHandler/Custom/IntegerFieldHandlerTest.php
index a4e41629..c3fff15f 100644
--- a/tests/old/FieldHandler/Custom/IntegerFieldHandlerTest.php
+++ b/tests/old/FieldHandler/Custom/IntegerFieldHandlerTest.php
@@ -2,47 +2,44 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler\Custom;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Integer\Value as IntegerValue;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Integer\Value as IntegerValue;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\IntegerFieldHandler;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
use PHPUnit\Framework\TestCase;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
class IntegerFieldHandlerTest extends TestCase
{
- /**
- * @var CustomLegacyFieldHandlerInterface
- */
- protected $handler;
+ protected CustomLegacyFieldHandlerInterface $handler;
- public function setUp()
+ public function setUp(): void
{
$this->handler = new IntegerFieldHandler();
}
- public function testInstanceOfCustomLegacyFieldHandler()
+ public function testInstanceOfCustomLegacyFieldHandler(): void
{
$this->assertInstanceOf(CustomLegacyFieldHandlerInterface::class, $this->handler);
}
- public function testSupportsHasValidBehaviour()
+ public function testSupportsHasValidBehaviour(): void
{
$this->assertFalse($this->handler->supports(new CheckboxValue(true)));
$this->assertTrue($this->handler->supports(new IntegerValue(1)));
$this->assertFalse($this->handler->supports(new FloatValue(2.0)));
}
- public function testToString()
+ public function testToString(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
$this->assertEquals('55', $this->handler->toString(new IntegerValue(55), $fieldDefinition));
$this->assertEquals('32', $this->handler->toString(new IntegerValue(32), $fieldDefinition));
}
- public function testGetLegacyValue()
+ public function testGetLegacyValue(): void
{
$fieldDefinition = new CoreFieldDefinition([
'id' => 123,
diff --git a/tests/old/FieldHandler/Custom/TimeFieldHandlerTest.php b/tests/old/FieldHandler/Custom/TimeFieldHandlerTest.php
index ed158843..09f5ef39 100644
--- a/tests/old/FieldHandler/Custom/TimeFieldHandlerTest.php
+++ b/tests/old/FieldHandler/Custom/TimeFieldHandlerTest.php
@@ -2,11 +2,11 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler\Custom;
-use eZ\Publish\Core\FieldType\Float\Value as FloatValue;
-use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
-use eZ\Publish\Core\FieldType\Time\Value as TimeValue;
-use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
-use eZ\Publish\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
+use Ibexa\Core\FieldType\Float\Value as FloatValue;
+use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
+use Ibexa\Core\FieldType\Time\Value as TimeValue;
+use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
+use Ibexa\Core\Repository\Values\ContentType\FieldDefinition as CoreFieldDefinition;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\TimeFieldHandler;
use PHPUnit\Framework\TestCase;
@@ -14,48 +14,39 @@
class TimeFieldHandlerTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomLegacyFieldHandlerInterface
- */
- protected $handler;
+ protected CustomLegacyFieldHandlerInterface $handler;
- /**
- * @var \DateTime
- */
- protected $dt;
+ protected DateTime $dt;
- /**
- * @var \eZ\Publish\Core\FieldType\Time\Value
- */
- protected $value;
+ protected TimeValue $value;
- public function setUp()
+ public function setUp(): void
{
$this->handler = new TimeFieldHandler();
$this->dt = new DateTime();
$this->value = TimeValue::fromDateTime($this->dt);
}
- public function testInstanceOfCustomLegacyFieldHandler()
+ public function testInstanceOfCustomLegacyFieldHandler(): void
{
$this->assertInstanceOf(CustomLegacyFieldHandlerInterface::class, $this->handler);
}
- public function testSupportsHasValidBehaviour()
+ public function testSupportsHasValidBehaviour(): void
{
$this->assertFalse($this->handler->supports(new CheckboxValue(true)));
$this->assertTrue($this->handler->supports($this->value));
$this->assertFalse($this->handler->supports(new FloatValue(2.0)));
}
- public function testToString()
+ public function testToString(): void
{
$fieldDefinition = $this->createMock(FieldDefinition::class);
$this->assertEquals($this->dt->format('H:i:s'), $this->handler->toString($this->value, $fieldDefinition));
}
- public function testGetLegacyValue()
+ public function testGetLegacyValue(): void
{
$fieldDefinition = new CoreFieldDefinition([
'id' => 123,
diff --git a/tests/old/FieldHandler/FieldHandlerRegistryTest.php b/tests/old/FieldHandler/FieldHandlerRegistryTest.php
index 8d0e0b72..8f5e1f90 100644
--- a/tests/old/FieldHandler/FieldHandlerRegistryTest.php
+++ b/tests/old/FieldHandler/FieldHandlerRegistryTest.php
@@ -2,29 +2,21 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler;
-use eZ\Publish\Core\FieldType\Integer\Value as TestValue;
+use Ibexa\Core\FieldType\Integer\Value as TestValue;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\Custom\CustomFieldHandlerInterface;
use Netgen\Bundle\InformationCollectionBundle\FieldHandler\FieldHandlerRegistry;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class FieldHandlerRegistryTest extends TestCase
{
- /**
- * @var FieldHandlerRegistry
- */
- protected $registry;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $customHandler1;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $customHandler2;
-
- public function setUp()
+ protected FieldHandlerRegistry $registry;
+
+ protected MockObject $customHandler1;
+
+ protected MockObject $customHandler2;
+
+ public function setUp(): void
{
$this->registry = new FieldHandlerRegistry();
$this->customHandler1 = $this->getMockBuilder(CustomFieldHandlerInterface::class)
@@ -40,13 +32,13 @@ public function setUp()
parent::setUp();
}
- public function testAddingHandlers()
+ public function testAddingHandlers(): void
{
$this->registry->addHandler($this->customHandler1);
$this->registry->addHandler($this->customHandler2);
}
- public function testItReturnsProperHandler()
+ public function testItReturnsProperHandler(): void
{
$value = new TestValue(2);
@@ -66,7 +58,7 @@ public function testItReturnsProperHandler()
$this->assertSame($this->customHandler2, $handler);
}
- public function testItReturnsNullWhenSupportedHandlerNotFound()
+ public function testItReturnsNullWhenSupportedHandlerNotFound(): void
{
$value = new TestValue(2);
diff --git a/tests/old/Form/Builder/FormBuilderTest.php b/tests/old/Form/Builder/FormBuilderTest.php
index d1816fac..8726814b 100644
--- a/tests/old/Form/Builder/FormBuilderTest.php
+++ b/tests/old/Form/Builder/FormBuilderTest.php
@@ -2,10 +2,11 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler;
-use eZ\Publish\API\Repository\Values\Content\ContentInfo;
-use eZ\Publish\Core\Repository\ContentTypeService;
-use eZ\Publish\Core\Repository\Values\Content\Location;
+use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
+use Ibexa\Core\Repository\ContentTypeService;
+use Ibexa\Core\Repository\Values\Content\Location;
use Netgen\Bundle\InformationCollectionBundle\Form\Builder\FormBuilder;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\FormBuilder as SymfonyFormBuilder;
use Symfony\Component\Form\FormFactory;
@@ -13,32 +14,17 @@
class FormBuilderTest extends TestCase
{
- /**
- * @var FormBuilder
- */
- protected $formBuilder;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $formFactory;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $contentTypeService;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $router;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $innerFormBuilder;
-
- public function setUp()
+ protected FormBuilder $formBuilder;
+
+ protected MockObject $formFactory;
+
+ protected MockObject $contentTypeService;
+
+ protected MockObject $router;
+
+ protected MockObject $innerFormBuilder;
+
+ public function setUp(): void
{
$this->formFactory = $this->getMockBuilder(FormFactory::class)
->disableOriginalConstructor()
@@ -64,7 +50,7 @@ public function setUp()
parent::setUp();
}
- public function testFormBuildUp()
+ public function testFormBuildUp(): void
{
$location = new Location(array(
'contentInfo' => new ContentInfo(array(
@@ -88,7 +74,7 @@ public function testFormBuildUp()
$this->assertSame($this->innerFormBuilder, $builder);
}
- public function testFormBuildUpWithCustomURL()
+ public function testFormBuildUpWithCustomURL(): void
{
$location = new Location(array(
'contentInfo' => new ContentInfo(array(
diff --git a/tests/old/Listener/InformationCollectedListenerTest.php b/tests/old/Listener/InformationCollectedListenerTest.php
index d47d5a90..82171cf7 100644
--- a/tests/old/Listener/InformationCollectedListenerTest.php
+++ b/tests/old/Listener/InformationCollectedListenerTest.php
@@ -2,26 +2,21 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Listener;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
use Netgen\Bundle\InformationCollectionBundle\Action\ActionRegistry;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Events;
use Netgen\Bundle\InformationCollectionBundle\Listener\InformationCollectedListener;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class InformationCollectedListenerTest extends TestCase
{
- /**
- * @var InformationCollectedListener
- */
- protected $listener;
+ protected InformationCollectedListener $listener;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $registry;
+ protected MockObject $registry;
- public function setUp()
+ public function setUp(): void
{
$this->registry = $this->getMockBuilder(ActionRegistry::class)
->disableOriginalConstructor()
@@ -33,7 +28,7 @@ public function setUp()
parent::setUp();
}
- public function testListenerConfiguration()
+ public function testListenerConfiguration(): void
{
$this->assertEquals(
array(Events::INFORMATION_COLLECTED => 'onInformationCollected'),
@@ -41,7 +36,7 @@ public function testListenerConfiguration()
);
}
- public function testItRunsActions()
+ public function testItRunsActions(): void
{
$event = new InformationCollected(new DataWrapper('payload'));
diff --git a/tests/old/Mailer/MailerTest.php b/tests/old/Mailer/MailerTest.php
index 09569e1b..5de73401 100644
--- a/tests/old/Mailer/MailerTest.php
+++ b/tests/old/Mailer/MailerTest.php
@@ -2,26 +2,22 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Mailer;
-use eZ\Publish\Core\FieldType\BinaryFile\Value as BinaryFileValue;
+use Ibexa\Core\FieldType\BinaryFile\Value as BinaryFileValue;
use Netgen\Bundle\InformationCollectionBundle\Mailer\Mailer;
use Netgen\Bundle\InformationCollectionBundle\Value\EmailData;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
+use Swift_Mailer;
class MailerTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Mailer\MailerInterface
- */
- protected $mailer;
+ protected Mailer $mailer;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $swiftMailer;
+ protected MockObject $swiftMailer;
- public function setUp()
+ public function setUp(): void
{
- $this->swiftMailer = $this->getMockBuilder(\Swift_Mailer::class)
+ $this->swiftMailer = $this->getMockBuilder(Swift_Mailer::class)
->disableOriginalConstructor()
->setMethods(array('createMessage', 'send'))
->getMock();
@@ -33,7 +29,7 @@ public function setUp()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException
* @expectedExceptionMessage Error occurred while trying to send email: recipient failed with error Address in mailbox given [[][][]][]] does not comply with RFC 2822, 3.6.2.
*/
- public function testCreateAndSendMessageWithWrongRecipient()
+ public function testCreateAndSendMessageWithWrongRecipient(): void
{
$data = new EmailData('[][][]][]', 'sender@example.com', 'Test', 'Body');
@@ -47,7 +43,7 @@ public function testCreateAndSendMessageWithWrongRecipient()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException
* @expectedExceptionMessage Error occurred while trying to send email: sender failed with error Address in mailbox given [[][][]][]] does not comply with RFC 2822, 3.6.2.
*/
- public function testCreateAndSendMessageWithWrongSender()
+ public function testCreateAndSendMessageWithWrongSender(): void
{
$data = new EmailData('recipient@example.com', '[][][]][]', 'Test', 'Body');
@@ -61,7 +57,7 @@ public function testCreateAndSendMessageWithWrongSender()
* @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\EmailNotSentException
* @expectedExceptionMessage Error occurred while trying to send email: send failed with error invalid mailer configuration?
*/
- public function testCreateAndSendMessageWithErrorFromInternalMailer()
+ public function testCreateAndSendMessageWithErrorFromInternalMailer(): void
{
$data = new EmailData('recipient@example.com', 'sender@example.com', 'Test', 'Body');
@@ -72,7 +68,7 @@ public function testCreateAndSendMessageWithErrorFromInternalMailer()
$this->mailer->createAndSendMessage($data);
}
- public function testCreateAndSendMessage()
+ public function testCreateAndSendMessage(): void
{
$data = new EmailData('recipient@example.com', 'sender@example.com', 'Test', 'Body');
@@ -83,7 +79,7 @@ public function testCreateAndSendMessage()
$this->mailer->createAndSendMessage($data);
}
- public function testCreateAndSendMessageWithAttachments()
+ public function testCreateAndSendMessageWithAttachments(): void
{
$attachments = [
new BinaryFileValue(
diff --git a/tests/old/Templating/Twig/AdminGlobalVariableTest.php b/tests/old/Templating/Twig/AdminGlobalVariableTest.php
index ad27409a..92042a23 100644
--- a/tests/old/Templating/Twig/AdminGlobalVariableTest.php
+++ b/tests/old/Templating/Twig/AdminGlobalVariableTest.php
@@ -7,7 +7,7 @@
class AdminGlobalVariableTest extends TestCase
{
- public function testGetterSetter()
+ public function testGetterSetter(): void
{
$admin = new AdminGlobalVariable();
diff --git a/tests/old/Value/EmailDataTest.php b/tests/old/Value/EmailDataTest.php
index 56111ee4..8923cf8c 100644
--- a/tests/old/Value/EmailDataTest.php
+++ b/tests/old/Value/EmailDataTest.php
@@ -15,7 +15,7 @@ class EmailDataTest extends TestCase
* @param mixed $subject
* @param mixed $body
*/
- public function testGetters($recipient, $sender, $subject, $body)
+ public function testGetters($recipient, $sender, $subject, $body): void
{
$emailData = new EmailData($recipient, $sender, $subject, $body);
@@ -26,7 +26,7 @@ public function testGetters($recipient, $sender, $subject, $body)
$this->assertNull($emailData->getAttachments());
}
- public function emailDataProvider()
+ public function emailDataProvider(): void
{
return array(
array('recipient@example.com', 'sender@example.com', 'Test subject', 'Email body'),
diff --git a/tests/old/Value/LegacyDataTest.php b/tests/old/Value/LegacyDataTest.php
index e64bccf3..c5357620 100644
--- a/tests/old/Value/LegacyDataTest.php
+++ b/tests/old/Value/LegacyDataTest.php
@@ -15,7 +15,7 @@ class LegacyDataTest extends TestCase
* @param mixed $dataInt
* @param mixed $dataText
*/
- public function testGetters($contentClassAttributeId, $dataFloat, $dataInt, $dataText)
+ public function testGetters($contentClassAttributeId, $dataFloat, $dataInt, $dataText): void
{
$legacyData = new LegacyData($contentClassAttributeId, $dataFloat, $dataInt, $dataText);
@@ -25,7 +25,7 @@ public function testGetters($contentClassAttributeId, $dataFloat, $dataInt, $dat
$this->assertEquals($dataText, $legacyData->getDataText());
}
- public function legacyDataProvider()
+ public function legacyDataProvider(): void
{
return array(
array(123456, 2.67, 34, 'text'),
diff --git a/tests/old/Value/TemplateDataTest.php b/tests/old/Value/TemplateDataTest.php
index 626b6de1..e96c207a 100644
--- a/tests/old/Value/TemplateDataTest.php
+++ b/tests/old/Value/TemplateDataTest.php
@@ -2,41 +2,29 @@
namespace Netgen\Bundle\InformationCollectionBundle\Tests\Value;
-use eZ\Publish\Core\Repository\Values\Content\Content;
-use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
+use Ibexa\Core\Repository\Values\Content\Content;
+use Netgen\Bundle\IbexaFormsBundle\Form\DataWrapper;
use Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected;
use Netgen\Bundle\InformationCollectionBundle\Value\TemplateData;
use PHPUnit\Framework\TestCase;
-use Twig_Environment;
-use Twig_Loader_Array;
-use Twig_TemplateWrapper;
+use Twig\Environment;
+use Twig\Loader\ArrayLoader;
+use Twig\TemplateWrapper;
class TemplateDataTest extends TestCase
{
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Value\TemplateData
- */
- protected $templateData;
-
- /**
- * @var \Netgen\Bundle\InformationCollectionBundle\Event\InformationCollected
- */
- protected $event;
-
- /**
- * @var \eZ\Publish\Core\Repository\Values\Content\Content
- */
- protected $content;
-
- /**
- * @var \Twig_TemplateWrapper
- */
- protected $templateWrapper;
-
- public function setUp()
+ protected TemplateData $templateData;
+
+ protected InformationCollected $event;
+
+ protected Content $content;
+
+ protected TemplateWrapper $templateWrapper;
+
+ public function setUp(): void
{
- $twig = new Twig_Environment(
- new Twig_Loader_Array(
+ $twig = new Environment(
+ new ArrayLoader(
array(
'index' => '{% block foo %}{% endblock %}',
)
@@ -45,12 +33,12 @@ public function setUp()
$this->event = new InformationCollected(new DataWrapper('test', null, null));
$this->content = new Content();
- $this->templateWrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
+ $this->templateWrapper = new TemplateWrapper($twig, $twig->loadTemplate('index'));
$this->templateData = new TemplateData($this->event, $this->content, $this->templateWrapper);
}
- public function testGetters()
+ public function testGetters(): void
{
$this->assertEquals($this->event, $this->templateData->getEvent());
$this->assertEquals($this->content, $this->templateData->getContent());