From 8b8deb68ce410de763c2159d920af4fbc135dcd1 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Thu, 10 Aug 2023 16:44:26 +0200 Subject: [PATCH 1/5] pimcore 11 suport --- .../config.yml => config/pimcore/config.yaml | 0 .../services.yml => config/services.yaml | 0 .../event.yml => config/services/event.yaml | 0 .../services/generator.yaml | 0 .../services/install.yaml | 0 .../services/processor.yaml | 0 .../services/registry.yaml | 0 .../twig.yml => config/services/twig.yaml | 0 .../seo.yml => config/third_party/seo.yaml | 0 .../Compiler/SchemaGeneratorAdapterPass.php | 3 +- .../DependencyInjection/Configuration.php | 0 src/DependencyInjection/SchemaExtension.php | 39 +++++++++++++ .../EventListener/SchemaListener.php | 13 +---- .../Generator/FragmentGeneratorInterface.php | 0 .../Generator/GeneratorInterface.php | 0 src/{SchemaBundle => }/Migrations/.gitkeep | 0 .../Processor/SchemaElementProcessor.php | 5 +- .../SchemaElementProcessorInterface.php | 0 .../Processor/SchemaRequestProcessor.php | 13 +---- .../SchemaRequestProcessorInterface.php | 0 .../Registry/SchemaGeneratorRegistry.php | 0 .../SchemaGeneratorRegistryInterface.php | 0 src/{SchemaBundle => }/SchemaBundle.php | 5 ++ .../DependencyInjection/SchemaExtension.php | 37 ------------ .../Seo/Middleware/SchemaGraphAdapter.php | 0 src/{SchemaBundle => }/Tool/Install.php | 5 -- .../Twig/Extension/JsonLdExtension.php | 5 +- .../views => templates}/layout.html.twig | 0 ...ite.dist.yml => Functional.suite.dist.yml} | 0 .../{functional => Functional}/_bootstrap.php | 0 .../FunctionalTester.php | 0 tests/{_support => Support}/UnitTester.php | 0 ...nit.suite.dist.yml => Unit.suite.dist.yml} | 0 tests/{unit => Unit}/_bootstrap.php | 0 tests/_etc/{config.yml => config.yaml} | 0 tests/_etc/config/app/config.yaml | 56 +++++++++++++++++++ tests/_etc/config/app/config.yml | 29 ---------- .../app/{system.yml => system_settings.yaml} | 6 -- ...config_default.yml => config_default.yaml} | 0 39 files changed, 109 insertions(+), 107 deletions(-) rename src/SchemaBundle/Resources/config/pimcore/config.yml => config/pimcore/config.yaml (100%) rename src/SchemaBundle/Resources/config/services.yml => config/services.yaml (100%) rename src/SchemaBundle/Resources/config/services/event.yml => config/services/event.yaml (100%) rename src/SchemaBundle/Resources/config/services/generator.yml => config/services/generator.yaml (100%) rename src/SchemaBundle/Resources/config/services/install.yml => config/services/install.yaml (100%) rename src/SchemaBundle/Resources/config/services/processor.yml => config/services/processor.yaml (100%) rename src/SchemaBundle/Resources/config/services/registry.yml => config/services/registry.yaml (100%) rename src/SchemaBundle/Resources/config/services/twig.yml => config/services/twig.yaml (100%) rename src/SchemaBundle/Resources/config/external/seo.yml => config/third_party/seo.yaml (100%) rename src/{SchemaBundle => }/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php (92%) rename src/{SchemaBundle => }/DependencyInjection/Configuration.php (100%) create mode 100644 src/DependencyInjection/SchemaExtension.php rename src/{SchemaBundle => }/EventListener/SchemaListener.php (75%) rename src/{SchemaBundle => }/Generator/FragmentGeneratorInterface.php (100%) rename src/{SchemaBundle => }/Generator/GeneratorInterface.php (100%) rename src/{SchemaBundle => }/Migrations/.gitkeep (100%) rename src/{SchemaBundle => }/Processor/SchemaElementProcessor.php (84%) rename src/{SchemaBundle => }/Processor/SchemaElementProcessorInterface.php (100%) rename src/{SchemaBundle => }/Processor/SchemaRequestProcessor.php (78%) rename src/{SchemaBundle => }/Processor/SchemaRequestProcessorInterface.php (100%) rename src/{SchemaBundle => }/Registry/SchemaGeneratorRegistry.php (100%) rename src/{SchemaBundle => }/Registry/SchemaGeneratorRegistryInterface.php (100%) rename src/{SchemaBundle => }/SchemaBundle.php (90%) delete mode 100644 src/SchemaBundle/DependencyInjection/SchemaExtension.php rename src/{SchemaBundle => }/Seo/Middleware/SchemaGraphAdapter.php (100%) rename src/{SchemaBundle => }/Tool/Install.php (60%) rename src/{SchemaBundle => }/Twig/Extension/JsonLdExtension.php (77%) rename {src/SchemaBundle/Resources/views => templates}/layout.html.twig (100%) rename tests/{functional.suite.dist.yml => Functional.suite.dist.yml} (100%) rename tests/{functional => Functional}/_bootstrap.php (100%) rename tests/{_support => Support}/FunctionalTester.php (100%) rename tests/{_support => Support}/UnitTester.php (100%) rename tests/{unit.suite.dist.yml => Unit.suite.dist.yml} (100%) rename tests/{unit => Unit}/_bootstrap.php (100%) rename tests/_etc/{config.yml => config.yaml} (100%) create mode 100755 tests/_etc/config/app/config.yaml delete mode 100755 tests/_etc/config/app/config.yml rename tests/_etc/config/app/{system.yml => system_settings.yaml} (92%) rename tests/_etc/config/bundle/{config_default.yml => config_default.yaml} (100%) diff --git a/src/SchemaBundle/Resources/config/pimcore/config.yml b/config/pimcore/config.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/pimcore/config.yml rename to config/pimcore/config.yaml diff --git a/src/SchemaBundle/Resources/config/services.yml b/config/services.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services.yml rename to config/services.yaml diff --git a/src/SchemaBundle/Resources/config/services/event.yml b/config/services/event.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services/event.yml rename to config/services/event.yaml diff --git a/src/SchemaBundle/Resources/config/services/generator.yml b/config/services/generator.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services/generator.yml rename to config/services/generator.yaml diff --git a/src/SchemaBundle/Resources/config/services/install.yml b/config/services/install.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services/install.yml rename to config/services/install.yaml diff --git a/src/SchemaBundle/Resources/config/services/processor.yml b/config/services/processor.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services/processor.yml rename to config/services/processor.yaml diff --git a/src/SchemaBundle/Resources/config/services/registry.yml b/config/services/registry.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services/registry.yml rename to config/services/registry.yaml diff --git a/src/SchemaBundle/Resources/config/services/twig.yml b/config/services/twig.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/services/twig.yml rename to config/services/twig.yaml diff --git a/src/SchemaBundle/Resources/config/external/seo.yml b/config/third_party/seo.yaml similarity index 100% rename from src/SchemaBundle/Resources/config/external/seo.yml rename to config/third_party/seo.yaml diff --git a/src/SchemaBundle/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php b/src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php similarity index 92% rename from src/SchemaBundle/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php rename to src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php index f3d59c7..24852d6 100644 --- a/src/SchemaBundle/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php +++ b/src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php @@ -13,9 +13,10 @@ final class SchemaGeneratorAdapterPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { foreach ($container->findTaggedServiceIds('schema.generator', true) as $id => $tags) { + $definition = $container->getDefinition(SchemaGeneratorRegistry::class); - if ($container->getParameter('schema.flag.schema_listener_removed') === true) { + if ($container->hasParameter('schema.third_party.seo.enabled') && $container->getParameter('schema.third_party.seo.enabled') === true) { $message = sprintf( 'Cannot register schema generator "%s" because you have installed the SEO Bundle. If you want to add some fragment generator (via twig) use the "schema.fragment_generator" tag. Read more about it here: %s', $id, diff --git a/src/SchemaBundle/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php similarity index 100% rename from src/SchemaBundle/DependencyInjection/Configuration.php rename to src/DependencyInjection/Configuration.php diff --git a/src/DependencyInjection/SchemaExtension.php b/src/DependencyInjection/SchemaExtension.php new file mode 100644 index 0000000..417ec88 --- /dev/null +++ b/src/DependencyInjection/SchemaExtension.php @@ -0,0 +1,39 @@ +processConfiguration($configuration, $configs); + + $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../../config'])); + $loader->load('services.yaml'); + } + + public function prepend(ContainerBuilder $container) + { + if ($container->hasExtension('seo')) { + return; + } + + $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../../config'])); + + $container->setParameter('schema.third_party.seo.enabled', true); + + $loader->load('third_party/seo.yaml'); + + if ($container->hasDefinition(SchemaListener::class)) { + $container->removeDefinition(SchemaListener::class); + } + } +} diff --git a/src/SchemaBundle/EventListener/SchemaListener.php b/src/EventListener/SchemaListener.php similarity index 75% rename from src/SchemaBundle/EventListener/SchemaListener.php rename to src/EventListener/SchemaListener.php index ce738dc..8434677 100644 --- a/src/SchemaBundle/EventListener/SchemaListener.php +++ b/src/EventListener/SchemaListener.php @@ -11,22 +11,15 @@ class SchemaListener implements EventSubscriberInterface { - protected SchemaRequestProcessorInterface $schemaRequestProcessor; - protected RequestHelper $requestHelper; - protected PimcoreContextResolver $pimcoreContextResolver; - /** * This service is only available in standalone mode. * If you've installed the SEO Bundle, this class is not available! */ public function __construct( - SchemaRequestProcessorInterface $schemaRequestProcessor, - RequestHelper $requestHelper, - PimcoreContextResolver $contextResolver + protected SchemaRequestProcessorInterface $schemaRequestProcessor, + protected RequestHelper $requestHelper, + protected PimcoreContextResolver $pimcoreContextResolver ) { - $this->schemaRequestProcessor = $schemaRequestProcessor; - $this->requestHelper = $requestHelper; - $this->pimcoreContextResolver = $contextResolver; } public static function getSubscribedEvents(): array diff --git a/src/SchemaBundle/Generator/FragmentGeneratorInterface.php b/src/Generator/FragmentGeneratorInterface.php similarity index 100% rename from src/SchemaBundle/Generator/FragmentGeneratorInterface.php rename to src/Generator/FragmentGeneratorInterface.php diff --git a/src/SchemaBundle/Generator/GeneratorInterface.php b/src/Generator/GeneratorInterface.php similarity index 100% rename from src/SchemaBundle/Generator/GeneratorInterface.php rename to src/Generator/GeneratorInterface.php diff --git a/src/SchemaBundle/Migrations/.gitkeep b/src/Migrations/.gitkeep similarity index 100% rename from src/SchemaBundle/Migrations/.gitkeep rename to src/Migrations/.gitkeep diff --git a/src/SchemaBundle/Processor/SchemaElementProcessor.php b/src/Processor/SchemaElementProcessor.php similarity index 84% rename from src/SchemaBundle/Processor/SchemaElementProcessor.php rename to src/Processor/SchemaElementProcessor.php index a048cb8..e589f87 100644 --- a/src/SchemaBundle/Processor/SchemaElementProcessor.php +++ b/src/Processor/SchemaElementProcessor.php @@ -7,11 +7,8 @@ class SchemaElementProcessor implements SchemaElementProcessorInterface { - protected SchemaGeneratorRegistryInterface $generatorRegistry; - - public function __construct(SchemaGeneratorRegistryInterface $generatorRegistry) + public function __construct(protected SchemaGeneratorRegistryInterface $generatorRegistry) { - $this->generatorRegistry = $generatorRegistry; } public function process($element): string diff --git a/src/SchemaBundle/Processor/SchemaElementProcessorInterface.php b/src/Processor/SchemaElementProcessorInterface.php similarity index 100% rename from src/SchemaBundle/Processor/SchemaElementProcessorInterface.php rename to src/Processor/SchemaElementProcessorInterface.php diff --git a/src/SchemaBundle/Processor/SchemaRequestProcessor.php b/src/Processor/SchemaRequestProcessor.php similarity index 78% rename from src/SchemaBundle/Processor/SchemaRequestProcessor.php rename to src/Processor/SchemaRequestProcessor.php index c178849..d458691 100644 --- a/src/SchemaBundle/Processor/SchemaRequestProcessor.php +++ b/src/Processor/SchemaRequestProcessor.php @@ -10,15 +10,10 @@ class SchemaRequestProcessor implements SchemaRequestProcessorInterface { - protected HeadMeta $headMeta; - protected SchemaGeneratorRegistryInterface $generatorRegistry; - public function __construct( - HeadMeta $headMeta, - SchemaGeneratorRegistryInterface $generatorRegistry + protected HeadMeta $headMeta, + protected SchemaGeneratorRegistryInterface $generatorRegistry ) { - $this->headMeta = $headMeta; - $this->generatorRegistry = $generatorRegistry; } public function process(Request $request): void @@ -38,10 +33,6 @@ public function process(Request $request): void $this->appendHeadMeta($graph, $schemaBlocks); } - /** - * @param Graph $graph - * @param array $schemaBlocks - */ protected function appendHeadMeta(Graph $graph, array $schemaBlocks): void { $nodes = $graph->getNodes(); diff --git a/src/SchemaBundle/Processor/SchemaRequestProcessorInterface.php b/src/Processor/SchemaRequestProcessorInterface.php similarity index 100% rename from src/SchemaBundle/Processor/SchemaRequestProcessorInterface.php rename to src/Processor/SchemaRequestProcessorInterface.php diff --git a/src/SchemaBundle/Registry/SchemaGeneratorRegistry.php b/src/Registry/SchemaGeneratorRegistry.php similarity index 100% rename from src/SchemaBundle/Registry/SchemaGeneratorRegistry.php rename to src/Registry/SchemaGeneratorRegistry.php diff --git a/src/SchemaBundle/Registry/SchemaGeneratorRegistryInterface.php b/src/Registry/SchemaGeneratorRegistryInterface.php similarity index 100% rename from src/SchemaBundle/Registry/SchemaGeneratorRegistryInterface.php rename to src/Registry/SchemaGeneratorRegistryInterface.php diff --git a/src/SchemaBundle/SchemaBundle.php b/src/SchemaBundle.php similarity index 90% rename from src/SchemaBundle/SchemaBundle.php rename to src/SchemaBundle.php index f724a75..895fecd 100644 --- a/src/SchemaBundle/SchemaBundle.php +++ b/src/SchemaBundle.php @@ -24,6 +24,11 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new SchemaGeneratorAdapterPass()); } + public function getPath(): string + { + return \dirname(__DIR__); + } + protected function getComposerPackageName(): string { return self::PACKAGE_NAME; diff --git a/src/SchemaBundle/DependencyInjection/SchemaExtension.php b/src/SchemaBundle/DependencyInjection/SchemaExtension.php deleted file mode 100644 index c447589..0000000 --- a/src/SchemaBundle/DependencyInjection/SchemaExtension.php +++ /dev/null @@ -1,37 +0,0 @@ -processConfiguration($configuration, $configs); - - $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../Resources/config'])); - $loader->load('services.yml'); - - $this->checkDependencies($container, $loader); - } - - protected function checkDependencies(ContainerBuilder $container, YamlFileLoader $loader): void - { - $bundles = $container->getParameter('kernel.bundles'); - $container->setParameter('schema.flag.schema_listener_removed', false); - - if (array_key_exists('SeoBundle', $bundles)) { - $loader->load('external/seo.yml'); - if ($container->hasDefinition(SchemaListener::class)) { - $container->removeDefinition(SchemaListener::class); - $container->setParameter('schema.flag.schema_listener_removed', true); - } - } - } -} diff --git a/src/SchemaBundle/Seo/Middleware/SchemaGraphAdapter.php b/src/Seo/Middleware/SchemaGraphAdapter.php similarity index 100% rename from src/SchemaBundle/Seo/Middleware/SchemaGraphAdapter.php rename to src/Seo/Middleware/SchemaGraphAdapter.php diff --git a/src/SchemaBundle/Tool/Install.php b/src/Tool/Install.php similarity index 60% rename from src/SchemaBundle/Tool/Install.php rename to src/Tool/Install.php index bcd0961..d419896 100644 --- a/src/SchemaBundle/Tool/Install.php +++ b/src/Tool/Install.php @@ -6,10 +6,5 @@ class Install extends SettingsStoreAwareInstaller { - public function install() - { - // currently, nothing to do. - parent::install(); - } } diff --git a/src/SchemaBundle/Twig/Extension/JsonLdExtension.php b/src/Twig/Extension/JsonLdExtension.php similarity index 77% rename from src/SchemaBundle/Twig/Extension/JsonLdExtension.php rename to src/Twig/Extension/JsonLdExtension.php index 222c767..356ad8a 100644 --- a/src/SchemaBundle/Twig/Extension/JsonLdExtension.php +++ b/src/Twig/Extension/JsonLdExtension.php @@ -8,11 +8,8 @@ class JsonLdExtension extends AbstractExtension { - protected SchemaElementProcessorInterface $schemaElementProcessor; - - public function __construct(SchemaElementProcessorInterface $schemaElementProcessor) + public function __construct(protected SchemaElementProcessorInterface $schemaElementProcessor) { - $this->schemaElementProcessor = $schemaElementProcessor; } public function getFilters(): array diff --git a/src/SchemaBundle/Resources/views/layout.html.twig b/templates/layout.html.twig similarity index 100% rename from src/SchemaBundle/Resources/views/layout.html.twig rename to templates/layout.html.twig diff --git a/tests/functional.suite.dist.yml b/tests/Functional.suite.dist.yml similarity index 100% rename from tests/functional.suite.dist.yml rename to tests/Functional.suite.dist.yml diff --git a/tests/functional/_bootstrap.php b/tests/Functional/_bootstrap.php similarity index 100% rename from tests/functional/_bootstrap.php rename to tests/Functional/_bootstrap.php diff --git a/tests/_support/FunctionalTester.php b/tests/Support/FunctionalTester.php similarity index 100% rename from tests/_support/FunctionalTester.php rename to tests/Support/FunctionalTester.php diff --git a/tests/_support/UnitTester.php b/tests/Support/UnitTester.php similarity index 100% rename from tests/_support/UnitTester.php rename to tests/Support/UnitTester.php diff --git a/tests/unit.suite.dist.yml b/tests/Unit.suite.dist.yml similarity index 100% rename from tests/unit.suite.dist.yml rename to tests/Unit.suite.dist.yml diff --git a/tests/unit/_bootstrap.php b/tests/Unit/_bootstrap.php similarity index 100% rename from tests/unit/_bootstrap.php rename to tests/Unit/_bootstrap.php diff --git a/tests/_etc/config.yml b/tests/_etc/config.yaml similarity index 100% rename from tests/_etc/config.yml rename to tests/_etc/config.yaml diff --git a/tests/_etc/config/app/config.yaml b/tests/_etc/config/app/config.yaml new file mode 100755 index 0000000..7ac9dbd --- /dev/null +++ b/tests/_etc/config/app/config.yaml @@ -0,0 +1,56 @@ +imports: + - { resource: services.yaml } + - { resource: 'local/' } + +services: + App\Controller\DefaultController: + public: true + autowire: true + autoconfigure: true + calls: + - [setContainer, ['@service_container']] + +doctrine: + dbal: + connections: + default: + mapping_types: + enum: string + bit: boolean + +pimcore: + config_location: + image_thumbnails: + write_target: + type: 'settings-store' + video_thumbnails: + write_target: + type: 'settings-store' + document_types: + write_target: + type: 'settings-store' + predefined_properties: + write_target: + type: 'settings-store' + predefined_asset_metadata: + write_target: + type: 'settings-store' + perspectives: + write_target: + type: 'settings-store' + custom_views: + write_target: + type: 'settings-store' + object_custom_layouts: + write_target: + type: 'settings-store' + +framework: + profiler: + enabled: true + collect: false + # don't send real emails in functional tests + mailer: + transports: + main: 'null://null' + pimcore_newsletter: 'null://null' \ No newline at end of file diff --git a/tests/_etc/config/app/config.yml b/tests/_etc/config/app/config.yml deleted file mode 100755 index 0a6240c..0000000 --- a/tests/_etc/config/app/config.yml +++ /dev/null @@ -1,29 +0,0 @@ -imports: - - { resource: services.yaml } - - { resource: 'local/' } - -services: - App\Controller\DefaultController: - public: true - autowire: true - autoconfigure: true - calls: - - [setContainer, ['@service_container']] - -doctrine: - dbal: - connections: - default: - mapping_types: - enum: string - bit: boolean - -framework: - profiler: - enabled: true - collect: false - # don't send real emails in functional tests - mailer: - transports: - main: 'null://null' - pimcore_newsletter: 'null://null' \ No newline at end of file diff --git a/tests/_etc/config/app/system.yml b/tests/_etc/config/app/system_settings.yaml similarity index 92% rename from tests/_etc/config/app/system.yml rename to tests/_etc/config/app/system_settings.yaml index 2480015..52c5500 100755 --- a/tests/_etc/config/app/system.yml +++ b/tests/_etc/config/app/system_settings.yaml @@ -36,12 +36,6 @@ pimcore: email: debug: email_addresses: opensource@dachcom.ch - services: - google: - client_id: '' - email: '' - simple_api_key: '' - browser_api_key: '' full_page_cache: exclude_cookie: '' enabled: false diff --git a/tests/_etc/config/bundle/config_default.yml b/tests/_etc/config/bundle/config_default.yaml similarity index 100% rename from tests/_etc/config/bundle/config_default.yml rename to tests/_etc/config/bundle/config_default.yaml From d8c2fff6b181310e7b3c57c91931c8fb811dc780 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 11 Aug 2023 08:34:19 +0200 Subject: [PATCH 2/5] upgrade tests --- .github/workflows/codeception.yml | 30 ++++++--- .github/workflows/ecs.yml | 12 ++-- .github/workflows/php-stan.yml | 12 ++-- .gitignore | 2 +- LICENSE.md | 2 +- README.md | 26 +++++--- UPGRADE.md | 8 +-- codeception.dist.yml | 9 +-- composer.json | 16 ++--- config/services.yaml | 2 +- docs/00_Usage.md | 3 +- docs/02_StandaloneUsage.md | 3 +- phpstan.neon | 4 +- tests/Functional.suite.dist.yml | 12 ++-- tests/Support/FunctionalTester.php | 4 +- tests/Support/UnitTester.php | 4 +- tests/Unit.suite.dist.yml | 6 +- tests/_bootstrap.php | 7 +-- tests/_etc/config.yaml | 11 ++-- tests/_etc/config/app/system_settings.yaml | 62 +++++++------------ .../config/app/templates/default.html.twig | 2 +- 21 files changed, 119 insertions(+), 118 deletions(-) diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index 8282037..bce8e13 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -15,10 +15,10 @@ jobs: TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "2.0" + PIMCORE_CODECEPTION_VERSION: "3.0" APP_ENV: test - PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" + PIMCORE_TEST_DB_DSN: "mysql://test:test@127.0.0.1:3306/dachcom_bundle_test" PIMCORE_TEST_URL: "http://localhost" PIMCORE_CLASS_DIRECTORY: "${{ github.workspace }}/lib/test-bundle/tests/_output/var/classes/DataObject" @@ -38,12 +38,12 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [ 8.1 ] - symfony: [ ^5.4 ] - pimcore: [ ~10.6.0 ] + php: [ 8.2 ] + symfony: [ ^6.2 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: ~10.6.0 - template_tag: v10.2.5 + - pimcore: ~11.0.0 + template_tag: v11.0.0 steps: - uses: actions/checkout@v2 with: @@ -82,9 +82,19 @@ jobs: run: php -v - name: Setup MySql - run: | - sudo systemctl start mysql - mysql -uroot -proot -h127.0.0.1 -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;" + uses: shogo82148/actions-setup-mysql@v1 + with: + mysql-version: '8.0' + user: test + password: test + root-password: root + auto-start: true + my-cnf: | + max_allowed_packet=32505856 + max_connections=1000 + + - name: Initial Database + run: mysql -utest -ptest -h127.0.0.1 -e 'CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;' - name: Setup Chromium run: | diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index c2e767c..cde0824 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -15,7 +15,7 @@ jobs: TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "2.0" + PIMCORE_CODECEPTION_VERSION: "3.0" APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" @@ -37,12 +37,12 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [ 8.1 ] - symfony: [ ^5.4 ] - pimcore: [ ~10.6.0 ] + php: [ 8.2 ] + symfony: [ ^6.2 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: ~10.6.0 - template_tag: v10.2.5 + - pimcore: ~11.0.0 + template_tag: v11.0.0 steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index c443f6d..2a4eb84 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -15,7 +15,7 @@ jobs: TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "2.0" + PIMCORE_CODECEPTION_VERSION: "3.0" APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@127.0.0.1:3306/dachcom_bundle_test" @@ -37,12 +37,12 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [ 8.1 ] - symfony: [ ^5.4 ] - pimcore: [ ~10.6.0 ] + php: [ 8.2 ] + symfony: [ ^6.2 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: ~10.6.0 - template_tag: v10.2.5 + - pimcore: ~11.0.0 + template_tag: v11.0.0 steps: - uses: actions/checkout@v2 with: diff --git a/.gitignore b/.gitignore index c4c84f2..c63d370 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,4 @@ php-cgi.core /tests/_output/* /tests/_data/* !/tests/_data/.gitkeep -/tests/_support/_generated/* +/tests/Support/_generated/* diff --git a/LICENSE.md b/LICENSE.md index cb6d83a..a2a1ff1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,5 +1,5 @@ # License -Copyright (C) 2021 DACHCOM.DIGITAL +Copyright (C) 2023 DACHCOM.DIGITAL This software is available under the GNU General Public License version 3 (GPLv3). diff --git a/README.md b/README.md index 5705b81..9fc6d27 100644 --- a/README.md +++ b/README.md @@ -10,31 +10,37 @@ This bundle requires the `spatie/schema-org` package. ### Release Plan -| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | -|---------|----------------------------|----------------------------|--------------|----------------|------------| -| **2.x** | `10.1` - `10.6` | `5.4` | -- | Feature Branch | dev-master | -| **1.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 01.10.2019 | Unsupported | 1.x | +| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | +|---------|----------------------------|----------------------------|--------------|----------------|--------| +| **3x** | `11.0` | `6.2` | -- | Feature Branch | master | +| **2.x** | `10.1` - `10.6` | `5.4` | -- | Bugfixes | 2.x | +| **1.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 01.10.2019 | Unsupported | 1.x | ## Installation ```json "require" : { - "dachcom-digital/schema" : "~2.0.0", + "dachcom-digital/schema" : "~3.0.0", } ``` -- Execute: `$ bin/console pimcore:bundle:enable SchemaBundle` +Add Bundle to `bundles.php`: +```php +return [ + SchemaBundle\SchemaBundle::class => ['all' => true], +]; +``` + - Execute: `$ bin/console pimcore:bundle:install SchemaBundle` ## Upgrading - Execute: `$ bin/console doctrine:migrations:migrate --prefix 'SchemaBundle\Migrations'` -- -## Output +## Output ![image](https://user-images.githubusercontent.com/700119/65961347-a9e22000-e456-11e9-878e-d5df75536846.png) -## -Test your output on https://search.google.com/structured-data/testing-tool +> [!NOTE] +> Test your output on https://search.google.com/structured-data/testing-tool ### Further Information - [Usage](docs/00_Usage.md) diff --git a/UPGRADE.md b/UPGRADE.md index 0a0ec8c..e7d82e2 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,11 +1,11 @@ # Upgrade Notes -## Migrating from Version 1.x to Version 2.0.0 +## Migrating from Version 2.x to Version 3.0.0 ### Global Changes -- PHP8 return type declarations added: you may have to adjust your extensions accordingly -- Bumped `spatie/schema-org` from 2.x to 3.x +- Recommended folder structure by symfony adopted +- Minor code improvements *** -SchemaBundle 1.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-schema/blob/1.x/UPGRADE.md +SchemaBundle 2.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-schema/blob/2.x/UPGRADE.md diff --git a/codeception.dist.yml b/codeception.dist.yml index 882426c..296aad2 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -1,14 +1,15 @@ namespace: DachcomBundle\Test +support_namespace: Support actor: Tester paths: tests: tests - output: tests/_output - data: tests/_data - support: tests/_support envs: tests/_envs + output: tests/_output log: tests/_output/var/logs + data: tests/_data + support: tests/Support +bootstrap: _bootstrap.php settings: - bootstrap: _bootstrap.php memory_limit: -1 colors: true params: diff --git a/composer.json b/composer.json index ff61e0c..9b87365 100755 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "autoload": { "psr-4": { - "SchemaBundle\\": "src/SchemaBundle" + "SchemaBundle\\": "src/" } }, "autoload-dev": { @@ -32,18 +32,18 @@ } }, "require": { - "pimcore/pimcore": "^10.1", + "pimcore/pimcore": "^11.0", "spatie/schema-org": "^3.0" }, "require-dev": { - "codeception/codeception": "^4.1", - "codeception/module-webdriver": "^1.4", - "codeception/module-symfony": "^1.6", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-symfony": "^0.12", + "codeception/codeception": "^5.0", + "codeception/module-symfony": "^3.1", + "codeception/module-webdriver": "^4.0", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-symfony": "^1.0", "symplify/easy-coding-standard": "^9.0" }, "suggest": { - "dachcom-digital/seo": "^2.0" + "dachcom-digital/seo": "^3.0" } } diff --git a/config/services.yaml b/config/services.yaml index 50ca291..ee78c90 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -1,2 +1,2 @@ imports: - - { resource: services/*.yml } \ No newline at end of file + - { resource: services/*.yaml } \ No newline at end of file diff --git a/docs/00_Usage.md b/docs/00_Usage.md index 424789e..bd96dbf 100644 --- a/docs/00_Usage.md +++ b/docs/00_Usage.md @@ -7,7 +7,8 @@ If you're using the [SEO Bundle](https://github.com/dachcom-digital/pimcore-seo) ## SEO Bundle -> Note: this is the recommended way! +> [!NOTE] +> this is the recommended way! This bundle detects automatically if you have installed the SEO Bundle. If so, it will disable the request event listener to keep things straight and prevent strategy mixes! Please read [more about seo bundle configuration](./01_SeoBundleUsage.md) and how to configure this bundle if you're using this bundle in combination with the SEO Bundle. diff --git a/docs/02_StandaloneUsage.md b/docs/02_StandaloneUsage.md index 34b75e4..0168e84 100644 --- a/docs/02_StandaloneUsage.md +++ b/docs/02_StandaloneUsage.md @@ -1,6 +1,7 @@ # Standalone Usage -> **Note!!** This does not work if you have installed the [SEO Bundle](https://github.com/dachcom-digital/pimcore-seo)! +> [!NOTE] +> This does not work if you have installed the [SEO Bundle](https://github.com/dachcom-digital/pimcore-seo)! > Read more about it [here](./00_Usage.md)! *** diff --git a/phpstan.neon b/phpstan.neon index 285c739..162c2aa 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,6 +7,6 @@ parameters: symfony: container_xml_path: %currentWorkingDirectory%/var/cache/test/TestKernelTestDebugContainer.xml constant_hassers: false - excludes_analyse: + excludePaths: # as long we don't install the dependencies :( - - '*SchemaBundle/Seo/Middleware/SchemaGraphAdapter.php' + - src/Seo/Middleware/SchemaGraphAdapter.php diff --git a/tests/Functional.suite.dist.yml b/tests/Functional.suite.dist.yml index 6ad8645..3b28e68 100644 --- a/tests/Functional.suite.dist.yml +++ b/tests/Functional.suite.dist.yml @@ -1,12 +1,12 @@ actor: FunctionalTester modules: enabled: - - \Dachcom\Codeception\Helper\PimcoreCore: + - \Dachcom\Codeception\Support\Helper\PimcoreCore: connect_db: true rebootable_client: true - - \Dachcom\Codeception\Helper\PimcoreBundleCore: + - \Dachcom\Codeception\Support\Helper\PimcoreBundleCore: run_installer: true - - \Dachcom\Codeception\Helper\Browser\PhpBrowser: - depends: \Dachcom\Codeception\Helper\PimcoreCore - - \Dachcom\Codeception\Helper\PimcoreBackend - - \Dachcom\Codeception\Helper\PimcoreUser + - \Dachcom\Codeception\Support\Helper\Browser\PhpBrowser: + depends: \Dachcom\Codeception\Support\Helper\PimcoreCore + - \Dachcom\Codeception\Support\Helper\PimcoreBackend + - \Dachcom\Codeception\Support\Helper\PimcoreUser diff --git a/tests/Support/FunctionalTester.php b/tests/Support/FunctionalTester.php index 6d89997..80598b8 100644 --- a/tests/Support/FunctionalTester.php +++ b/tests/Support/FunctionalTester.php @@ -1,8 +1,8 @@ - Test Page for Test Bundle + {{ pimcore_head_title() }} {{ pimcore_head_meta() }} {{ pimcore_head_link() }} From 9dfd9429fcf8b4048197f22e74879be17d185124 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 11 Aug 2023 08:39:04 +0200 Subject: [PATCH 3/5] tests: enable admin bundle --- tests/_etc/config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/_etc/config.yaml b/tests/_etc/config.yaml index 60407b1..9e4c5cf 100644 --- a/tests/_etc/config.yaml +++ b/tests/_etc/config.yaml @@ -1,4 +1,5 @@ bundles: + - { namespace: \Pimcore\Bundle\AdminBundle\PimcoreAdminBundle, priority: 60 } - { namespace: \Pimcore\Bundle\SeoBundle\PimcoreSeoBundle, priority: 0, execute_installer: true } - { namespace: \SchemaBundle\SchemaBundle } setup_files: From 0092e6f443a090df632ca3f359fb248c2c21fda5 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 11 Aug 2023 09:09:25 +0200 Subject: [PATCH 4/5] improve seo dependency --- .../Compiler/SchemaGeneratorAdapterPass.php | 13 ++++++++++++- src/DependencyInjection/SchemaExtension.php | 9 ++------- src/EventListener/SchemaListener.php | 5 ----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php b/src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php index 24852d6..f0cd14c 100644 --- a/src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php +++ b/src/DependencyInjection/Compiler/SchemaGeneratorAdapterPass.php @@ -2,6 +2,7 @@ namespace SchemaBundle\DependencyInjection\Compiler; +use SchemaBundle\EventListener\SchemaListener; use SchemaBundle\Registry\SchemaGeneratorRegistry; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -12,11 +13,15 @@ final class SchemaGeneratorAdapterPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void { + if ($this->hasSeoBundle($container) && $container->hasDefinition(SchemaListener::class)) { + $container->removeDefinition(SchemaListener::class); + } + foreach ($container->findTaggedServiceIds('schema.generator', true) as $id => $tags) { $definition = $container->getDefinition(SchemaGeneratorRegistry::class); - if ($container->hasParameter('schema.third_party.seo.enabled') && $container->getParameter('schema.third_party.seo.enabled') === true) { + if ($this->hasSeoBundle($container)) { $message = sprintf( 'Cannot register schema generator "%s" because you have installed the SEO Bundle. If you want to add some fragment generator (via twig) use the "schema.fragment_generator" tag. Read more about it here: %s', $id, @@ -38,4 +43,10 @@ public function process(ContainerBuilder $container): void } } } + + private function hasSeoBundle(ContainerBuilder $container): bool + { + /** @phpstan-ignore-next-line */ + return $container->hasParameter('schema.third_party.seo.enabled') && $container->getParameter('schema.third_party.seo.enabled') === true; + } } diff --git a/src/DependencyInjection/SchemaExtension.php b/src/DependencyInjection/SchemaExtension.php index 417ec88..7cee43f 100644 --- a/src/DependencyInjection/SchemaExtension.php +++ b/src/DependencyInjection/SchemaExtension.php @@ -20,20 +20,15 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('services.yaml'); } - public function prepend(ContainerBuilder $container) + public function prepend(ContainerBuilder $container): void { - if ($container->hasExtension('seo')) { + if (!$container->hasExtension('seo')) { return; } $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../../config'])); $container->setParameter('schema.third_party.seo.enabled', true); - $loader->load('third_party/seo.yaml'); - - if ($container->hasDefinition(SchemaListener::class)) { - $container->removeDefinition(SchemaListener::class); - } } } diff --git a/src/EventListener/SchemaListener.php b/src/EventListener/SchemaListener.php index 8434677..945a2c0 100644 --- a/src/EventListener/SchemaListener.php +++ b/src/EventListener/SchemaListener.php @@ -32,15 +32,10 @@ public static function getSubscribedEvents(): array public function onKernelRequest(RequestEvent $event): void { $request = $event->getRequest(); - if ($event->isMainRequest() === false) { return; } - if ($this->pimcoreContextResolver->matchesPimcoreContext($request, PimcoreContextResolver::CONTEXT_ADMIN)) { - return; - } - if (!$this->pimcoreContextResolver->matchesPimcoreContext($request, PimcoreContextResolver::CONTEXT_DEFAULT)) { return; } From 8aaa5aa7f2a23ca12918e18a706e81c77c622748 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 11 Aug 2023 09:13:28 +0200 Subject: [PATCH 5/5] clean-up --- config/pimcore/config.yaml | 2 +- src/DependencyInjection/SchemaExtension.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config/pimcore/config.yaml b/config/pimcore/config.yaml index 43d77c5..5c03812 100644 --- a/config/pimcore/config.yaml +++ b/config/pimcore/config.yaml @@ -1,3 +1,3 @@ doctrine_migrations: migrations_paths: - 'SchemaBundle\Migrations': '@SchemaBundle/Migrations' \ No newline at end of file + 'SchemaBundle\Migrations': '@SchemaBundle/src/Migrations' \ No newline at end of file diff --git a/src/DependencyInjection/SchemaExtension.php b/src/DependencyInjection/SchemaExtension.php index 7cee43f..5ffa057 100644 --- a/src/DependencyInjection/SchemaExtension.php +++ b/src/DependencyInjection/SchemaExtension.php @@ -2,7 +2,6 @@ namespace SchemaBundle\DependencyInjection; -use SchemaBundle\EventListener\SchemaListener; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension;