Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

pimcore 11 support #11

Merged
merged 5 commits into from Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 20 additions & 10 deletions .github/workflows/codeception.yml
Expand Up @@ -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"

Expand All @@ -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:
Expand Down Expand Up @@ -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: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ecs.yml
Expand Up @@ -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"
Expand All @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/php-stan.yml
Expand Up @@ -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"
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -52,4 +52,4 @@ php-cgi.core
/tests/_output/*
/tests/_data/*
!/tests/_data/.gitkeep
/tests/_support/_generated/*
/tests/Support/_generated/*
2 changes: 1 addition & 1 deletion 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).

Expand Down
26 changes: 16 additions & 10 deletions README.md
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions 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
9 changes: 5 additions & 4 deletions 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:
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Expand Up @@ -16,7 +16,7 @@

"autoload": {
"psr-4": {
"SchemaBundle\\": "src/SchemaBundle"
"SchemaBundle\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -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"
}
}
3 changes: 3 additions & 0 deletions config/pimcore/config.yaml
@@ -0,0 +1,3 @@
doctrine_migrations:
migrations_paths:
'SchemaBundle\Migrations': '@SchemaBundle/src/Migrations'
2 changes: 2 additions & 0 deletions config/services.yaml
@@ -0,0 +1,2 @@
imports:
- { resource: services/*.yaml }
File renamed without changes.
3 changes: 2 additions & 1 deletion docs/00_Usage.md
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion 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)!

***
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Expand Up @@ -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
Expand Up @@ -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;
Expand All @@ -12,10 +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->getParameter('schema.flag.schema_listener_removed') === 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,
Expand All @@ -37,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;
}
}
33 changes: 33 additions & 0 deletions src/DependencyInjection/SchemaExtension.php
@@ -0,0 +1,33 @@
<?php

namespace SchemaBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;

class SchemaExtension extends Extension implements PrependExtensionInterface
{
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../../config']));
$loader->load('services.yaml');
}

public function prepend(ContainerBuilder $container): void
{
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');
}
}
Expand Up @@ -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
Expand All @@ -39,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;
}
Expand Down
File renamed without changes.