diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index f806d55..e78f7d6 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.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://test:test@127.0.0.1:3306/dachcom_bundle_test" @@ -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: diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index fb9a68d..c453731 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 ac548a6..26b9c3d 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 0139f99..d4770f3 100644 --- a/.gitignore +++ b/.gitignore @@ -45,11 +45,11 @@ Vagrantfile php-cgi.core .sass-cache -# codeception (only stage *.dist.yml config files) -/codeception.yml -/tests/codeception.yml -/tests/*.suite.yml +# codeception (only stage *.dist.yaml config files) +/codeception.yaml +/tests/codeception.yaml +/tests/*.suite.yaml /tests/_output/* /tests/_data/* !/tests/_data/.gitkeep -/tests/_support/_generated/* \ No newline at end of file +/tests/Support/_generated/* \ No newline at end of file diff --git a/README.md b/README.md index a6483b1..cabb7c7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ This Bundle allows you to synchronise your job offers with various connectors li | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|----------------------------|----------------------------|--------------|----------------|------------| -| **2.x** | `10.5`, `10.6` | `5.4` | -- | Feature Branch | dev-master | +| **3.x** | `11.0` | `6.2` | -- | Feature Branch | dev-master | +| **2.x** | `10.5`, `10.6` | `5.4` | 14.10.2021 | Bugfixes | 2.x | | **1.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 27.04.2020 | Unsupported | 1.x | @@ -20,18 +21,24 @@ This Bundle allows you to synchronise your job offers with various connectors li ```json "require" : { - "dachcom-digital/jobs" : "~2.1.0", + "dachcom-digital/jobs" : "~3.0.0", } ``` -- Execute: `$ bin/console pimcore:bundle:enable JobsBundle` +Add Bundle to `bundles.php`: +```php +return [ + JobsBundle\JobsBundle::class => ['all' => true], +]; +``` + - Execute: `$ bin/console pimcore:bundle:install JobsBundle` ## Upgrading - Execute: `$ bin/console doctrine:migrations:migrate --prefix 'JobsBundle\Migrations'` ## Usage -This Bundle needs some preparation. Please checkout the [Setup](docs/00_Setup.md) guide first. +This Bundle needs some preparation. Please check out the [Setup](docs/00_Setup.md) guide first. ## Further Information - [Setup](docs/00_Setup.md) diff --git a/UPGRADE.md b/UPGRADE.md index 3dc32c0..ab0487f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,14 +1,10 @@ # Upgrade Notes -## 2.1.0 -- [FEATURE] Pimcore 10.5 support only - -## 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 -- [FB Connector](./docs/Connectors/02_FacebookJobs.md): `facebookarchive/php-graph-sdk` has been removed, we're now using the `league/oauth2-facebook` package. +- Recommended folder structure by symfony adopted *** -JobsBundle 1.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-jobs/blob/1.x/UPGRADE.md +JobsBundle 2.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-jobs/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 e465435..66977db 100755 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "autoload": { "psr-4": { - "JobsBundle\\": "src/JobsBundle" + "JobsBundle\\": "src/" } }, "autoload-dev": { @@ -31,20 +31,20 @@ } }, "require": { - "pimcore/pimcore": "^10.5", + "pimcore/pimcore": "^11.0", "doctrine/orm": "^2.7" }, "require-dev": { - "codeception/codeception": "^4.1", - "codeception/module-webdriver": "^1.4", - "codeception/module-symfony": "^1.6", + "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": { "league/oauth2-facebook": "^2.0", - "dachcom-digital/schema": "^2.0", - "dachcom-digital/seo": "^2.0" + "dachcom-digital/schema": "^3.0", + "dachcom-digital/seo": "^3.0" } } diff --git a/src/JobsBundle/Resources/config/doctrine/model/ConnectorContextItem.orm.yml b/config/doctrine/model/ConnectorContextItem.orm.yml similarity index 100% rename from src/JobsBundle/Resources/config/doctrine/model/ConnectorContextItem.orm.yml rename to config/doctrine/model/ConnectorContextItem.orm.yml diff --git a/src/JobsBundle/Resources/config/doctrine/model/ConnectorEngine.orm.yml b/config/doctrine/model/ConnectorEngine.orm.yml similarity index 100% rename from src/JobsBundle/Resources/config/doctrine/model/ConnectorEngine.orm.yml rename to config/doctrine/model/ConnectorEngine.orm.yml diff --git a/src/JobsBundle/Resources/config/doctrine/model/ContextDefinition.orm.yml b/config/doctrine/model/ContextDefinition.orm.yml similarity index 100% rename from src/JobsBundle/Resources/config/doctrine/model/ContextDefinition.orm.yml rename to config/doctrine/model/ContextDefinition.orm.yml diff --git a/src/JobsBundle/Resources/config/doctrine/model/LogEntry.orm.yml b/config/doctrine/model/LogEntry.orm.yml similarity index 100% rename from src/JobsBundle/Resources/config/doctrine/model/LogEntry.orm.yml rename to config/doctrine/model/LogEntry.orm.yml diff --git a/src/JobsBundle/Resources/config/external/seo.yml b/config/external/seo.yaml similarity index 100% rename from src/JobsBundle/Resources/config/external/seo.yml rename to config/external/seo.yaml diff --git a/src/JobsBundle/Resources/install/sql/install.sql b/config/install/sql/install.sql similarity index 100% rename from src/JobsBundle/Resources/install/sql/install.sql rename to config/install/sql/install.sql diff --git a/src/JobsBundle/Resources/install/translations/admin.csv b/config/install/translations/admin.csv similarity index 100% rename from src/JobsBundle/Resources/install/translations/admin.csv rename to config/install/translations/admin.csv diff --git a/src/JobsBundle/Resources/config/pimcore/config.yml b/config/pimcore/config.yaml similarity index 100% rename from src/JobsBundle/Resources/config/pimcore/config.yml rename to config/pimcore/config.yaml diff --git a/src/JobsBundle/Resources/config/pimcore/routing.yml b/config/pimcore/routing.yaml similarity index 100% rename from src/JobsBundle/Resources/config/pimcore/routing.yml rename to config/pimcore/routing.yaml diff --git a/src/JobsBundle/Resources/config/serialization/ConnectorContextItem.yml b/config/serialization/ConnectorContextItem.yaml similarity index 100% rename from src/JobsBundle/Resources/config/serialization/ConnectorContextItem.yml rename to config/serialization/ConnectorContextItem.yaml diff --git a/src/JobsBundle/Resources/config/serialization/ConnectorEngine.yml b/config/serialization/ConnectorEngine.yaml similarity index 100% rename from src/JobsBundle/Resources/config/serialization/ConnectorEngine.yml rename to config/serialization/ConnectorEngine.yaml diff --git a/src/JobsBundle/Resources/config/serialization/ContextDefinition.yml b/config/serialization/ContextDefinition.yaml similarity index 100% rename from src/JobsBundle/Resources/config/serialization/ContextDefinition.yml rename to config/serialization/ContextDefinition.yaml diff --git a/config/services.yaml b/config/services.yaml new file mode 100644 index 0000000..ee78c90 --- /dev/null +++ b/config/services.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: services/*.yaml } \ No newline at end of file diff --git a/src/JobsBundle/Resources/config/services/connector_definition.yml b/config/services/connector_definition.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/connector_definition.yml rename to config/services/connector_definition.yaml diff --git a/src/JobsBundle/Resources/config/services/context.yml b/config/services/context.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/context.yml rename to config/services/context.yaml diff --git a/src/JobsBundle/Resources/config/services/controller.yml b/config/services/controller.yaml similarity index 79% rename from src/JobsBundle/Resources/config/services/controller.yml rename to config/services/controller.yaml index 8a286c8..b871d2d 100644 --- a/src/JobsBundle/Resources/config/services/controller.yml +++ b/config/services/controller.yaml @@ -1,7 +1,7 @@ services: JobsBundle\Controller\: - resource: '../../Controller' + resource: '../../src/Controller' public: true autowire: true autoconfigure: true diff --git a/src/JobsBundle/Resources/config/services/install.yml b/config/services/install.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/install.yml rename to config/services/install.yaml diff --git a/src/JobsBundle/Resources/config/services/maintenance.yml b/config/services/maintenance.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/maintenance.yml rename to config/services/maintenance.yaml diff --git a/src/JobsBundle/Resources/config/services/manager.yml b/config/services/manager.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/manager.yml rename to config/services/manager.yaml diff --git a/src/JobsBundle/Resources/config/services/registry.yml b/config/services/registry.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/registry.yml rename to config/services/registry.yaml diff --git a/src/JobsBundle/Resources/config/services/repository.yml b/config/services/repository.yaml similarity index 100% rename from src/JobsBundle/Resources/config/services/repository.yml rename to config/services/repository.yaml diff --git a/src/JobsBundle/Resources/config/services/services.yml b/config/services/services.yaml similarity index 75% rename from src/JobsBundle/Resources/config/services/services.yml rename to config/services/services.yaml index ad2d72b..fcac81d 100644 --- a/src/JobsBundle/Resources/config/services/services.yml +++ b/config/services/services.yaml @@ -5,6 +5,10 @@ services: autoconfigure: true public: false + JobsBundle\EventListener\Admin\AssetListener: + tags: + - { name: kernel.event_subscriber } + JobsBundle\Connector\ConnectorServiceInterface: '@JobsBundle\Connector\ConnectorService' JobsBundle\Connector\ConnectorService: ~ @@ -19,4 +23,8 @@ services: JobsBundle\Normalizer\EntityNormalizer: tags: - - serializer.normalizer \ No newline at end of file + - serializer.normalizer + + jobs.internal.serializer: + alias: serializer + public: true \ No newline at end of file diff --git a/docs/20_AvailableItemsResolver.md b/docs/20_AvailableItemsResolver.md index 4882e48..d8d84a1 100644 --- a/docs/20_AvailableItemsResolver.md +++ b/docs/20_AvailableItemsResolver.md @@ -4,13 +4,13 @@ After resolving them, they need to return an array with `ResolvedItem`. ## Dynamic Route Request Resolver -| Name | Description -|------|------------| -| `route_name` | Determinates, on which route the job object is available | -| `route_request_identifier` | Which request fragment owns the object identifier (For Example `/?id=123` would be `id` | -| `route_object_identifier` | Determinates, on which object attribute the request identifier should get applied on | -| `is_localized_field` | If true, the object fetcher will look up with `getByLocalizedfields` | -| `must_match_request_locale` | If true, the current request locale must match with the context definition locale | +| Name | Description | +|-----------------------------|-----------------------------------------------------------------------------------------| +| `route_name` | Determinates, on which route the job object is available | +| `route_request_identifier` | Which request fragment owns the object identifier (For Example `/?id=123` would be `id` | +| `route_object_identifier` | Determinates, on which object attribute the request identifier should get applied on | +| `is_localized_field` | If true, the object fetcher will look up with `getByLocalizedfields` | +| `must_match_request_locale` | If true, the current request locale must match with the context definition locale | ### Usage ````yaml diff --git a/phpstan.neon b/phpstan.neon index 26a096b..b24610d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,10 +7,10 @@ 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 :( - - '*JobsBundle/Seo/Extractor/GoogleForJobsExtractor.php' - - '*JobsBundle/Seo/ResourceProcessor/GoogleJobsProcessor.php' + - src/Seo/Extractor/GoogleForJobsExtractor.php + - src/Seo/ResourceProcessor/GoogleJobsProcessor.php ignoreErrors: # 3rd parties - '/.*Spatie\\SchemaOrg\\Graph.*/' diff --git a/src/JobsBundle/Resources/public/css/admin.css b/public/css/admin.css similarity index 100% rename from src/JobsBundle/Resources/public/css/admin.css rename to public/css/admin.css diff --git a/src/JobsBundle/Resources/public/img/jobs_connector_options.svg b/public/img/jobs_connector_options.svg similarity index 100% rename from src/JobsBundle/Resources/public/img/jobs_connector_options.svg rename to public/img/jobs_connector_options.svg diff --git a/src/JobsBundle/Resources/public/img/jobs_icon_white.svg b/public/img/jobs_icon_white.svg similarity index 100% rename from src/JobsBundle/Resources/public/img/jobs_icon_white.svg rename to public/img/jobs_icon_white.svg diff --git a/src/JobsBundle/Resources/public/js/connector/abstractConnector.js b/public/js/connector/abstractConnector.js similarity index 100% rename from src/JobsBundle/Resources/public/js/connector/abstractConnector.js rename to public/js/connector/abstractConnector.js diff --git a/src/JobsBundle/Resources/public/js/connector/facebook.js b/public/js/connector/facebook.js similarity index 100% rename from src/JobsBundle/Resources/public/js/connector/facebook.js rename to public/js/connector/facebook.js diff --git a/src/JobsBundle/Resources/public/js/connector/google.js b/public/js/connector/google.js similarity index 100% rename from src/JobsBundle/Resources/public/js/connector/google.js rename to public/js/connector/google.js diff --git a/src/JobsBundle/Resources/public/js/coreExtension/data/jobConnectorContext.js b/public/js/coreExtension/data/jobConnectorContext.js similarity index 100% rename from src/JobsBundle/Resources/public/js/coreExtension/data/jobConnectorContext.js rename to public/js/coreExtension/data/jobConnectorContext.js diff --git a/src/JobsBundle/Resources/public/js/coreExtension/tags/jobConnectorContext.js b/public/js/coreExtension/tags/jobConnectorContext.js similarity index 99% rename from src/JobsBundle/Resources/public/js/coreExtension/tags/jobConnectorContext.js rename to public/js/coreExtension/tags/jobConnectorContext.js index c218ec9..42ba8bb 100644 --- a/src/JobsBundle/Resources/public/js/coreExtension/tags/jobConnectorContext.js +++ b/public/js/coreExtension/tags/jobConnectorContext.js @@ -266,7 +266,7 @@ pimcore.object.tags.jobConnectorContext = Class.create(pimcore.object.tags.abstr postSaveObject: function () { Ext.Array.each(this.connectorGrids, function (connector) { - connector['grid'].getStore().commitChanges(); + connector.grid.getStore().commitChanges(); }); }, diff --git a/src/JobsBundle/Resources/public/js/plugin.js b/public/js/plugin.js similarity index 91% rename from src/JobsBundle/Resources/public/js/plugin.js rename to public/js/plugin.js index bd14192..1a4bc42 100755 --- a/src/JobsBundle/Resources/public/js/plugin.js +++ b/public/js/plugin.js @@ -1,6 +1,7 @@ document.addEventListener(pimcore.events.pimcoreReady, (e) => { - var user = pimcore.globalmanager.get('user'), + let user = pimcore.globalmanager.get('user'), + jobsMenu, openSettings = function (config) { try { pimcore.globalmanager.get('jobs_bundle_settings').activate(); @@ -23,5 +24,4 @@ document.addEventListener(pimcore.events.pimcoreReady, (e) => { if (layoutToolbar.settingsMenu) { layoutToolbar.settingsMenu.add(jobsMenu); } - }); diff --git a/src/JobsBundle/Resources/public/js/settingsPanel.js b/public/js/settingsPanel.js similarity index 100% rename from src/JobsBundle/Resources/public/js/settingsPanel.js rename to public/js/settingsPanel.js diff --git a/src/JobsBundle/Connector/ConnectorDefinitionInterface.php b/src/Connector/ConnectorDefinitionInterface.php similarity index 100% rename from src/JobsBundle/Connector/ConnectorDefinitionInterface.php rename to src/Connector/ConnectorDefinitionInterface.php diff --git a/src/JobsBundle/Connector/ConnectorEngineConfigurationInterface.php b/src/Connector/ConnectorEngineConfigurationInterface.php similarity index 100% rename from src/JobsBundle/Connector/ConnectorEngineConfigurationInterface.php rename to src/Connector/ConnectorEngineConfigurationInterface.php diff --git a/src/JobsBundle/Connector/ConnectorService.php b/src/Connector/ConnectorService.php similarity index 94% rename from src/JobsBundle/Connector/ConnectorService.php rename to src/Connector/ConnectorService.php index 8c27b60..6e7e872 100644 --- a/src/JobsBundle/Connector/ConnectorService.php +++ b/src/Connector/ConnectorService.php @@ -10,16 +10,12 @@ class ConnectorService implements ConnectorServiceInterface { protected array $connectorCache = []; - protected ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry; - protected ConnectorManagerInterface $connectorManager; public function __construct( - ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry, - ConnectorManagerInterface $connectorManager + protected ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry, + protected ConnectorManagerInterface $connectorManager ) { $this->connectorCache = []; - $this->connectorDefinitionRegistry = $connectorDefinitionRegistry; - $this->connectorManager = $connectorManager; } public function installConnector(string $connectorName): ConnectorEngineInterface diff --git a/src/JobsBundle/Connector/ConnectorServiceInterface.php b/src/Connector/ConnectorServiceInterface.php similarity index 100% rename from src/JobsBundle/Connector/ConnectorServiceInterface.php rename to src/Connector/ConnectorServiceInterface.php diff --git a/src/JobsBundle/Connector/Facebook/ConnectorDefinition.php b/src/Connector/Facebook/ConnectorDefinition.php similarity index 100% rename from src/JobsBundle/Connector/Facebook/ConnectorDefinition.php rename to src/Connector/Facebook/ConnectorDefinition.php diff --git a/src/JobsBundle/Connector/Facebook/EngineConfiguration.php b/src/Connector/Facebook/EngineConfiguration.php similarity index 100% rename from src/JobsBundle/Connector/Facebook/EngineConfiguration.php rename to src/Connector/Facebook/EngineConfiguration.php diff --git a/src/JobsBundle/Connector/Facebook/FeedGenerator.php b/src/Connector/Facebook/FeedGenerator.php similarity index 80% rename from src/JobsBundle/Connector/Facebook/FeedGenerator.php rename to src/Connector/Facebook/FeedGenerator.php index a310cfd..36cff60 100644 --- a/src/JobsBundle/Connector/Facebook/FeedGenerator.php +++ b/src/Connector/Facebook/FeedGenerator.php @@ -10,15 +10,11 @@ class FeedGenerator implements FeedGeneratorInterface { - protected ItemTransformerInterface $itemTransformer; - protected array $items; - protected array $params; - - public function __construct(ItemTransformerInterface $itemTransformer, array $items, array $params) - { - $this->itemTransformer = $itemTransformer; - $this->items = $items; - $this->params = $params; + public function __construct( + protected ItemTransformerInterface $itemTransformer, + protected array $items, + protected array $params + ) { } public function generate(string $outputType): mixed diff --git a/src/JobsBundle/Connector/Facebook/FeedTransformerDefinition.php b/src/Connector/Facebook/FeedTransformerDefinition.php similarity index 100% rename from src/JobsBundle/Connector/Facebook/FeedTransformerDefinition.php rename to src/Connector/Facebook/FeedTransformerDefinition.php diff --git a/src/JobsBundle/Connector/Facebook/ItemTransformerDefinition.php b/src/Connector/Facebook/ItemTransformerDefinition.php similarity index 100% rename from src/JobsBundle/Connector/Facebook/ItemTransformerDefinition.php rename to src/Connector/Facebook/ItemTransformerDefinition.php diff --git a/src/JobsBundle/Connector/Google/ConnectorDefinition.php b/src/Connector/Google/ConnectorDefinition.php similarity index 100% rename from src/JobsBundle/Connector/Google/ConnectorDefinition.php rename to src/Connector/Google/ConnectorDefinition.php diff --git a/src/JobsBundle/Connector/Google/FeedGenerator.php b/src/Connector/Google/FeedGenerator.php similarity index 72% rename from src/JobsBundle/Connector/Google/FeedGenerator.php rename to src/Connector/Google/FeedGenerator.php index dbccde9..cdf2cde 100644 --- a/src/JobsBundle/Connector/Google/FeedGenerator.php +++ b/src/Connector/Google/FeedGenerator.php @@ -8,15 +8,13 @@ class FeedGenerator implements FeedGeneratorInterface { - protected ItemTransformerInterface $itemTransformer; - protected array $items; - protected array $params; - public function __construct(ItemTransformerInterface $itemTransformer, array $items, array $params) + public function __construct( + protected ItemTransformerInterface $itemTransformer, + protected array $items, + protected array $params + ) { - $this->itemTransformer = $itemTransformer; - $this->items = $items; - $this->params = $params; } public function generate(string $outputType): mixed diff --git a/src/JobsBundle/Connector/Google/ItemTransformerDefinition.php b/src/Connector/Google/ItemTransformerDefinition.php similarity index 100% rename from src/JobsBundle/Connector/Google/ItemTransformerDefinition.php rename to src/Connector/Google/ItemTransformerDefinition.php diff --git a/src/JobsBundle/Context/ContextService.php b/src/Context/ContextService.php similarity index 85% rename from src/JobsBundle/Context/ContextService.php rename to src/Context/ContextService.php index 9fe6ff0..a5291fc 100644 --- a/src/JobsBundle/Context/ContextService.php +++ b/src/Context/ContextService.php @@ -8,11 +8,8 @@ class ContextService implements ContextServiceInterface { - protected ContextItemsResolverRegistryInterface $contextItemsResolverRegistry; - - public function __construct(ContextItemsResolverRegistryInterface $contextItemsResolverRegistry) + public function __construct(protected ContextItemsResolverRegistryInterface $contextItemsResolverRegistry) { - $this->contextItemsResolverRegistry = $contextItemsResolverRegistry; } public function resolveContextItems(string $contextName, ConnectorDefinitionInterface $connectorDefinition, array $contextParameter): array diff --git a/src/JobsBundle/Context/ContextServiceInterface.php b/src/Context/ContextServiceInterface.php similarity index 100% rename from src/JobsBundle/Context/ContextServiceInterface.php rename to src/Context/ContextServiceInterface.php diff --git a/src/JobsBundle/Context/ResolvedItem.php b/src/Context/ResolvedItem.php similarity index 62% rename from src/JobsBundle/Context/ResolvedItem.php rename to src/Context/ResolvedItem.php index 71d7b00..66ada7c 100644 --- a/src/JobsBundle/Context/ResolvedItem.php +++ b/src/Context/ResolvedItem.php @@ -7,15 +7,12 @@ class ResolvedItem implements ResolvedItemInterface { - protected ?ConnectorContextItemInterface $contextItem; - protected ?Concrete $subject; - protected array $resolvedParams; - - public function __construct(?ConnectorContextItemInterface $contextItem, ?Concrete $subject, array $resolvedParams = []) + public function __construct( + protected ?ConnectorContextItemInterface $contextItem, + protected ?Concrete $subject, + protected array $resolvedParams = [] + ) { - $this->contextItem = $contextItem; - $this->subject = $subject; - $this->resolvedParams = $resolvedParams; } public function getContextItem(): ?ConnectorContextItemInterface diff --git a/src/JobsBundle/Context/ResolvedItemInterface.php b/src/Context/ResolvedItemInterface.php similarity index 100% rename from src/JobsBundle/Context/ResolvedItemInterface.php rename to src/Context/ResolvedItemInterface.php diff --git a/src/JobsBundle/Context/Resolver/ContextItemsResolverInterface.php b/src/Context/Resolver/ContextItemsResolverInterface.php similarity index 100% rename from src/JobsBundle/Context/Resolver/ContextItemsResolverInterface.php rename to src/Context/Resolver/ContextItemsResolverInterface.php diff --git a/src/JobsBundle/Context/Resolver/DynamicRouteRequestResolver.php b/src/Context/Resolver/DynamicRouteRequestResolver.php similarity index 100% rename from src/JobsBundle/Context/Resolver/DynamicRouteRequestResolver.php rename to src/Context/Resolver/DynamicRouteRequestResolver.php diff --git a/src/JobsBundle/Context/Resolver/FeedResolver.php b/src/Context/Resolver/FeedResolver.php similarity index 100% rename from src/JobsBundle/Context/Resolver/FeedResolver.php rename to src/Context/Resolver/FeedResolver.php diff --git a/src/JobsBundle/Context/Resolver/PimcoreObjectResolver.php b/src/Context/Resolver/PimcoreObjectResolver.php similarity index 100% rename from src/JobsBundle/Context/Resolver/PimcoreObjectResolver.php rename to src/Context/Resolver/PimcoreObjectResolver.php diff --git a/src/JobsBundle/Context/Resolver/SeoQueueResolver.php b/src/Context/Resolver/SeoQueueResolver.php similarity index 100% rename from src/JobsBundle/Context/Resolver/SeoQueueResolver.php rename to src/Context/Resolver/SeoQueueResolver.php diff --git a/src/JobsBundle/Controller/Admin/LogController.php b/src/Controller/Admin/LogController.php similarity index 93% rename from src/JobsBundle/Controller/Admin/LogController.php rename to src/Controller/Admin/LogController.php index 0372bea..eaa2e8e 100644 --- a/src/JobsBundle/Controller/Admin/LogController.php +++ b/src/Controller/Admin/LogController.php @@ -4,11 +4,11 @@ use JobsBundle\Manager\LogManagerInterface; use JobsBundle\Model\LogEntryInterface; -use Pimcore\Bundle\AdminBundle\HttpFoundation\JsonResponse; +use Pimcore\Bundle\AdminBundle\Controller\AdminAbstractController; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Pimcore\Bundle\AdminBundle\Controller\AdminController; -class LogController extends AdminController +class LogController extends AdminAbstractController { protected LogManagerInterface $logManager; diff --git a/src/JobsBundle/Controller/Admin/SettingsController.php b/src/Controller/Admin/SettingsController.php similarity index 90% rename from src/JobsBundle/Controller/Admin/SettingsController.php rename to src/Controller/Admin/SettingsController.php index 10e35ff..3703ed8 100644 --- a/src/JobsBundle/Controller/Admin/SettingsController.php +++ b/src/Controller/Admin/SettingsController.php @@ -9,31 +9,20 @@ use JobsBundle\Manager\ContextDefinitionManagerInterface; use JobsBundle\Service\EnvironmentServiceInterface; use JobsBundle\Tool\FeedIdHelper; -use Pimcore\Bundle\AdminBundle\HttpFoundation\JsonResponse; +use Pimcore\Bundle\AdminBundle\Controller\AdminAbstractController; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use JobsBundle\Registry\ConnectorDefinitionRegistryInterface; -use Pimcore\Bundle\AdminBundle\Controller\AdminController; -class SettingsController extends AdminController +class SettingsController extends AdminAbstractController { - protected EnvironmentServiceInterface $environmentService; - protected ConnectorManagerInterface $connectorManager; - protected ContextDefinitionManagerInterface $contextDefinitionManager; - protected ConnectorDefinitionRegistryInterface $connectorRegistry; - protected ConnectorServiceInterface $connectorService; - public function __construct( - EnvironmentServiceInterface $environmentService, - ConnectorManagerInterface $connectorManager, - ContextDefinitionManagerInterface $contextDefinitionManager, - ConnectorDefinitionRegistryInterface $connectorRegistry, - ConnectorServiceInterface $connectorService + protected EnvironmentServiceInterface $environmentService, + protected ConnectorManagerInterface $connectorManager, + protected ContextDefinitionManagerInterface $contextDefinitionManager, + protected ConnectorDefinitionRegistryInterface $connectorRegistry, + protected ConnectorServiceInterface $connectorService ) { - $this->environmentService = $environmentService; - $this->connectorManager = $connectorManager; - $this->contextDefinitionManager = $contextDefinitionManager; - $this->connectorRegistry = $connectorRegistry; - $this->connectorService = $connectorService; } /** diff --git a/src/JobsBundle/Controller/FacebookController.php b/src/Controller/FacebookController.php similarity index 97% rename from src/JobsBundle/Controller/FacebookController.php rename to src/Controller/FacebookController.php index e11d511..028cd01 100644 --- a/src/JobsBundle/Controller/FacebookController.php +++ b/src/Controller/FacebookController.php @@ -20,15 +20,10 @@ class FacebookController extends FrontendController { - protected EnvironmentServiceInterface $environmentService; - protected ConnectorServiceInterface $connectorService; - public function __construct( - EnvironmentServiceInterface $environmentService, - ConnectorServiceInterface $connectorService + protected EnvironmentServiceInterface $environmentService, + protected ConnectorServiceInterface $connectorService ) { - $this->environmentService = $environmentService; - $this->connectorService = $connectorService; } public function connectAction(Request $request, string $token): RedirectResponse diff --git a/src/JobsBundle/Controller/ProviderController.php b/src/Controller/ProviderController.php similarity index 85% rename from src/JobsBundle/Controller/ProviderController.php rename to src/Controller/ProviderController.php index 0dadd44..dd95f4d 100644 --- a/src/JobsBundle/Controller/ProviderController.php +++ b/src/Controller/ProviderController.php @@ -11,15 +11,10 @@ class ProviderController extends FrontendController { - protected ContextServiceInterface $contextService; - protected ConnectorServiceInterface $connectorService; - public function __construct( - ContextServiceInterface $contextService, - ConnectorServiceInterface $connectorService + protected ContextServiceInterface $contextService, + protected ConnectorServiceInterface $connectorService ) { - $this->contextService = $contextService; - $this->connectorService = $connectorService; } /** diff --git a/src/JobsBundle/CoreExtension/JobConnectorContext.php b/src/CoreExtension/JobConnectorContext.php similarity index 71% rename from src/JobsBundle/CoreExtension/JobConnectorContext.php rename to src/CoreExtension/JobConnectorContext.php index e933866..80e5e61 100644 --- a/src/JobsBundle/CoreExtension/JobConnectorContext.php +++ b/src/CoreExtension/JobConnectorContext.php @@ -13,8 +13,11 @@ use JobsBundle\Model\ConnectorEngineInterface; use JobsBundle\Model\ContextDefinitionInterface; use Pimcore\Model\DataObject\ClassDefinition\Data; -use Pimcore\Model\DataObject\ClassDefinition\Data\CustomDataCopyInterface; use Pimcore\Model\DataObject\Concrete; +use Pimcore\Model\DataObject\Fieldcollection; +use Pimcore\Model\DataObject\Localizedfield; +use Pimcore\Model\DataObject\Objectbrick; +use Pimcore\Model\DataObject\Objectbrick\Data\AbstractData; use Pimcore\Model\Element\ValidationException; use Symfony\Component\Serializer\Serializer; @@ -22,15 +25,10 @@ class JobConnectorContext extends Data implements Data\CustomResourcePersistingInterface, Data\CustomVersionMarshalInterface, Data\CustomRecyclingMarshalInterface, - Data\CustomDataCopyInterface + Data\CustomDataCopyInterface, + Data\PreGetDataInterface, + Data\PreSetDataInterface { - /** - * Static type of this element. - * - * @var string - */ - public $fieldtype = 'jobConnectorContext'; - private function getConnectorContextManager(): ConnectorContextManagerInterface { return \Pimcore::getContainer()->get(ConnectorContextManager::class); @@ -48,69 +46,44 @@ private function getLogManager(): LogManagerInterface protected function getSerializer(): Serializer { - return \Pimcore::getContainer()->get('serializer'); + return \Pimcore::getContainer()->get('jobs.internal.serializer'); } - /** - * @param mixed $object - * - * @return null|ConnectorContextItemInterface[] - */ - public function preGetData($object) + public function preGetData(mixed $container, array $params = []): mixed { - if (!$object instanceof Concrete) { + if (!$container instanceof Concrete) { return null; } - $data = $object->getObjectVar($this->getName()); + $data = $container->getObjectVar($this->getName()); - if (!$object->isLazyKeyLoaded($this->getName())) { - $data = $this->load($object, ['force' => true]); + if (!$container->isLazyKeyLoaded($this->getName())) { + $data = $this->load($container, ['force' => true]); $setter = 'set' . ucfirst($this->getName()); - if (method_exists($object, $setter)) { - $object->$setter($data); + if (method_exists($container, $setter)) { + $container->$setter($data); } } return $data; } - public function preSetData($object, $data, $params = []) + public function preSetData(mixed $container, mixed $data, array $params = []): mixed { - $this->markAsLoaded($object); + $this->markAsLoaded($container); return $data; } - /** - * {@inheritdoc} - */ - public function isDiffChangeAllowed($object, $params = []) - { - return false; - } - - /** - * {@inheritdoc} - */ - public function getDiffDataForEditMode($data, $object = null, $params = []) - { - return []; - } - - public function getDataFromResource($data, $object = null, $params = []) + public function getDiffDataForEditMode(mixed $data, Concrete $object = null, array $params = []): ?array { return []; } /** - * @param mixed $data - * @param null|Concrete $object - * @param array $params - * * @return ConnectorContextItemInterface[] */ - public function getDataForEditmode($data, $object = null, $params = []) + public function getDataForEditmode(mixed $data, Concrete $object = null, array $params = []): mixed { if (!$object instanceof Concrete) { return $data; @@ -124,15 +97,9 @@ public function getDataForEditmode($data, $object = null, $params = []) } /** - * @param mixed $data - * @param null|Concrete $object - * @param array $params - * - * @return null|array - * * @throws \Exception */ - public function getDataFromEditmode($data, $object = null, $params = []) + public function getDataFromEditmode(mixed $data, Concrete $object = null, array $params = []): mixed { if (!is_array($data)) { return null; @@ -170,7 +137,7 @@ public function getDataFromEditmode($data, $object = null, $params = []) continue; } - $item = array_reduce($existingConnectorContextItems, function ($result, ConnectorContextItemInterface $item) use ($contextConfig) { + $item = array_reduce($existingConnectorContextItems, static function ($result, ConnectorContextItemInterface $item) use ($contextConfig) { return $item->getContextDefinition()->getId() === $contextConfig['id'] ? $item : $result; }); @@ -188,11 +155,7 @@ public function getDataFromEditmode($data, $object = null, $params = []) return $items; } - /** - * @param mixed $object - * @param array $params - */ - public function save($object, $params = []) + public function save(Localizedfield|\Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData|AbstractData|Concrete $object, array $params = []): void { if (!method_exists($object, 'getJobConnectorContext')) { return; @@ -229,10 +192,7 @@ public function save($object, $params = []) } } - /** - * {@inheritdoc} - */ - public function load($object, $params = []) + public function load(Localizedfield|\Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData|AbstractData|Concrete $object, array $params = []): mixed { if (isset($params['force']) && $params['force']) { return $this->getConnectorContextManager()->getForObject($object->getId()); @@ -241,10 +201,7 @@ public function load($object, $params = []) return null; } - /** - * {@inheritdoc} - */ - public function delete($object, $params = []) + public function delete(Localizedfield|\Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData|AbstractData|Concrete $object, array $params = []): void { $allConnectorContextItems = $this->load($object, ['force' => true]); if (!is_array($allConnectorContextItems)) { @@ -258,27 +215,7 @@ public function delete($object, $params = []) $this->getLogManager()->deleteForObject($object->getId()); } - /** - * @param mixed $data - * @param null $relatedObject - * @param mixed $params - * @param null $idMapper - * - * @return ConnectorContextItemInterface[] - * - * @throws \Exception - */ - public function getFromWebserviceImport($data, $relatedObject = null, $params = [], $idMapper = null) - { - return $this->getDataFromEditmode($this->arrayCastRecursive($data), $relatedObject, $params); - } - - /** - * @param mixed $array - * - * @return array - */ - protected function arrayCastRecursive($array) + protected function arrayCastRecursive(mixed $array): array { if (is_array($array)) { foreach ($array as $key => $value) { @@ -310,10 +247,7 @@ protected function markAsLoaded($object) $object->markLazyKeyAsLoaded($this->getName()); } - /** - * {@inheritdoc} - */ - public function marshalVersion($object, $data) + public function marshalVersion(Concrete $object, mixed $data): mixed { if (!is_array($data)) { return []; @@ -322,10 +256,7 @@ public function marshalVersion($object, $data) return $this->getSerializer()->normalize($data, 'array', ['groups' => ['Version']]); } - /** - * {@inheritdoc} - */ - public function unmarshalVersion($object, $data) + public function unmarshalVersion(Concrete $object, mixed $data): mixed { if (!is_array($data)) { return []; @@ -336,36 +267,17 @@ public function unmarshalVersion($object, $data) ); } - /** - * {@inheritdoc} - */ - public function marshalRecycleData($object, $data) + public function marshalRecycleData(Concrete $object, mixed $data): mixed { - if (!is_array($data)) { - return []; - } - - return $this->getSerializer()->normalize($data, 'array', ['groups' => ['Version']]); + return $this->marshalVersion($object, $data); } - /** - * {@inheritdoc} - */ - public function unmarshalRecycleData($object, $data) + public function unmarshalRecycleData(Concrete $object, mixed $data): mixed { - if (!is_array($data)) { - return []; - } - - return array_filter( - $this->getSerializer()->denormalize($data, sprintf('%s[]', ConnectorContextItem::class)) - ); + return $this->unmarshalVersion($object, $data); } - /** - * {@inheritdoc} - */ - public function createDataCopy(Concrete $object, $data) + public function createDataCopy(Concrete $object, mixed $data): mixed { if (!is_array($data)) { return []; @@ -388,10 +300,7 @@ public function createDataCopy(Concrete $object, $data) return $newData; } - /** - * {@inheritdoc} - */ - public function getVersionPreview($data, $object = null, $params = []) + public function getVersionPreview(mixed $data, Concrete $object = null, array $params = []): string { $preview = []; if (!is_array($data)) { @@ -408,10 +317,7 @@ public function getVersionPreview($data, $object = null, $params = []) return implode(', ', $preview); } - /** - * {@inheritdoc} - */ - public function getDataForSearchIndex($object, $params = []) + public function getDataForSearchIndex(Localizedfield|Fieldcollection\Data\AbstractData|Objectbrick\Data\AbstractData|Concrete $object, array $params = []): string { return ''; } @@ -423,7 +329,7 @@ public function getParameterTypeDeclaration(): ?string public function getReturnTypeDeclaration(): ?string { - return '?array'; + return $this->getParameterTypeDeclaration(); } public function getPhpdocInputType(): ?string @@ -435,4 +341,9 @@ public function getPhpdocReturnType(): ?string { return '\\' . ConnectorContextItemInterface::class . '[]'; } + + public function getFieldType(): string + { + return 'jobConnectorContext'; + } } diff --git a/src/JobsBundle/DependencyInjection/Compiler/ConnectorDefinitionPass.php b/src/DependencyInjection/Compiler/ConnectorDefinitionPass.php similarity index 100% rename from src/JobsBundle/DependencyInjection/Compiler/ConnectorDefinitionPass.php rename to src/DependencyInjection/Compiler/ConnectorDefinitionPass.php diff --git a/src/JobsBundle/DependencyInjection/Compiler/ContextItemsResolverPass.php b/src/DependencyInjection/Compiler/ContextItemsResolverPass.php similarity index 100% rename from src/JobsBundle/DependencyInjection/Compiler/ContextItemsResolverPass.php rename to src/DependencyInjection/Compiler/ContextItemsResolverPass.php diff --git a/src/JobsBundle/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php similarity index 100% rename from src/JobsBundle/DependencyInjection/Configuration.php rename to src/DependencyInjection/Configuration.php diff --git a/src/JobsBundle/DependencyInjection/JobsExtension.php b/src/DependencyInjection/JobsExtension.php similarity index 97% rename from src/JobsBundle/DependencyInjection/JobsExtension.php rename to src/DependencyInjection/JobsExtension.php index d17b15b..5619bc9 100644 --- a/src/JobsBundle/DependencyInjection/JobsExtension.php +++ b/src/DependencyInjection/JobsExtension.php @@ -15,8 +15,8 @@ public function load(array $configs, ContainerBuilder $container): void $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../Resources/config'])); - $loader->load('services.yml'); + $loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../../config'])); + $loader->load('services.yaml'); $persistenceConfig = $config['persistence']['doctrine']; $entityManagerName = $persistenceConfig['entity_manager']; @@ -76,7 +76,7 @@ protected function checkGoogleConnectorDependencies(ContainerBuilder $container, /** @phpstan-ignore-next-line */ if (array_key_exists('SeoBundle', $bundles) && array_key_exists('SchemaBundle', $bundles)) { $container->setParameter('jobs.connector.google.dependencies_installed', true); - $loader->load('external/seo.yml'); + $loader->load('external/seo.yaml'); } } diff --git a/src/EventListener/Admin/AssetListener.php b/src/EventListener/Admin/AssetListener.php new file mode 100644 index 0000000..6c08bec --- /dev/null +++ b/src/EventListener/Admin/AssetListener.php @@ -0,0 +1,38 @@ + 'addCssFiles', + BundleManagerEvents::JS_PATHS => 'addJsFiles', + ]; + } + + public function addCssFiles(PathsEvent $event): void + { + $event->addPaths([ + '/bundles/jobs/css/admin.css' + ]); + } + + public function addJsFiles(PathsEvent $event): void + { + $event->addPaths([ + '/bundles/jobs/js/plugin.js', + '/bundles/jobs/js/settingsPanel.js', + '/bundles/jobs/js/connector/abstractConnector.js', + '/bundles/jobs/js/connector/google.js', + '/bundles/jobs/js/connector/facebook.js', + '/bundles/jobs/js/coreExtension/data/jobConnectorContext.js', + '/bundles/jobs/js/coreExtension/tags/jobConnectorContext.js', + ]); + } +} diff --git a/src/JobsBundle/EventListener/Maintenance/CleanUpLogsTask.php b/src/EventListener/Maintenance/CleanUpLogsTask.php similarity index 52% rename from src/JobsBundle/EventListener/Maintenance/CleanUpLogsTask.php rename to src/EventListener/Maintenance/CleanUpLogsTask.php index 4d3e0cf..ab12bac 100644 --- a/src/JobsBundle/EventListener/Maintenance/CleanUpLogsTask.php +++ b/src/EventListener/Maintenance/CleanUpLogsTask.php @@ -7,13 +7,10 @@ class CleanUpLogsTask implements TaskInterface { - protected int $logExpirationDays; - protected LogRepositoryInterface $logRepository; - - public function __construct(int $logExpirationDays, LogRepositoryInterface $logRepository) - { - $this->logExpirationDays = $logExpirationDays; - $this->logRepository = $logRepository; + public function __construct( + protected int $logExpirationDays, + protected LogRepositoryInterface $logRepository + ) { } public function execute(): void diff --git a/src/JobsBundle/Feed/FeedGeneratorInterface.php b/src/Feed/FeedGeneratorInterface.php similarity index 100% rename from src/JobsBundle/Feed/FeedGeneratorInterface.php rename to src/Feed/FeedGeneratorInterface.php diff --git a/src/JobsBundle/JobsBundle.php b/src/JobsBundle.php similarity index 69% rename from src/JobsBundle/JobsBundle.php rename to src/JobsBundle.php index 8ea4d7b..7356321 100644 --- a/src/JobsBundle/JobsBundle.php +++ b/src/JobsBundle.php @@ -29,29 +29,14 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new ContextItemsResolverPass()); } - protected function getComposerPackageName(): string - { - return self::PACKAGE_NAME; - } - - public function getCssPaths(): array + public function getPath(): string { - return [ - '/bundles/jobs/css/admin.css' - ]; + return \dirname(__DIR__); } - public function getJsPaths(): array + protected function getComposerPackageName(): string { - return [ - '/bundles/jobs/js/plugin.js', - '/bundles/jobs/js/settingsPanel.js', - '/bundles/jobs/js/connector/abstractConnector.js', - '/bundles/jobs/js/connector/google.js', - '/bundles/jobs/js/connector/facebook.js', - '/bundles/jobs/js/coreExtension/data/jobConnectorContext.js', - '/bundles/jobs/js/coreExtension/tags/jobConnectorContext.js', - ]; + return self::PACKAGE_NAME; } protected function configureDoctrineExtension(ContainerBuilder $container): void @@ -72,10 +57,6 @@ protected function getNamespaceName(): string protected function getNameSpacePath(): string { - return sprintf( - '%s/Resources/config/doctrine/%s', - $this->getPath(), - 'model' - ); + return realpath(sprintf('%s/config/doctrine/%s', $this->getPath(), 'model')); } } diff --git a/src/JobsBundle/Resources/config/services.yml b/src/JobsBundle/Resources/config/services.yml deleted file mode 100644 index 50ca291..0000000 --- a/src/JobsBundle/Resources/config/services.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: services/*.yml } \ No newline at end of file diff --git a/src/JobsBundle/Manager/ConnectorContextManager.php b/src/Manager/ConnectorContextManager.php similarity index 84% rename from src/JobsBundle/Manager/ConnectorContextManager.php rename to src/Manager/ConnectorContextManager.php index 7402d22..e570774 100644 --- a/src/JobsBundle/Manager/ConnectorContextManager.php +++ b/src/Manager/ConnectorContextManager.php @@ -10,21 +10,12 @@ class ConnectorContextManager implements ConnectorContextManagerInterface { - protected ConnectorManagerInterface $connectorManager; - protected ContextDefinitionManagerInterface $contextDefinitionManager; - protected ConnectorContextItemRepositoryInterface $connectorContextItemRepository; - protected EntityManagerInterface $entityManager; - public function __construct( - ConnectorManagerInterface $connectorManager, - ContextDefinitionManagerInterface $contextDefinitionManager, - ConnectorContextItemRepositoryInterface $connectorContextItemRepository, - EntityManagerInterface $entityManager + protected ConnectorManagerInterface $connectorManager, + protected ContextDefinitionManagerInterface $contextDefinitionManager, + protected ConnectorContextItemRepositoryInterface $connectorContextItemRepository, + protected EntityManagerInterface $entityManager ) { - $this->connectorManager = $connectorManager; - $this->contextDefinitionManager = $contextDefinitionManager; - $this->connectorContextItemRepository = $connectorContextItemRepository; - $this->entityManager = $entityManager; } public function getForObject(int $objectId): array diff --git a/src/JobsBundle/Manager/ConnectorContextManagerInterface.php b/src/Manager/ConnectorContextManagerInterface.php similarity index 100% rename from src/JobsBundle/Manager/ConnectorContextManagerInterface.php rename to src/Manager/ConnectorContextManagerInterface.php diff --git a/src/JobsBundle/Manager/ConnectorManager.php b/src/Manager/ConnectorManager.php similarity index 84% rename from src/JobsBundle/Manager/ConnectorManager.php rename to src/Manager/ConnectorManager.php index 5232d3b..2717f2a 100644 --- a/src/JobsBundle/Manager/ConnectorManager.php +++ b/src/Manager/ConnectorManager.php @@ -12,21 +12,12 @@ class ConnectorManager implements ConnectorManagerInterface { - protected array $availableConnectors; - protected ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry; - protected ConnectorEngineRepositoryInterface $connectorEngineRepository; - protected EntityManagerInterface $entityManager; - public function __construct( - array $availableConnectors, - ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry, - ConnectorEngineRepositoryInterface $connectorEngineRepository, - EntityManagerInterface $entityManager + protected array $availableConnectors, + protected ConnectorDefinitionRegistryInterface $connectorDefinitionRegistry, + protected ConnectorEngineRepositoryInterface $connectorEngineRepository, + protected EntityManagerInterface $entityManager ) { - $this->availableConnectors = $availableConnectors; - $this->connectorDefinitionRegistry = $connectorDefinitionRegistry; - $this->connectorEngineRepository = $connectorEngineRepository; - $this->entityManager = $entityManager; } public function connectorDefinitionIsEnabled(string $connectorDefinitionName): bool diff --git a/src/JobsBundle/Manager/ConnectorManagerInterface.php b/src/Manager/ConnectorManagerInterface.php similarity index 100% rename from src/JobsBundle/Manager/ConnectorManagerInterface.php rename to src/Manager/ConnectorManagerInterface.php diff --git a/src/JobsBundle/Manager/ContextDefinitionManager.php b/src/Manager/ContextDefinitionManager.php similarity index 79% rename from src/JobsBundle/Manager/ContextDefinitionManager.php rename to src/Manager/ContextDefinitionManager.php index d581100..a54841f 100644 --- a/src/JobsBundle/Manager/ContextDefinitionManager.php +++ b/src/Manager/ContextDefinitionManager.php @@ -9,15 +9,10 @@ class ContextDefinitionManager implements ContextDefinitionManagerInterface { - protected ContextDefinitionRepositoryInterface $contextDefinitionRepository; - protected EntityManagerInterface $entityManager; - public function __construct( - ContextDefinitionRepositoryInterface $contextDefinitionRepository, - EntityManagerInterface $entityManager + protected ContextDefinitionRepositoryInterface $contextDefinitionRepository, + protected EntityManagerInterface $entityManager ) { - $this->contextDefinitionRepository = $contextDefinitionRepository; - $this->entityManager = $entityManager; } public function createNew(string $host, string $locale): ContextDefinitionInterface diff --git a/src/JobsBundle/Manager/ContextDefinitionManagerInterface.php b/src/Manager/ContextDefinitionManagerInterface.php similarity index 100% rename from src/JobsBundle/Manager/ContextDefinitionManagerInterface.php rename to src/Manager/ContextDefinitionManagerInterface.php diff --git a/src/JobsBundle/Manager/LogManager.php b/src/Manager/LogManager.php similarity index 83% rename from src/JobsBundle/Manager/LogManager.php rename to src/Manager/LogManager.php index 84be681..d47a3b4 100644 --- a/src/JobsBundle/Manager/LogManager.php +++ b/src/Manager/LogManager.php @@ -10,18 +10,11 @@ class LogManager implements LogManagerInterface { - protected LogRepositoryInterface $logRepository; - protected ConnectorManagerInterface $connectorManager; - protected EntityManagerInterface $entityManager; - public function __construct( - LogRepositoryInterface $logRepository, - ConnectorManagerInterface $connectorManager, - EntityManagerInterface $entityManager + protected LogRepositoryInterface $logRepository, + protected ConnectorManagerInterface $connectorManager, + protected EntityManagerInterface $entityManager ) { - $this->logRepository = $logRepository; - $this->connectorManager = $connectorManager; - $this->entityManager = $entityManager; } public function getForObject(int $objectId): Paginator diff --git a/src/JobsBundle/Manager/LogManagerInterface.php b/src/Manager/LogManagerInterface.php similarity index 100% rename from src/JobsBundle/Manager/LogManagerInterface.php rename to src/Manager/LogManagerInterface.php diff --git a/src/JobsBundle/Migrations/.gitkeep b/src/Migrations/.gitkeep similarity index 100% rename from src/JobsBundle/Migrations/.gitkeep rename to src/Migrations/.gitkeep diff --git a/src/JobsBundle/Model/ConnectorContextItem.php b/src/Model/ConnectorContextItem.php similarity index 100% rename from src/JobsBundle/Model/ConnectorContextItem.php rename to src/Model/ConnectorContextItem.php diff --git a/src/JobsBundle/Model/ConnectorContextItemInterface.php b/src/Model/ConnectorContextItemInterface.php similarity index 100% rename from src/JobsBundle/Model/ConnectorContextItemInterface.php rename to src/Model/ConnectorContextItemInterface.php diff --git a/src/JobsBundle/Model/ConnectorEngine.php b/src/Model/ConnectorEngine.php similarity index 100% rename from src/JobsBundle/Model/ConnectorEngine.php rename to src/Model/ConnectorEngine.php diff --git a/src/JobsBundle/Model/ConnectorEngineInterface.php b/src/Model/ConnectorEngineInterface.php similarity index 100% rename from src/JobsBundle/Model/ConnectorEngineInterface.php rename to src/Model/ConnectorEngineInterface.php diff --git a/src/JobsBundle/Model/ContextDefinition.php b/src/Model/ContextDefinition.php similarity index 100% rename from src/JobsBundle/Model/ContextDefinition.php rename to src/Model/ContextDefinition.php diff --git a/src/JobsBundle/Model/ContextDefinitionInterface.php b/src/Model/ContextDefinitionInterface.php similarity index 100% rename from src/JobsBundle/Model/ContextDefinitionInterface.php rename to src/Model/ContextDefinitionInterface.php diff --git a/src/JobsBundle/Model/LogEntry.php b/src/Model/LogEntry.php similarity index 100% rename from src/JobsBundle/Model/LogEntry.php rename to src/Model/LogEntry.php diff --git a/src/JobsBundle/Model/LogEntryInterface.php b/src/Model/LogEntryInterface.php similarity index 100% rename from src/JobsBundle/Model/LogEntryInterface.php rename to src/Model/LogEntryInterface.php diff --git a/src/JobsBundle/Normalizer/EntityNormalizer.php b/src/Normalizer/EntityNormalizer.php similarity index 90% rename from src/JobsBundle/Normalizer/EntityNormalizer.php rename to src/Normalizer/EntityNormalizer.php index 7de3a5a..eb9f469 100644 --- a/src/JobsBundle/Normalizer/EntityNormalizer.php +++ b/src/Normalizer/EntityNormalizer.php @@ -10,11 +10,8 @@ class EntityNormalizer implements DenormalizerInterface { - protected EntityManagerInterface $entityManager; - - public function __construct(EntityManagerInterface $entityManager) + public function __construct(protected EntityManagerInterface $entityManager) { - $this->entityManager = $entityManager; } public function supportsDenormalization($data, $type, $format = null): bool @@ -50,4 +47,4 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a return $connectorContextItem; } -} \ No newline at end of file +} diff --git a/src/JobsBundle/Registry/ConnectorDefinitionRegistry.php b/src/Registry/ConnectorDefinitionRegistry.php similarity index 100% rename from src/JobsBundle/Registry/ConnectorDefinitionRegistry.php rename to src/Registry/ConnectorDefinitionRegistry.php diff --git a/src/JobsBundle/Registry/ConnectorDefinitionRegistryInterface.php b/src/Registry/ConnectorDefinitionRegistryInterface.php similarity index 100% rename from src/JobsBundle/Registry/ConnectorDefinitionRegistryInterface.php rename to src/Registry/ConnectorDefinitionRegistryInterface.php diff --git a/src/JobsBundle/Registry/ContextItemsResolverRegistry.php b/src/Registry/ContextItemsResolverRegistry.php similarity index 100% rename from src/JobsBundle/Registry/ContextItemsResolverRegistry.php rename to src/Registry/ContextItemsResolverRegistry.php diff --git a/src/JobsBundle/Registry/ContextItemsResolverRegistryInterface.php b/src/Registry/ContextItemsResolverRegistryInterface.php similarity index 100% rename from src/JobsBundle/Registry/ContextItemsResolverRegistryInterface.php rename to src/Registry/ContextItemsResolverRegistryInterface.php diff --git a/src/JobsBundle/Repository/ConnectorContextItemRepository.php b/src/Repository/ConnectorContextItemRepository.php similarity index 100% rename from src/JobsBundle/Repository/ConnectorContextItemRepository.php rename to src/Repository/ConnectorContextItemRepository.php diff --git a/src/JobsBundle/Repository/ConnectorContextItemRepositoryInterface.php b/src/Repository/ConnectorContextItemRepositoryInterface.php similarity index 100% rename from src/JobsBundle/Repository/ConnectorContextItemRepositoryInterface.php rename to src/Repository/ConnectorContextItemRepositoryInterface.php diff --git a/src/JobsBundle/Repository/ConnectorEngineRepository.php b/src/Repository/ConnectorEngineRepository.php similarity index 100% rename from src/JobsBundle/Repository/ConnectorEngineRepository.php rename to src/Repository/ConnectorEngineRepository.php diff --git a/src/JobsBundle/Repository/ConnectorEngineRepositoryInterface.php b/src/Repository/ConnectorEngineRepositoryInterface.php similarity index 100% rename from src/JobsBundle/Repository/ConnectorEngineRepositoryInterface.php rename to src/Repository/ConnectorEngineRepositoryInterface.php diff --git a/src/JobsBundle/Repository/ContextDefinitionRepository.php b/src/Repository/ContextDefinitionRepository.php similarity index 100% rename from src/JobsBundle/Repository/ContextDefinitionRepository.php rename to src/Repository/ContextDefinitionRepository.php diff --git a/src/JobsBundle/Repository/ContextDefinitionRepositoryInterface.php b/src/Repository/ContextDefinitionRepositoryInterface.php similarity index 100% rename from src/JobsBundle/Repository/ContextDefinitionRepositoryInterface.php rename to src/Repository/ContextDefinitionRepositoryInterface.php diff --git a/src/JobsBundle/Repository/LogRepository.php b/src/Repository/LogRepository.php similarity index 100% rename from src/JobsBundle/Repository/LogRepository.php rename to src/Repository/LogRepository.php diff --git a/src/JobsBundle/Repository/LogRepositoryInterface.php b/src/Repository/LogRepositoryInterface.php similarity index 100% rename from src/JobsBundle/Repository/LogRepositoryInterface.php rename to src/Repository/LogRepositoryInterface.php diff --git a/src/JobsBundle/Seo/Extractor/GoogleForJobsExtractor.php b/src/Seo/Extractor/GoogleForJobsExtractor.php similarity index 76% rename from src/JobsBundle/Seo/Extractor/GoogleForJobsExtractor.php rename to src/Seo/Extractor/GoogleForJobsExtractor.php index 1b45839..6eaca65 100644 --- a/src/JobsBundle/Seo/Extractor/GoogleForJobsExtractor.php +++ b/src/Seo/Extractor/GoogleForJobsExtractor.php @@ -2,7 +2,6 @@ namespace JobsBundle\Seo\Extractor; -use JobsBundle\Service\EnvironmentService; use JobsBundle\Service\EnvironmentServiceInterface; use SeoBundle\MetaData\Extractor\ExtractorInterface; use SeoBundle\Model\SeoMetaDataInterface; @@ -12,18 +11,11 @@ class GoogleForJobsExtractor implements ExtractorInterface { - protected EnvironmentService $environmentService; - protected ContextServiceInterface $contextService; - protected ConnectorServiceInterface $connectorService; - public function __construct( - EnvironmentServiceInterface $environmentService, - ContextServiceInterface $contextService, - ConnectorServiceInterface $connectorService + protected EnvironmentServiceInterface $environmentService, + protected ContextServiceInterface $contextService, + protected ConnectorServiceInterface $connectorService ) { - $this->environmentService = $environmentService; - $this->contextService = $contextService; - $this->connectorService = $connectorService; } public function supports(mixed $element): bool diff --git a/src/JobsBundle/Seo/ResourceProcessor/GoogleJobsProcessor.php b/src/Seo/ResourceProcessor/GoogleJobsProcessor.php similarity index 84% rename from src/JobsBundle/Seo/ResourceProcessor/GoogleJobsProcessor.php rename to src/Seo/ResourceProcessor/GoogleJobsProcessor.php index b590612..f037c28 100644 --- a/src/JobsBundle/Seo/ResourceProcessor/GoogleJobsProcessor.php +++ b/src/Seo/ResourceProcessor/GoogleJobsProcessor.php @@ -15,21 +15,12 @@ class GoogleJobsProcessor implements ResourceProcessorInterface { - protected EnvironmentServiceInterface $environmentService; - protected ContextServiceInterface $contextService; - protected ConnectorServiceInterface $connectorService; - protected LogManagerInterface $logManager; - public function __construct( - EnvironmentServiceInterface $environmentService, - ContextServiceInterface $contextService, - ConnectorServiceInterface $connectorService, - LogManagerInterface $logManager + protected EnvironmentServiceInterface $environmentService, + protected ContextServiceInterface $contextService, + protected ConnectorServiceInterface $connectorService, + protected LogManagerInterface $logManager ) { - $this->environmentService = $environmentService; - $this->contextService = $contextService; - $this->connectorService = $connectorService; - $this->logManager = $logManager; } public function supportsWorker(string $workerIdentifier): bool diff --git a/src/JobsBundle/Service/EnvironmentService.php b/src/Service/EnvironmentService.php similarity index 57% rename from src/JobsBundle/Service/EnvironmentService.php rename to src/Service/EnvironmentService.php index a576307..4cd0c1d 100644 --- a/src/JobsBundle/Service/EnvironmentService.php +++ b/src/Service/EnvironmentService.php @@ -4,13 +4,11 @@ class EnvironmentService implements EnvironmentServiceInterface { - protected string $dataClass; - protected string $feedHost; - public function __construct(string $dataClass, string $feedHost) - { - $this->dataClass = $dataClass; - $this->feedHost = $feedHost; + public function __construct( + protected string $dataClass, + protected string $feedHost + ) { } public function getDataClass(): string diff --git a/src/JobsBundle/Service/EnvironmentServiceInterface.php b/src/Service/EnvironmentServiceInterface.php similarity index 100% rename from src/JobsBundle/Service/EnvironmentServiceInterface.php rename to src/Service/EnvironmentServiceInterface.php diff --git a/src/JobsBundle/Service/LinkGeneratorService.php b/src/Service/LinkGeneratorService.php similarity index 100% rename from src/JobsBundle/Service/LinkGeneratorService.php rename to src/Service/LinkGeneratorService.php diff --git a/src/JobsBundle/Service/LinkGeneratorServiceInterface.php b/src/Service/LinkGeneratorServiceInterface.php similarity index 100% rename from src/JobsBundle/Service/LinkGeneratorServiceInterface.php rename to src/Service/LinkGeneratorServiceInterface.php diff --git a/src/JobsBundle/Tool/FeedIdHelper.php b/src/Tool/FeedIdHelper.php similarity index 100% rename from src/JobsBundle/Tool/FeedIdHelper.php rename to src/Tool/FeedIdHelper.php diff --git a/src/JobsBundle/Tool/Install.php b/src/Tool/Install.php similarity index 68% rename from src/JobsBundle/Tool/Install.php rename to src/Tool/Install.php index 0f1c728..6859dd4 100644 --- a/src/JobsBundle/Tool/Install.php +++ b/src/Tool/Install.php @@ -2,7 +2,6 @@ namespace JobsBundle\Tool; -use Pimcore\Db\Connection; use Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller; class Install extends SettingsStoreAwareInstaller @@ -16,13 +15,12 @@ public function install(): void protected function installDbStructure(): void { - /** @var Connection $db */ $db = \Pimcore\Db::get(); - $db->query(file_get_contents($this->getInstallSourcesPath() . '/sql/install.sql')); + $db->executeQuery(file_get_contents($this->getInstallSourcesPath() . '/sql/install.sql')); } protected function getInstallSourcesPath(): string { - return __DIR__ . '/../Resources/install'; + return __DIR__ . '/../../config/install'; } } diff --git a/src/JobsBundle/Transformer/ItemTransformerDefinitionInterface.php b/src/Transformer/ItemTransformerDefinitionInterface.php similarity index 100% rename from src/JobsBundle/Transformer/ItemTransformerDefinitionInterface.php rename to src/Transformer/ItemTransformerDefinitionInterface.php diff --git a/src/JobsBundle/Transformer/ItemTransformerInterface.php b/src/Transformer/ItemTransformerInterface.php similarity index 100% rename from src/JobsBundle/Transformer/ItemTransformerInterface.php rename to src/Transformer/ItemTransformerInterface.php diff --git a/src/JobsBundle/Resources/views/layout.html.twig b/templates/layout.html.twig similarity index 100% rename from src/JobsBundle/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 new file mode 100644 index 0000000..412ce94 --- /dev/null +++ b/tests/Functional.suite.dist.yml @@ -0,0 +1,14 @@ +actor: FunctionalTester +modules: + enabled: + - \Dachcom\Codeception\Support\Helper\PimcoreCore: + connect_db: true + rebootable_client: true + - \Dachcom\Codeception\Support\Helper\PimcoreBundleCore: + run_installer: true + - \Dachcom\Codeception\Support\Helper\Browser\PhpBrowser: + depends: \Dachcom\Codeception\Support\Helper\PimcoreCore + - \Dachcom\Codeception\Support\Helper\PimcoreBackend + - \Dachcom\Codeception\Support\Helper\PimcoreUser + - \DachcomBundle\Test\Support\Helper\Jobs + - \Pimcore\Tests\Support\Helper\ClassManager \ No newline at end of file diff --git a/tests/functional/Admin/ObjectConnectorCest.php b/tests/Functional/Admin/ObjectConnectorCest.php similarity index 97% rename from tests/functional/Admin/ObjectConnectorCest.php rename to tests/Functional/Admin/ObjectConnectorCest.php index 8efcf7b..94d7727 100644 --- a/tests/functional/Admin/ObjectConnectorCest.php +++ b/tests/Functional/Admin/ObjectConnectorCest.php @@ -1,8 +1,8 @@