diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..029d927
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,12 @@
+| Q | A
+| ------------- | ---
+| Branch? | master / x.y.z
+| Bug fix? | yes/no
+| New feature? | yes/no
+| BC breaks? | yes/no
+| Fixed tickets | #...
+
+
diff --git a/.github/issue_template.md b/.github/issue_template.md
new file mode 100644
index 0000000..81a3586
--- /dev/null
+++ b/.github/issue_template.md
@@ -0,0 +1,13 @@
+| Q | A
+| ---------------- | -----
+| Bug report? | yes/no
+| Feature request? | yes/no
+| BC Break report? | yes/no
+| RFC? | yes/no
+| Version | x.y.z
+
+
+
diff --git a/.github/workflows/main-ci.yaml b/.github/workflows/main-ci.yaml
new file mode 100644
index 0000000..9f93306
--- /dev/null
+++ b/.github/workflows/main-ci.yaml
@@ -0,0 +1,116 @@
+name: CI
+
+on: [push, pull_request]
+
+jobs:
+ lint:
+ name: Coding Standard
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@master
+ with:
+ php-version: 7.3
+ id: php
+
+ - name: Validate composer.json and composer.lock
+ run: composer validate
+
+ - name: Install dependencies
+ run: composer install --prefer-dist --no-progress --no-suggest --no-interaction
+
+ - name: Check Sources
+ run: php vendor/bin/phpcs --standard=.cs/cs_ruleset.xml --extensions=php bundle/ tests/
+
+ - name: Check Mess Sources
+ run: php vendor/bin/phpmd bundle,tests text .cs/md_ruleset.xml
+ tests:
+ name: Tests
+ runs-on: ubuntu-latest
+ services:
+ mysql:
+ image: mariadb:10.3
+ env:
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
+ MYSQL_DATABASE: ezplatform
+ ports:
+ - 3306:3306
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
+ redis:
+ image: redis:latest
+ ports:
+ - 6379:6379
+ options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
+ strategy:
+ matrix:
+ php: [7.3]
+ env:
+ CACHE_POOL: cache.redis
+ DATABASE_URL: mysql://root@127.0.0.1:3306/ezplatform
+ CACHE_DSN: 127.0.0.1:6379
+ APP_ENV: dev
+ APP_DEBUG: 1
+ COMPOSER_MEMORY_LIMIT: 4G
+ PANTHER_EXTERNAL_BASE_URI: http://127.0.0.1:8000
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@master
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: mbstring, intl
+ id: php
+
+ - name: Get Composer Cache Directory
+ id: composer-cache
+ run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+ - uses: actions/cache@v1
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-composer-
+
+ - name: Install dependencies
+ run: composer install --prefer-dist --no-progress --no-suggest --no-interaction
+
+ - name: Install Symfony Server
+ run: |
+ wget https://get.symfony.com/cli/installer -O - | bash
+ /home/runner/.symfony/bin/symfony local:php:list
+
+ - name: Install eZ Platform
+ run: |
+ composer create-project ezsystems/ezplatform --prefer-dist --no-progress --no-interaction --no-scripts ezplatform
+ cd ezplatform
+ rm -rf var/cache
+ composer ezplatform-install
+
+ - name: Install Bundle on Top of a fresh eZ Installation
+ run: |
+ curl -o tests/provisioning/wrap.php https://raw.githubusercontent.com/Plopix/symfony-bundle-app-wrapper/master/wrap-bundle.php
+ WRAP_APP_DIR=./ezplatform WRAP_BUNDLE_DIR=./ php tests/provisioning/wrap.php
+ rm tests/provisioning/wrap.php
+ mysql -u root -h 127.0.0.1 ezplatform < bundle/Resources/sql/schema.sql
+ cd ezplatform
+ COMPOSER_MEMORY_LIMIT=-1 composer update --lock
+ bin/console cache:clear
+
+ - name: Run Webserver
+ run: |
+ cd ezplatform
+ /home/runner/.symfony/bin/symfony local:server:start --no-tls -d
+ /home/runner/.symfony/bin/symfony local:server:list
+
+ - name: Install Field everywhere
+ run: cd ezplatform && bin/console nova_ezseo:addnovaseometasfieldtype --group_identifier=Content --no-interaction
+
+ - name: Test Web Server
+ run: curl -I http://127.0.0.1:8000 | grep "HTTP/1.1 200 OK"
+
+ - name: Finally Run the tests
+ run: php vendor/bin/phpunit ./tests --exclude-group behat
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index e3b2886..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-language: php
-dist: xenial
-php:
- - '7.2'
-
-before_install:
- - phpenv config-rm xdebug.ini
-
-install:
- - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install
-
-script:
- - ./vendor/bin/phpcs --standard=.cs/cs_ruleset.xml --extensions=php bundle tests
-
-
-notifications:
- email: false
diff --git a/Makefile b/Makefile
index 565b959..667260b 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ PHP_BIN := php
COMPOSER := composer
CURRENT_DIR := $(shell pwd)
.DEFAULT_GOAL := list
+SYMFONY := symfony
EZ_DIR := $(CURRENT_DIR)/ezplatform
.PHONY: list
@@ -22,7 +23,7 @@ list:
.PHONY: installez
installez: ## Install eZ as the local project
@docker run -d -p 3364:3306 --name ezdbnovaezseocontainer -e MYSQL_ROOT_PASSWORD=ezplatform mariadb:10.3
- @composer create-project ezsystems/ezplatform:dev-master --prefer-dist --no-progress --no-interaction --no-scripts $(EZ_DIR)
+ @composer create-project ezsystems/ezplatform --prefer-dist --no-progress --no-interaction --no-scripts $(EZ_DIR)
@curl -o tests/provisioning/wrap.php https://raw.githubusercontent.com/Plopix/symfony-bundle-app-wrapper/master/wrap-bundle.php
@WRAP_APP_DIR=./ezplatform WRAP_BUNDLE_DIR=./ php tests/provisioning/wrap.php
@rm tests/provisioning/wrap.php
@@ -39,14 +40,11 @@ serveez: stopez ## Clear the cache and start the web server
@cd $(EZ_DIR) && rm -rf var/cache/*
@docker start ezdbnovaezseocontainer
@cd $(EZ_DIR) && bin/console cache:clear
- @cd $(EZ_DIR) && bin/console server:start
+ @cd $(EZ_DIR) && $(SYMFONY) local:server:start -d
.PHONY: stopez
stopez: ## Stop the web server if it is running
- @if [ -a $(EZ_DIR)/.web-server-pid ] ; \
- then \
- cd $(EZ_DIR) && php bin/console server:stop; \
- fi;
+ @cd $(EZ_DIR) && $(SYMFONY) local:server:stop
@docker stop ezdbnovaezseocontainer
diff --git a/bundle/Command/AddNovaSEOMetasFieldTypeCommand.php b/bundle/Command/AddNovaSEOMetasFieldTypeCommand.php
index e63d3a1..5c5ffa2 100644
--- a/bundle/Command/AddNovaSEOMetasFieldTypeCommand.php
+++ b/bundle/Command/AddNovaSEOMetasFieldTypeCommand.php
@@ -56,13 +56,6 @@ class AddNovaSEOMetasFieldTypeCommand extends Command
*/
private $adminUserId;
- /**
- * List of the ContentType we'll manage.
- *
- * @var ContentType[]
- */
- protected $contentTypes;
-
public function __construct(
ConfigResolverInterface $configResolver,
Repository $repository,
@@ -109,42 +102,8 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
- $io = new SymfonyStyle($input, $output);
- $contentTypes = $this->contentTypes;
- if (0 == count($contentTypes)) {
- $io->success('Nothing to do.');
-
- return 0;
- }
-
- $fieldName = $this->configResolver->getParameter('fieldtype_metas_identifier', 'nova_ezseo');
-
- foreach ($contentTypes as $contentType) {
- $io->section("Doing {$contentType->getName()}");
- if ($this->fieldInstaller->fieldExists($fieldName, $contentType)) {
- $io->block('Field exists');
- continue;
- }
- if (!$this->fieldInstaller->addToContentType($fieldName, $contentType)) {
- $io->error(
- sprintf(
- 'There were errors when adding new field to %s ContentType: %s',
- $contentType->getName($contentType->mainLanguageCode),
- $this->fieldInstaller->getErrorMessage()
- )
- );
- continue;
- }
- $io->block('FieldType added.');
- }
-
- $io->success('Done.');
-
- return 0;
- }
+ $io = new SymfonyStyle($input, $output);
- protected function interact(InputInterface $input, OutputInterface $output): void
- {
$contentTypes = [];
$groupIdentifier = $input->getOption('group_identifier');
@@ -172,10 +131,43 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
"\nAre you sure you want to add novaseometas all these Content Type?[yes]",
true
);
+
if (!$helper->ask($input, $output, $question)) {
- return;
+ $io->success('Nothing to do.');
+
+ return 0;
+ }
+
+ if (0 === \count($contentTypes)) {
+ $io->success('Nothing to do.');
+
+ return 0;
+ }
+
+ $fieldName = $this->configResolver->getParameter('fieldtype_metas_identifier', 'nova_ezseo');
+
+ foreach ($contentTypes as $contentType) {
+ $io->section("Doing {$contentType->getName()}");
+ if ($this->fieldInstaller->fieldExists($fieldName, $contentType)) {
+ $io->block('Field exists');
+ continue;
+ }
+ if (!$this->fieldInstaller->addToContentType($fieldName, $contentType)) {
+ $io->error(
+ sprintf(
+ 'There were errors when adding new field to %s ContentType: %s',
+ $contentType->getName($contentType->mainLanguageCode),
+ $this->fieldInstaller->getErrorMessage()
+ )
+ );
+ continue;
+ }
+ $io->block('FieldType added.');
}
- $this->contentTypes = $contentTypes;
+
+ $io->success('Done.');
+
+ return 0;
}
protected function initialize(InputInterface $input, OutputInterface $output): void
diff --git a/bundle/Controller/Admin/RedirectController.php b/bundle/Controller/Admin/RedirectController.php
index 7d1d329..f6c4431 100644
--- a/bundle/Controller/Admin/RedirectController.php
+++ b/bundle/Controller/Admin/RedirectController.php
@@ -14,7 +14,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use eZ\Publish\API\Repository\PermissionResolver;
-use eZ\Publish\Core\SignalSlot\URLWildcardService;
+use eZ\Publish\Core\Event\URLWildcardService;
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller;
use Novactive\Bundle\eZSEOBundle\Core\Helper\ImportUrlsHelper;
use Novactive\Bundle\eZSEOBundle\Entity\RedirectImportHistory;
@@ -32,7 +32,7 @@
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Route("/novaseo/redirect")
@@ -65,7 +65,7 @@ public function listAction(
$formDelete = $this->createForm(DeleteUrlType::class);
$formDelete->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
$source = trim($form->getData()['source']);
$destination = trim($form->getData()['destination']);
$type = trim($form->getData()['type']);
@@ -98,8 +98,9 @@ public function listAction(
}
}
- if ($formDelete->isValid()) {
- $response = $this->forward('NovaeZSEOBundle:Admin/Redirect:delete', ['request' => $request]);
+ if ($formDelete->isSubmitted() && $formDelete->isValid()) {
+ $deleteAction = self::class.'::deleteAction';
+ $response = $this->forward($deleteAction, ['request' => $request]);
if (Response::HTTP_CREATED == $response->getStatusCode()) {
$messages[] = $translator->trans('nova.redirect.delete.info', [], 'redirect');
}
@@ -112,7 +113,7 @@ public function listAction(
$pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages()));
return $this->render(
- 'NovaeZSEOBundle::platform_admin/list_url_wildcard.html.twig',
+ '@NovaeZSEO/platform_admin/list_url_wildcard.html.twig',
[
'pager' => $pagerfanta,
'form' => $form->createView(),
@@ -152,7 +153,7 @@ public function deleteAction(
/**
* @Route("/url-redirect-import", name="novactive_platform_admin_ui.import-redirect-url")
- * @Template("NovaeZSEOBundle::platform_admin/import_urls.html.twig")
+ * @Template("@NovaeZSEO/platform_admin/import_urls.html.twig")
*/
public function importAction(
Request $request,
@@ -171,7 +172,7 @@ public function importAction(
$form = $this->createForm(ImportUrlsType::class);
$form->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
$file = $request->files->get('novaseo_import_urls')['file'];
if ($file instanceof UploadedFile) {
$filePath = $file->getRealPath();
@@ -222,9 +223,9 @@ public function importAction(
/**
* @Route("/history-import-redirect-url", name="novactive_platform_admin_ui.history-import-redirect-url")
- * @Template("NovaeZSEOBundle::platform_admin/history_urls_imported.html.twig")
+ * @Template("@NovaeZSEO/platform_admin/history_urls_imported.html.twig")
*/
- public function hisroryUrlsImported(
+ public function historyUrlsImported(
Request $request,
ImportUrlsHelper $importUrlsHelper,
PermissionResolver $permissionResolver
diff --git a/bundle/Controller/SitemapController.php b/bundle/Controller/SitemapController.php
index edee4df..614319e 100644
--- a/bundle/Controller/SitemapController.php
+++ b/bundle/Controller/SitemapController.php
@@ -43,7 +43,7 @@ protected function getQuery(): Query
$limitToRootLocation = $this->getConfigResolver()->getParameter('limit_to_rootlocation', 'nova_ezseo');
$excludes = $this->getConfigResolver()->getParameter('sitemap_excludes', 'nova_ezseo');
$query = new Query();
- $criterion[] = new Criterion\Visibility(Criterion\Visibility::VISIBLE);
+ $criterion = [new Criterion\Visibility(Criterion\Visibility::VISIBLE)];
if (true === $limitToRootLocation) {
$criterion[] = new Criterion\Subtree($this->getRootLocation()->pathString);
}
diff --git a/bundle/Core/FieldType/Metas/Converter.php b/bundle/Core/FieldType/Metas/Converter.php
index 443b186..ceeaaa8 100644
--- a/bundle/Core/FieldType/Metas/Converter.php
+++ b/bundle/Core/FieldType/Metas/Converter.php
@@ -24,10 +24,8 @@ class Converter implements LegacyConverter
* Factory for current class.
*
* @note Class should instead be configured as service if it gains dependencies.
- *
- * @return Converter
*/
- public static function create()
+ public static function create(): Converter
{
return new self();
}
@@ -35,21 +33,21 @@ public static function create()
/**
* Converts data from $value to $storageFieldValue.
*/
- public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
+ public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue): void
{
}
/**
* Converts data from $value to $fieldValue.
*/
- public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue)
+ public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue): void
{
}
/**
* Converts field definition data in $fieldDef into $storageFieldDef.
*/
- public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef)
+ public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef): void
{
$fieldSettings = $fieldDef->fieldTypeConstraints->fieldSettings;
@@ -61,7 +59,7 @@ public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageField
/**
* Converts field definition data in $storageDef into $fieldDef.
*/
- public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
+ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef): void
{
$fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings(
[
@@ -72,10 +70,8 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin
/**
* Returns the name of the index column in the attribute table.
- *
- * @return bool
*/
- public function getIndexColumn()
+ public function getIndexColumn(): bool
{
return false;
}
diff --git a/bundle/Core/FieldType/Metas/FormMapper.php b/bundle/Core/FieldType/Metas/FormMapper.php
index f046016..67dad58 100644
--- a/bundle/Core/FieldType/Metas/FormMapper.php
+++ b/bundle/Core/FieldType/Metas/FormMapper.php
@@ -12,8 +12,8 @@
namespace Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
-use EzSystems\RepositoryForms\Data\Content\FieldData;
-use EzSystems\RepositoryForms\Data\FieldDefinitionData;
+use EzSystems\EzPlatformAdminUi\Form\Data\FieldDefinitionData;
+use EzSystems\EzPlatformContentForms\Data\Content\FieldData;
use EzSystems\RepositoryForms\FieldType\FieldDefinitionFormMapperInterface;
use EzSystems\RepositoryForms\FieldType\FieldValueFormMapperInterface;
use Novactive\Bundle\eZSEOBundle\Core\Meta;
@@ -46,7 +46,7 @@ public function __construct(ConfigResolverInterface $configResolver)
* @param FormInterface $fieldDefinitionForm form for current FieldDefinition
* @param FieldDefinitionData $data underlying data for current FieldDefinition form
*/
- public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data)
+ public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data): void
{
$metasConfig = $this->configResolver->getParameter('fieldtype_metas', 'nova_ezseo');
diff --git a/bundle/Core/FieldType/Metas/MetasStorage.php b/bundle/Core/FieldType/Metas/MetasStorage.php
index 57330ac..2955b52 100644
--- a/bundle/Core/FieldType/Metas/MetasStorage.php
+++ b/bundle/Core/FieldType/Metas/MetasStorage.php
@@ -11,77 +11,63 @@
namespace Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas;
-use eZ\Publish\Core\FieldType\GatewayBasedStorage;
+use eZ\Publish\SPI\FieldType\GatewayBasedStorage;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
-use Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway\LegacyStorage;
class MetasStorage extends GatewayBasedStorage
{
+ /**
+ * @var \Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway
+ */
+ protected $gateway;
+
/**
* Stores value for $field in an external data source.
- *
- *
- * @return mixed null|true
*/
- public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context)
+ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context): void
{
if (empty($field->value->externalData)) {
return;
}
- /** @var LegacyStorage $gateway */
- $gateway = $this->getGateway($context);
-
- $metas = $gateway->loadFieldData($versionInfo, $field);
+ $metas = $this->gateway->loadFieldData($versionInfo, $field);
if ($metas) {
- $gateway->deleteFieldData($versionInfo, [$field->id]);
+ $this->gateway->deleteFieldData($versionInfo, [$field->id]);
}
- $gateway->storeFieldData($versionInfo, $field);
+ $this->gateway->storeFieldData($versionInfo, $field);
}
/**
* Populates $field value property based on the external data.
*/
- public function getFieldData(VersionInfo $versionInfo, Field $field, array $context)
+ public function getFieldData(VersionInfo $versionInfo, Field $field, array $context): void
{
- /** @var LegacyStorage $gateway */
- $gateway = $this->getGateway($context);
- $gateway->getFieldData($versionInfo, $field);
+ $this->gateway->getFieldData($versionInfo, $field);
}
/**
* Deletes field data for all $fieldIds in the version identified by
* $versionInfo.
- *
- *
- * @return bool
*/
- public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context)
+ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context): void
{
- /** @var LegacyStorage $gateway */
- $gateway = $this->getGateway($context);
- $gateway->deleteFieldData($versionInfo, $fieldIds);
+ $this->gateway->deleteFieldData($versionInfo, $fieldIds);
}
/**
* Checks if field type has external data to deal with.
- *
- * @return bool
*/
- public function hasFieldData()
+ public function hasFieldData(): bool
{
return true;
}
/**
* Get index data for external data for search backend.
- *
- *
- * @return bool
*/
- public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
+ public function getIndexData(VersionInfo $versionInfo, Field $field, array $context): bool
{
return false;
}
diff --git a/bundle/Core/FieldType/Metas/MetasStorage/Gateway.php b/bundle/Core/FieldType/Metas/MetasStorage/Gateway.php
index 819f532..44b0349 100644
--- a/bundle/Core/FieldType/Metas/MetasStorage/Gateway.php
+++ b/bundle/Core/FieldType/Metas/MetasStorage/Gateway.php
@@ -11,7 +11,7 @@
namespace Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage;
-use eZ\Publish\Core\FieldType\StorageGateway;
+use eZ\Publish\SPI\FieldType\StorageGateway;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
@@ -24,16 +24,21 @@ abstract class Gateway extends StorageGateway
/**
* Stores the tags in the database based on the given field data.
*/
- abstract public function storeFieldData(VersionInfo $versionInfo, Field $field);
+ abstract public function storeFieldData(VersionInfo $versionInfo, Field $field): void;
/**
* Gets the tags stored in the field.
*/
- abstract public function getFieldData(VersionInfo $versionInfo, Field $field);
+ abstract public function getFieldData(VersionInfo $versionInfo, Field $field): void;
/**
* Deletes field data for all $fieldIds in the version identified by
* $versionInfo.
*/
- abstract public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds);
+ abstract public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): void;
+
+ /**
+ * Returns the data for the given $field and $version.
+ */
+ abstract public function loadFieldData(VersionInfo $versionInfo, Field $field): array;
}
diff --git a/bundle/Core/FieldType/Metas/MetasStorage/Gateway/DoctrineStorage.php b/bundle/Core/FieldType/Metas/MetasStorage/Gateway/DoctrineStorage.php
new file mode 100644
index 0000000..59665ed
--- /dev/null
+++ b/bundle/Core/FieldType/Metas/MetasStorage/Gateway/DoctrineStorage.php
@@ -0,0 +1,105 @@
+connection = $connection;
+ }
+
+ public function storeFieldData(VersionInfo $versionInfo, Field $field): void
+ {
+ foreach ($field->value->externalData as $meta) {
+ $insertQuery = $this->connection->createQueryBuilder();
+ $insertQuery
+ ->insert($this->connection->quoteIdentifier(self::TABLE))
+ ->values(
+ [
+ $this->connection->quoteIdentifier('meta_name') => ':meta_name',
+ $this->connection->quoteIdentifier('meta_content') => ':meta_content',
+ $this->connection->quoteIdentifier('objectattribute_id') => ':objectattribute_id',
+ $this->connection->quoteIdentifier('objectattribute_version') => ':objectattribute_version',
+ ]
+ )
+ ->setParameter(':meta_name', $meta['meta_name'], ParameterType::STRING)
+ ->setParameter(':meta_content', $meta['meta_content'], ParameterType::STRING)
+ ->setParameter(':objectattribute_id', $field->id, ParameterType::INTEGER)
+ ->setParameter(':objectattribute_version', $versionInfo->versionNo, ParameterType::INTEGER)
+ ;
+
+ $insertQuery->execute();
+ }
+ }
+
+ public function getFieldData(VersionInfo $versionInfo, Field $field): void
+ {
+ $field->value->externalData = $this->loadFieldData($versionInfo, $field);
+ }
+
+ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): void
+ {
+ $deleteQuery = $this->connection->createQueryBuilder();
+ $deleteQuery
+ ->delete($this->connection->quoteIdentifier(self::TABLE))
+ ->where(
+ $deleteQuery->expr()->andX(
+ $deleteQuery->expr()->in(
+ $this->connection->quoteIdentifier('objectattribute_id'),
+ $fieldIds
+ ),
+ $deleteQuery->expr()->eq(
+ $this->connection->quoteIdentifier('objectattribute_version'),
+ ':version'
+ )
+ )
+ )
+ ->setParameter(':version', $versionInfo->versionNo, ParameterType::INTEGER)
+ ;
+
+ $deleteQuery->execute();
+ }
+
+ public function loadFieldData(VersionInfo $versionInfo, Field $field): array
+ {
+ $selectQuery = $this->connection->createQueryBuilder();
+ $selectQuery
+ ->select('*')
+ ->distinct()
+ ->from($this->connection->quoteIdentifier(self::TABLE))
+ ->where(
+ $selectQuery->expr()->andX(
+ $selectQuery->expr()->eq(
+ $this->connection->quoteIdentifier('objectattribute_id'),
+ ':objectattribute_id'
+ ),
+ $selectQuery->expr()->eq(
+ $this->connection->quoteIdentifier('objectattribute_version'),
+ ':objectattribute_version'
+ )
+ )
+ )
+ ->setParameter(':objectattribute_id', $field->id, ParameterType::INTEGER)
+ ->setParameter(':objectattribute_version', $versionInfo->versionNo, ParameterType::INTEGER)
+ ;
+
+ $statement = $selectQuery->execute();
+
+ return $statement->fetchAll(FetchMode::ASSOCIATIVE);
+ }
+}
diff --git a/bundle/Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php b/bundle/Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php
deleted file mode 100644
index 9680b09..0000000
--- a/bundle/Core/FieldType/Metas/MetasStorage/Gateway/LegacyStorage.php
+++ /dev/null
@@ -1,168 +0,0 @@
-
- * @copyright 2015 Novactive
- * @license https://github.com/Novactive/NovaeZSEOBundle/blob/master/LICENSE MIT Licence
- */
-
-namespace Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway;
-
-use eZ\Publish\Core\Persistence\Database\DatabaseHandler;
-use eZ\Publish\SPI\Persistence\Content\Field;
-use eZ\Publish\SPI\Persistence\Content\VersionInfo;
-use Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway;
-use PDO;
-use RuntimeException;
-
-/**
- * Class LegacyStorage.
- */
-class LegacyStorage extends Gateway
-{
- /**
- * Table.
- */
- const TABLE = 'novaseo_meta';
-
- /**
- * Connection.
- *
- * @var DatabaseHandler
- */
- protected $connection;
-
- /**
- * Sets the data storage connection to use.
- *
- *
- * @param DatabaseHandler $connection
- *
- * @throws \RuntimeException if $connection is not an instance of
- * {@link \eZ\Publish\Core\Persistence\Database\DatabaseHandler}
- */
- public function setConnection($connection): void
- {
- // This obviously violates the Liskov substitution Principle, but with
- // the given class design there is no sane other option. Actually the
- // dbHandler *should* be passed to the constructor, and there should
- // not be the need to post-inject it.
- if (!$connection instanceof DatabaseHandler) {
- throw new RuntimeException('Invalid connection passed');
- }
-
- $this->connection = $connection;
- }
-
- /**
- * Returns the active connection.
- *
- * @throws RuntimeException if no connection has been set, yet
- *
- * @return DatabaseHandler
- */
- protected function getConnection()
- {
- if (null === $this->connection) {
- throw new RuntimeException('Missing database connection.');
- }
-
- return $this->connection;
- }
-
- /**
- * Stores the metas in the database based on the given field data.
- */
- public function storeFieldData(VersionInfo $versionInfo, Field $field)
- {
- $connection = $this->getConnection();
- foreach ($field->value->externalData as $meta) {
- $insertQuery = $connection->createInsertQuery();
- $insertQuery
- ->insertInto($connection->quoteTable(self::TABLE))
- ->set(
- $connection->quoteColumn('meta_name'),
- $insertQuery->bindValue($meta['meta_name'], null, PDO::PARAM_STR)
- )->set(
- $connection->quoteColumn('meta_content'),
- $insertQuery->bindValue($meta['meta_content'], null, PDO::PARAM_STR)
- )->set(
- $connection->quoteColumn('objectattribute_id'),
- $insertQuery->bindValue($field->id, null, PDO::PARAM_INT)
- )->set(
- $connection->quoteColumn('objectattribute_version'),
- $insertQuery->bindValue($versionInfo->versionNo, null, PDO::PARAM_INT)
- );
- $insertQuery->prepare()->execute();
- }
- }
-
- /**
- * Gets the metas stored in the field.
- */
- public function getFieldData(VersionInfo $versionInfo, Field $field)
- {
- $field->value->externalData = $this->loadFieldData($versionInfo, $field);
- }
-
- /**
- * Deletes field data for all $fieldIds in the version identified by
- * $versionInfo.
- */
- public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
- {
- $connection = $this->getConnection();
-
- $query = $connection->createDeleteQuery();
- $query
- ->deleteFrom($connection->quoteTable(self::TABLE))
- ->where(
- $query->expr->lAnd(
- $query->expr->in(
- $connection->quoteColumn('objectattribute_id'),
- $fieldIds
- ),
- $query->expr->eq(
- $connection->quoteColumn('objectattribute_version'),
- $query->bindValue($versionInfo->versionNo, null, PDO::PARAM_INT)
- )
- )
- );
-
- $query->prepare()->execute();
- }
-
- /**
- * Returns the data for the given $field and $version.
- *
- * @return array
- */
- public function loadFieldData(VersionInfo $versionInfo, Field $field)
- {
- $connection = $this->getConnection();
-
- $query = $connection->createSelectQuery();
- $query
- ->selectDistinct('*')
- ->from($connection->quoteTable(self::TABLE))
- ->where(
- $query->expr->lAnd(
- $query->expr->eq(
- $connection->quoteColumn('objectattribute_id'),
- $query->bindValue($field->id, null, PDO::PARAM_INT)
- ),
- $query->expr->eq(
- $connection->quoteColumn('objectattribute_version'),
- $query->bindValue($versionInfo->versionNo, null, PDO::PARAM_INT)
- )
- )
- );
- $statement = $query->prepare();
- $statement->execute();
-
- return $statement->fetchAll(PDO::FETCH_ASSOC);
- }
-}
diff --git a/bundle/Core/FieldType/Metas/Type.php b/bundle/Core/FieldType/Metas/Type.php
index 5786653..6a0b16d 100644
--- a/bundle/Core/FieldType/Metas/Type.php
+++ b/bundle/Core/FieldType/Metas/Type.php
@@ -11,6 +11,7 @@
namespace Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas;
+use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
use eZ\Publish\Core\FieldType\FieldType;
use eZ\Publish\Core\FieldType\ValidationError;
@@ -35,18 +36,15 @@ class Type extends FieldType
/**
* Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.
- *
- *
- * @return \eZ\Publish\SPI\FieldType\ValidationError[]
*/
- public function validateFieldSettings($fieldSettings)
+ public function validateFieldSettings($fieldSettings): array
{
$validationErrors = [];
foreach ($fieldSettings as $settingKey => $settingValue) {
switch ($settingKey) {
case 'configuration':
- if (!is_array($settingValue)) {
+ if (!\is_array($settingValue)) {
$validationErrors[] = new ValidationError(
"FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
null,
@@ -76,30 +74,21 @@ public function validateFieldSettings($fieldSettings)
/**
* Return the FieldType identifier ( Legacy DataTypeString ).
- *
- * @return string
*/
- public function getFieldTypeIdentifier()
+ public function getFieldTypeIdentifier(): string
{
return self::IDENTIFIER;
}
/**
* Inspects given $inputValue and potentially converts it into a dedicated value object.
- *
- *
- * @return Value the potentially converted and structurally plausible value
*/
- protected function createValueFromInput($inputValue)
+ protected function createValueFromInput($inputValue): Value
{
- if (is_array($inputValue)) {
+ if (\is_array($inputValue)) {
foreach ($inputValue as $index => $inputValueItem) {
if (!$inputValueItem instanceof Meta) {
- throw new InvalidArgumentType(
- '$inputValue['.$index.']',
- '\\Novactive\\Bundle\\SEOBundle\\API\\Repository\\Values\\Metas\\Meta',
- $inputValueItem
- );
+ throw new InvalidArgumentType('$inputValue['.$index.']', Meta::class, $inputValueItem);
}
}
$inputValue = new Value($inputValue);
@@ -113,75 +102,54 @@ protected function createValueFromInput($inputValue)
*
* @throws InvalidArgumentType if the value does not match the expected structure
*/
- protected function checkValueStructure(CoreValue $value)
+ protected function checkValueStructure(CoreValue $value): void
{
- if (!is_array($value->metas)) {
- throw new InvalidArgumentType(
- '$value->metas',
- 'array',
- $value->metas
- );
+ if (!\is_array($value->metas)) {
+ throw new InvalidArgumentType('$value->metas', 'array', $value->metas);
}
foreach ($value->metas as $index => $meta) {
if (!$meta instanceof Meta) {
- throw new InvalidArgumentType(
- '$value->metas['.$index.']',
- '\\Novactive\\Bundle\\SEOBundle\\API\\Repository\\Values\\Metas\\Meta',
- $meta
- );
+ throw new InvalidArgumentType('$value->metas['.$index.']', Meta::class, $meta);
}
}
}
/**
* Returns the empty value for this field type.
- *
- * @return Value
*/
- public function getEmptyValue()
+ public function getEmptyValue(): Value
{
return new Value();
}
/**
* Returns a human readable string representation from the given $value.
- *
- * @param Value $value
- *
- * @return string
*/
- public function getName(SPIValue $value)
+ public function getName(SPIValue $value, FieldDefinition $fieldDefinition, string $languageCode): string
{
return $value->__toString();
}
/**
* Returns information for FieldValue->$sortKey relevant to the field type.
- *
- * @param Value $value
- *
- * @return bool
*/
- protected function getSortInfo(CoreValue $value)
+ protected function getSortInfo(CoreValue $value): bool
{
return false;
}
/**
* Converts an $hash to the Value defined by the field type.
- *
- *
- * @return Value
*/
- public function fromHash($hash)
+ public function fromHash($hash): Value
{
- if (!is_array($hash)) {
+ if (!\is_array($hash)) {
return new Value([]);
}
$metas = [];
foreach ($hash as $hashItem) {
- if (!is_array($hashItem)) {
+ if (!\is_array($hashItem)) {
continue;
}
$meta = new Meta();
@@ -195,18 +163,15 @@ public function fromHash($hash)
/**
* Converts the given $value into a plain hash format.
- *
- * @param Value $value
- *
- * @return array
*/
- public function toHash(SPIValue $value)
+ public function toHash(SPIValue $value): array
{
$hash = [];
foreach ($value->metas as $meta) {
/* @var Meta $meta */
- $hash[$meta->getName()] = [
- 'meta_name' => $meta->getName(),
+ $name = $meta->getName();
+ $hash[$name] = [
+ 'meta_name' => $name,
'meta_content' => $meta->getContent(),
];
}
@@ -216,12 +181,8 @@ public function toHash(SPIValue $value)
/**
* Converts a $value to a persistence value.
- *
- * @param Value $value
- *
- * @return FieldValue
*/
- public function toPersistenceValue(SPIValue $value)
+ public function toPersistenceValue(SPIValue $value): FieldValue
{
return new FieldValue(
[
@@ -234,23 +195,16 @@ public function toPersistenceValue(SPIValue $value)
/**
* Converts a persistence $fieldValue to a Value.
- *
- *
- * @return Value
*/
- public function fromPersistenceValue(FieldValue $fieldValue)
+ public function fromPersistenceValue(FieldValue $fieldValue): Value
{
return $this->fromHash($fieldValue->externalData);
}
/**
* Returns if the given $value is considered empty by the field type.
- *
- * @param Value $value
- *
- * @return bool
*/
- public function isEmptyValue(SPIValue $value)
+ public function isEmptyValue(SPIValue $value): bool
{
return null === $value || $value->metas == $this->getEmptyValue()->metas;
}
diff --git a/bundle/Core/FieldType/Metas/Value.php b/bundle/Core/FieldType/Metas/Value.php
index 3322ed1..9a38f3c 100644
--- a/bundle/Core/FieldType/Metas/Value.php
+++ b/bundle/Core/FieldType/Metas/Value.php
@@ -30,6 +30,7 @@ class Value extends BaseValue
*/
public function __construct($metas = null)
{
+ parent::__construct();
if (\is_array($metas)) {
$this->metas = [];
foreach ($metas as $meta) {
diff --git a/bundle/Core/Helper/ImportUrlsHelper.php b/bundle/Core/Helper/ImportUrlsHelper.php
index 8aeb594..c7ef577 100644
--- a/bundle/Core/Helper/ImportUrlsHelper.php
+++ b/bundle/Core/Helper/ImportUrlsHelper.php
@@ -13,13 +13,13 @@
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
+use eZ\Publish\API\Repository\URLWildcardService;
use eZ\Publish\Core\IO\IOService;
-use eZ\Publish\Core\SignalSlot\URLWildcardService;
use Novactive\Bundle\eZSEOBundle\Entity\RedirectImportHistory;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Component\Filesystem\Filesystem;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
class ImportUrlsHelper
{
diff --git a/bundle/Core/MetaNameSchema.php b/bundle/Core/MetaNameSchema.php
index 141f35c..cd3ffa8 100644
--- a/bundle/Core/MetaNameSchema.php
+++ b/bundle/Core/MetaNameSchema.php
@@ -15,25 +15,23 @@
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\Field;
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
-use eZ\Publish\Core\Base\Container\ApiLoader\FieldTypeCollectionFactory;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
+use eZ\Publish\Core\FieldType\FieldTypeRegistry;
use eZ\Publish\Core\FieldType\Image\Value as ImageValue;
use eZ\Publish\Core\FieldType\ImageAsset\Value as ImageAssetValue;
use eZ\Publish\Core\FieldType\Relation\Value as RelationValue;
-use eZ\Publish\Core\FieldType\RelationList\NameableField as RelationListNameableField;
+use eZ\Publish\Core\FieldType\RelationList\Type as RelationListType;
use eZ\Publish\Core\FieldType\RelationList\Value as RelationListValue;
-use eZ\Publish\Core\FieldType\RichText\Converter as RichTextConverterInterface;
-use eZ\Publish\Core\FieldType\RichText\Value as RichTextValue;
use eZ\Publish\Core\Helper\TranslationHelper;
-use eZ\Publish\Core\Repository\Helper\ContentTypeDomainMapper;
-use eZ\Publish\Core\Repository\Helper\FieldTypeRegistry;
-use eZ\Publish\Core\Repository\Helper\NameableFieldTypeRegistry;
use eZ\Publish\Core\Repository\Helper\NameSchemaService;
+use eZ\Publish\Core\Repository\Mapper\ContentTypeDomainMapper;
use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
use eZ\Publish\SPI\Persistence\Content\Language\Handler as ContentLanguageHandler;
use eZ\Publish\SPI\Persistence\Content\Type as SPIContentType;
use eZ\Publish\SPI\Persistence\Content\Type\Handler as ContentTypeHandler;
use eZ\Publish\SPI\Variation\VariationHandler;
+use EzSystems\EzPlatformRichText\eZ\FieldType\RichText\Value as RichTextValue;
+use EzSystems\EzPlatformRichText\eZ\RichText\Converter as RichTextConverterInterface;
class MetaNameSchema extends NameSchemaService
{
@@ -73,32 +71,31 @@ class MetaNameSchema extends NameSchemaService
protected $fieldTypeRegistry;
/**
- * @var RelationListNameableField
+ * @var RelationListType
*/
- protected $relationListNameableField;
+ private $relationListField;
public function __construct(
ContentTypeHandler $contentTypeHandler,
- FieldTypeCollectionFactory $collectionFactory,
+ FieldTypeRegistry $fieldTypeRegistry,
ContentLanguageHandler $languageHandler,
RepositoryInterface $repository,
- TranslationHelper $helper,
- RelationListNameableField $relationListNameableField,
+ TranslationHelper $translationHelper,
array $settings = []
) {
- $fieldTypes = $collectionFactory->getFieldTypes();
- $nameable = new NameableFieldTypeRegistry($fieldTypes);
- $this->fieldTypeRegistry = new FieldTypeRegistry($fieldTypes);
+ $this->fieldTypeRegistry = $fieldTypeRegistry;
$settings['limit'] = $this->fieldContentMaxLength;
$handler = new ContentTypeDomainMapper(
$contentTypeHandler,
$languageHandler,
$this->fieldTypeRegistry
);
- parent::__construct($contentTypeHandler, $handler, $nameable, $settings);
- $this->repository = $repository;
- $this->translationHelper = $helper;
- $this->relationListNameableField = $relationListNameableField;
+
+ parent::__construct($contentTypeHandler, $handler, $fieldTypeRegistry, $settings);
+
+ $this->repository = $repository;
+ $this->translationHelper = $translationHelper;
+ $this->relationListField = $this->fieldTypeRegistry->getFieldType('ezobjectrelationlist');
}
public function setLanguages(array $languages = null): void
@@ -154,7 +151,8 @@ protected function getFieldTitles(array $schemaIdentifiers, $contentType, array
foreach ($contentType->fieldDefinitions as $spiFieldDefinition) {
if ($spiFieldDefinition->identifier === $fieldDefinitionIdentifier) {
$fieldDefinition = $this->contentTypeDomainMapper->buildFieldDefinitionDomainObject(
- $spiFieldDefinition
+ $spiFieldDefinition,
+ $languageCode
);
break;
}
@@ -217,9 +215,8 @@ protected function getFieldTitles(array $schemaIdentifiers, $contentType, array
continue;
}
- $fieldType = $this->fieldTypeRegistry->getFieldType(
- $fieldDefinition->fieldTypeIdentifier
- );
+ $fieldType = $this->fieldTypeRegistry->getFieldType($fieldDefinition->fieldTypeIdentifier);
+
$fieldTitles[$fieldDefinitionIdentifier] = $fieldType->getName(
$fieldMap[$fieldDefinitionIdentifier][$languageCode],
$fieldDefinition,
@@ -237,13 +234,14 @@ protected function getVariation(
string $languageCode,
string $variationName
): string {
- $field = new Field(
+ $field = new Field(
[
'value' => $value,
'fieldDefIdentifier' => $identifier,
'languageCode' => $languageCode,
]
);
+
$variation = $this->imageVariationService->getVariation($field, new VersionInfo(), $variationName);
return $variation->uri;
@@ -279,7 +277,7 @@ protected function handleRelationValue(RelationValue $value, string $languageCod
protected function handleRelationListValue(RelationListValue $value, $fieldDefinition, $languageCode): string
{
- return $this->relationListNameableField->getFieldName($value, $fieldDefinition, $languageCode);
+ return $this->relationListField->getName($value, $fieldDefinition, $languageCode);
}
/**
diff --git a/bundle/Core/SiteAccessAwareEntityManagerFactory.php b/bundle/Core/SiteAccessAwareEntityManagerFactory.php
index 3de886b..9fcc282 100644
--- a/bundle/Core/SiteAccessAwareEntityManagerFactory.php
+++ b/bundle/Core/SiteAccessAwareEntityManagerFactory.php
@@ -13,13 +13,13 @@
namespace Novactive\Bundle\eZSEOBundle\Core;
use Doctrine\Bundle\DoctrineBundle\Mapping\ContainerEntityListenerResolver;
-use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
-use eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider;
use Doctrine\ORM\Mapping\UnderscoreNamingStrategy;
+use Doctrine\Persistence\ManagerRegistry as Registry;
+use eZ\Bundle\EzPublishCoreBundle\ApiLoader\RepositoryConfigurationProvider;
class SiteAccessAwareEntityManagerFactory
{
@@ -39,7 +39,7 @@ class SiteAccessAwareEntityManagerFactory
private $settings;
/**
- * @var ContainerAwareEntityListenerResolver
+ * @var ContainerEntityListenerResolver
*/
private $resolver;
diff --git a/bundle/Core/UrlWildcardRouter.php b/bundle/Core/UrlWildcardRouter.php
index 43e32aa..ee2c9a5 100644
--- a/bundle/Core/UrlWildcardRouter.php
+++ b/bundle/Core/UrlWildcardRouter.php
@@ -13,103 +13,41 @@
use Exception;
use eZ\Publish\API\Repository\URLWildcardService;
-use eZ\Publish\API\Repository\Values\Content\URLWildcard;
-use eZ\Publish\API\Repository\Values\Content\URLWildcardTranslationResult;
-use RuntimeException;
-use Symfony\Cmf\Component\Routing\ChainedRouterInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use eZ\Publish\Core\MVC\Symfony\Routing\UrlWildcardRouter as BaseUrlWildcardRouter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
-use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
-use Symfony\Component\Routing\RequestContext;
-use Symfony\Component\Routing\Route as SymfonyRoute;
-use Symfony\Component\Routing\RouteCollection;
-class UrlWildcardRouter implements RequestMatcherInterface, ChainedRouterInterface
+class UrlWildcardRouter extends BaseUrlWildcardRouter
{
- const URL_WILDCARD_ROUTE_NAME = 'ez_urlwildcard';
+ /** @var URLWildcardService */
+ private $wildcardService;
- /**
- * @var RequestContext
- */
- protected $requestContext;
-
- /**
- * @var URLWildcardService
- */
- protected $urlWildcardService;
-
- public function __construct(URLWildcardService $urlWildcardService)
- {
- $this->urlWildcardService = $urlWildcardService;
- }
-
- public function setContext(RequestContext $context): void
- {
- $this->requestContext = $context;
- }
-
- public function getContext(): RequestContext
- {
- return $this->requestContext;
- }
-
- public function getRouteCollection(): RouteCollection
- {
- return new RouteCollection();
- }
-
- public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string
- {
- return '';
- }
-
- public function match($pathinfo)
+ public function setWildcardService(URLWildcardService $wildcardService): void
{
- throw new RuntimeException(
- "The UrlWildcardRouter doesn't support the match() method. Please use matchRequest() instead."
- );
+ $this->wildcardService = $wildcardService;
}
- public function supports($name): bool
- {
- return $name instanceof URLWildcard || self::URL_WILDCARD_ROUTE_NAME === $name;
- }
-
- public function getRouteDebugMessage($name, array $parameters = []): string
- {
- if ($name instanceof RouteObjectInterface) {
- return 'Route with key '.$name->getRouteKey();
- }
-
- if ($name instanceof SymfonyRoute) {
- return 'Route with pattern '.$name->getPath();
- }
-
- return $name;
- }
-
- public function matchRequest(Request $request): ?array
+ public function matchRequest(Request $request): array
{
try {
$requestedPath = $request->attributes->get('semanticPathinfo', $request->getPathInfo());
- $urlWildcard = $this->getUrlWildcard($requestedPath);
+ $urlWildcard = $this->wildcardService->translate($requestedPath);
$params = [
- '_route' => self::URL_WILDCARD_ROUTE_NAME,
+ '_route' => 'ez_urlalias',
];
- // In URLAlias terms, "forward" means "redirect".
- if ($urlWildcard->forward) {
- $params += [ 'needsRedirect' => true ];
+ if (0 === strpos($urlWildcard->uri, 'http://') || 'https://' === substr($urlWildcard->uri, 0, 8)) {
+ $params += ['semanticPathinfo' => trim($urlWildcard->uri, '/')];
} else {
- $params += [ 'needsForward' => true ];
+ $params += ['semanticPathinfo' => '/'.trim($urlWildcard->uri, '/')];
}
- if (substr($urlWildcard->uri, 0, 7) === "http://" || substr($urlWildcard->uri, 0, 8) === "https://") {
- $params += [ 'semanticPathinfo' => trim($urlWildcard->uri, '/') ];
+ // In URLAlias terms, "forward" means "redirect".
+ if ($urlWildcard->forward) {
+ $params += ['needsRedirect' => true];
} else {
- $params += [ 'semanticPathinfo' => '/'.trim($urlWildcard->uri, '/') ];
+ $params += ['needsForward' => true];
}
return $params;
@@ -117,9 +55,4 @@ public function matchRequest(Request $request): ?array
throw new ResourceNotFoundException($e->getMessage(), $e->getCode(), $e);
}
}
-
- protected function getUrlWildcard($pathinfo): URLWildcardTranslationResult
- {
- return $this->urlWildcardService->translate($pathinfo);
- }
}
diff --git a/bundle/DependencyInjection/Configuration.php b/bundle/DependencyInjection/Configuration.php
index a877816..99ceb18 100644
--- a/bundle/DependencyInjection/Configuration.php
+++ b/bundle/DependencyInjection/Configuration.php
@@ -18,8 +18,8 @@ class Configuration extends SAConfiguration
{
public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
- $rootNode = $treeBuilder->root('nova_ezseo');
+ $treeBuilder = new TreeBuilder('nova_ezseo');
+ $rootNode = $treeBuilder->getRootNode();
$systemNode = $this->generateScopeBaseNode($rootNode);
$systemNode
->scalarNode('custom_fallback_service')->defaultValue('~')->end()
diff --git a/bundle/DependencyInjection/NovaeZSEOExtension.php b/bundle/DependencyInjection/NovaeZSEOExtension.php
index dcd15ce..969eb30 100644
--- a/bundle/DependencyInjection/NovaeZSEOExtension.php
+++ b/bundle/DependencyInjection/NovaeZSEOExtension.php
@@ -33,6 +33,7 @@ public function prepend(ContainerBuilder $container): void
$container->prependExtensionConfig('assetic', ['bundles' => ['NovaeZSEOBundle']]);
$configs = [
+ 'wildcard_routing.yml' => 'ezpublish',
'ez_field_templates.yml' => 'ezpublish',
'variations.yml' => 'ezpublish',
'admin_ui/ez_field_templates.yml' => 'ezpublish',
diff --git a/bundle/NovaeZSEOBundle.php b/bundle/NovaeZSEOBundle.php
index 5e9f470..ec8d186 100644
--- a/bundle/NovaeZSEOBundle.php
+++ b/bundle/NovaeZSEOBundle.php
@@ -36,13 +36,9 @@ public function getContainerExtension()
if (null !== $extension) {
if (!$extension instanceof ExtensionInterface) {
- throw new LogicException(
- sprintf(
- 'Extension %s must implement %s.',
- \get_class($extension),
- ExtensionInterface::class
- )
- );
+ $fqdn = \get_class($extension);
+ $message = 'Extension %s must implement %s.';
+ throw new LogicException(sprintf($message, $fqdn, ExtensionInterface::class));
}
$this->extension = $extension;
} else {
diff --git a/bundle/Resources/config/admin_ui/ez_field_templates.yml b/bundle/Resources/config/admin_ui/ez_field_templates.yml
index 3264b86..dc0532b 100644
--- a/bundle/Resources/config/admin_ui/ez_field_templates.yml
+++ b/bundle/Resources/config/admin_ui/ez_field_templates.yml
@@ -2,5 +2,5 @@ system:
admin_group:
field_templates:
-
- template: "NovaeZSEOBundle:fields:novaseometas_admin.html.twig"
+ template: "@NovaeZSEO/fields/novaseometas_admin.html.twig"
priority: 10
diff --git a/bundle/Resources/config/ez_field_templates.yml b/bundle/Resources/config/ez_field_templates.yml
index 2197f73..30b1404 100644
--- a/bundle/Resources/config/ez_field_templates.yml
+++ b/bundle/Resources/config/ez_field_templates.yml
@@ -2,12 +2,12 @@ system:
default:
fielddefinition_settings_templates:
-
- template: "NovaeZSEOBundle:fields:fielddefinition_settings.html.twig"
+ template: "@NovaeZSEO/fields/fielddefinition_settings.html.twig"
fielddefinition_edit_templates:
-
- template: "NovaeZSEOBundle:fields:field_types.html.twig"
+ template: "@NovaeZSEO/fields/field_types.html.twig"
field_templates:
-
- template: "NovaeZSEOBundle:fields:novaseometas.html.twig"
+ template: "@NovaeZSEO/fields/novaseometas.html.twig"
diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml
index 6675a83..a0ac702 100644
--- a/bundle/Resources/config/services.yml
+++ b/bundle/Resources/config/services.yml
@@ -19,13 +19,18 @@ services:
- { name: ezpublish.fieldType.indexable, alias: novaseometas }
Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage:
+ arguments:
+ $gateway: '@Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway\DoctrineStorage'
public: true
tags:
- { name: ezpublish.fieldType.externalStorageHandler, alias: novaseometas }
- Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway\LegacyStorage:
+ Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\MetasStorage\Gateway\DoctrineStorage:
+ arguments:
+ $connection: "@ezpublish.api.storage_engine.legacy.connection"
tags:
- - { name: ezpublish.fieldType.externalStorageHandler.gateway, alias: novaseometas, identifier: LegacyStorage }
+ - { name: ezpublish.fieldType.externalStorageHandler.gateway, alias: novaseometas, identifier: LegacyStorage }
+
Novactive\Bundle\eZSEOBundle\Core\FieldType\Metas\Converter:
tags:
@@ -47,9 +52,10 @@ services:
arguments:
$contentTypeHandler: "@ezpublish.spi.persistence.content_type_handler"
$languageHandler: "@ezpublish.spi.persistence.cache.contentLanguageHandler"
+ $translationHelper: "@ezpublish.translation_helper"
calls:
- - [setLanguages, ["$languages$"]]
- - [setRichTextConverter, ["@ezpublish.fieldType.ezrichtext.converter.output.xhtml5"]]
+ - [setLanguages, ["@=service('ezpublish.config.resolver').getParameter('languages')"]]
+ - [setRichTextConverter, ["@ezrichtext.converter.output.xhtml5.core"]]
# Note: injecting lower layer Variation Handler (AliasGenerator) as a workaround for missing Public API objects context
- [setImageVariationService, ["@ezpublish.image_alias.imagine.alias_generator", "@ezpublish.fieldType.ezimage"]]
@@ -65,12 +71,6 @@ services:
Novactive\Bundle\eZSEOBundle\Core\Converter\ContentTypesHelper: ~
- Novactive\Bundle\eZSEOBundle\Core\UrlWildcardRouter:
- arguments:
- $urlWildcardService: "@ezpublish.api.service.url_wildcard"
- tags:
- - { name: router, priority: 2000 }
-
Novactive\Bundle\eZSEOBundle\Listener\AdminTopMenu:
tags:
- { name: kernel.event_listener, event: "ezplatform_admin_ui.menu_configure.main_menu", method: "onMenuConfigure", priority: -100 }
@@ -80,8 +80,24 @@ services:
$cacheDirectory: '%kernel.cache_dir%'
Novactive\Bundle\eZSEOBundle\Core\SiteAccessAwareEntityManagerFactory:
- $settings: { debug: "%kernel.debug%", cache_dir: "%kernel.cache_dir%" }
+ arguments:
+ $repositoryConfigurationProvider: "@ezpublish.api.repository_configuration_provider"
+ $resolver: "@doctrine.orm.default_entity_listener_resolver"
+ $settings: { debug: "%kernel.debug%", cache_dir: "%kernel.cache_dir%" }
novaezmailing.doctrine.entity_manager:
class: Doctrine\ORM\EntityManagerInterface
- factory: 'Novactive\Bundle\eZSEOBundle\Core\SiteAccessAwareEntityManagerFactory:get'
+ factory: ['@Novactive\Bundle\eZSEOBundle\Core\SiteAccessAwareEntityManagerFactory', 'get']
+
+
+ Novactive\Bundle\eZSEOBundle\Core\UrlWildcardRouter:
+ arguments:
+ - '@ezpublish.api.service.url_wildcard'
+ - '@ezpublish.urlalias_generator'
+ - '@router.request_context'
+ calls:
+ - [setLogger, ['@?logger']]
+ - [setWildcardService, ['@ezpublish.api.service.url_wildcard']]
+ tags:
+ - { name: router, priority: 2000 }
+
diff --git a/bundle/Resources/config/wildcard_routing.yml b/bundle/Resources/config/wildcard_routing.yml
new file mode 100644
index 0000000..efd57dc
--- /dev/null
+++ b/bundle/Resources/config/wildcard_routing.yml
@@ -0,0 +1,2 @@
+url_wildcards:
+ enabled: true
diff --git a/bundle/Resources/sql/shema.sql b/bundle/Resources/sql/schema.sql
similarity index 100%
rename from bundle/Resources/sql/shema.sql
rename to bundle/Resources/sql/schema.sql
diff --git a/bundle/Resources/views/fields/field_types.html.twig b/bundle/Resources/views/fields/field_types.html.twig
index 0e4e941..caf59a2 100644
--- a/bundle/Resources/views/fields/field_types.html.twig
+++ b/bundle/Resources/views/fields/field_types.html.twig
@@ -1,4 +1,4 @@
-{% extends 'EzSystemsRepositoryFormsBundle:ContentType:field_types.html.twig' %}
+{% extends '@EzPlatformAdminUi/themes/admin/content_type/field_types.html.twig' %}
{% block novaseometas_field_definition_edit %}