Skip to content

Commit

Permalink
Pim 4.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoussard committed Apr 6, 2020
1 parent 8b2c148 commit d7d94d0
Show file tree
Hide file tree
Showing 37 changed files with 5,890 additions and 2,567 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
!docs/examples/bin
bin
vendor
composer.phar
.php_cs.cache
docker-compose.override.yml

# PhpStorm
.idea
8 changes: 4 additions & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ tools:
- vendor/*
php_loc:
excluded_dirs:
- app/
- config/
- bin/
- vendor/
- web/
- public/
php_pdepend:
excluded_dirs:
- app/
- config/
- bin/
- vendor/
- web/
- public/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: php

php:
- "7.2"
- "7.3"

cache:
directories:
Expand Down
2 changes: 1 addition & 1 deletion Action/AbstractAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Router;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @author Antoine Guigan <[email protected]>
Expand Down
16 changes: 8 additions & 8 deletions Action/AbstractViewableAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use Pim\Bundle\CustomEntityBundle\Event\ActionEventManager;
use Pim\Bundle\CustomEntityBundle\Manager\Registry as ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;

/**
* @author Antoine Guigan <[email protected]>
Expand All @@ -19,29 +19,29 @@
abstract class AbstractViewableAction extends AbstractAction
{
/**
* @var EngineInterface
* @var Environment
*/
protected $templating;
protected $twig;

/**
* @param ActionFactory $actionFactory
* @param ActionEventManager $eventManager
* @param ManagerRegistry $managerRegistry
* @param RouterInterface $router
* @param TranslatorInterface $translator
* @param EngineInterface $templating
* @param Environment $twig
*/
public function __construct(
ActionFactory $actionFactory,
ActionEventManager $eventManager,
ManagerRegistry $managerRegistry,
RouterInterface $router,
TranslatorInterface $translator,
EngineInterface $templating
Environment $twig
) {
parent::__construct($actionFactory, $eventManager, $managerRegistry, $router, $translator);

$this->templating = $templating;
$this->twig = $twig;
}

/**
Expand Down Expand Up @@ -69,7 +69,7 @@ public function renderResponse(array $templateVars = [])
$templateVars + $this->getDefaultTemplateVars()
);

return $this->templating->renderResponse($template, $templateVars);
return $this->twig->render($template, $templateVars);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Controller/AjaxOptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Pim\Bundle\CustomEntityBundle\Controller;

use Akeneo\Pim\Enrichment\Component\Product\Repository\ReferenceDataRepositoryInterface;
use Akeneo\Platform\Bundle\UIBundle\Controller\AjaxOptionController as BaseAjaxOptionController;
use Pim\Component\ReferenceData\Repository\ReferenceDataRepositoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

Expand Down
2 changes: 2 additions & 0 deletions DependencyInjection/Compiler/ConfigurationBuilderPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function addService(ContainerBuilder $container, $name, array $configu
$configuration['options']
]
);
$definition->setPublic(true);
foreach ($configuration['actions'] as $type => $options) {
if (null === $options || !$options['enabled']) {
continue;
Expand All @@ -77,6 +78,7 @@ protected function addService(ContainerBuilder $container, $name, array $configu
$serviceName = sprintf('pim_custom_entity.configuration.%s', $name);
$container->addDefinitions([$serviceName => $definition]);
$container->getDefinition('pim_custom_entity.configuration.registry')
->setPublic(true)
->addMethodCall('add', [$name, $serviceName]);
}

Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For more information, please see http://docs.akeneo.com/

| CustomEntityBundle | Akeneo PIM Community Edition |
|:--------------------:|:----------------------------:|
| v4.0.* | v4.0.* |
| v3.0.* | v3.0.* |
| v2.4.* | v2.3.* |
| v2.3.* | v2.2.* |
Expand All @@ -23,24 +24,24 @@ For more information, please see http://docs.akeneo.com/
You can install this bundle with composer (see requirements section):

```bash
php composer.phar require "akeneo-labs/custom-entity-bundle":"3.0.*"
php composer.phar require "akeneo-labs/custom-entity-bundle":"4.0.*"
```

Then add the following lines **at the end** of your app/config/routing.yml :
Then add the following lines **at the end** of your config/routes/routes.yml :

```yaml
pim_customentity:
prefix: /reference-data
resource: "@PimCustomEntityBundle/Resources/config/routing.yml"
```
and enable the bundle in the `app/AppKernel.php` file in the `registerProjectBundles()` method:
and enable the bundle in the `config/bundles.php` file:

```php
$bundles = [
return [
// ...
new \Pim\Bundle\CustomEntityBundle\PimCustomEntityBundle(),
]
Pim\Bundle\CustomEntityBundle\PimCustomEntityBundle::class => ['all' => true]
];
```

If your installation is already set up, you have to run the following command in order to add the quick export job:
Expand All @@ -52,7 +53,7 @@ If your installation is already set up, you have to run the following command in
## Documentation

The reference data documentation can be found in the
[PIM documentation](https://docs.akeneo.com/2.2/manipulate_pim_data/catalog_structure/creating_a_reference_data.html).
[PIM documentation](https://docs.akeneo.com/4.0/manipulate_pim_data/catalog_structure/creating_a_reference_data.html).

Detailled information can be found in the [bundle documentation](docs/index.md).

Expand All @@ -75,15 +76,21 @@ Detailled information can be found in the [bundle documentation](docs/index.md).
### PHPUnit

* Install an Akeneo PIM with the CustomEntityBundle
* Copy `Tests/Resources/phpunit.xml` into your base `app` directory
* Copy `Tests/Resources/parameters_test.yml` or `Tests/Resources/parameters_test_ee.yml` (depending on your PIM version) to `app/config/parameters_test.yml`, and edit accordingly to your config
* Copy `Tests/Resources/phpunit.xml` to project root
* Copy `Tests/Resources/.env.test` to project root, and edit accordingly to your config
* Copy `Tests/Resources/bundles.php` or `Tests/Resources/bundles_ee.php` (depending on your PIM version) content in the `config/bundles.php` file

Then:

```bash
$ php bin/console cache:clear --no-warmup --env=test
$ php bin/console pim:installer:db --env=test
$ vendor/bin/phpunit -c app/phpunit.xml
$ php bin/console cache:warmup --env=test
If you're on EE Edition :
$ php bin/console pim:installer:db --env=test --catalog vendor/akeneo/pim-enterprise-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal
Else :
$ php bin/console pim:installer:db --env=test --catalog vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal
$ vendor/bin/phpunit
```

## Contributing
Expand Down
8 changes: 7 additions & 1 deletion Resources/config/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
abstract: true
parent: pim_custom_entity.action
arguments:
- '@templating'
- '@twig'

pim_custom_entity.action.form:
abstract: true
Expand All @@ -39,6 +39,7 @@ services:
pim_custom_entity.action.quick_export:
class: '%pim_custom_entity.action.quick_export.class%'
shared: false
public: true
arguments:
- '@pim_custom_entity.action.factory'
- '@pim_custom_entity.action_event_manager'
Expand All @@ -56,6 +57,7 @@ services:
pim_custom_entity.action.rest.get:
class: '%pim_custom_entity.action.rest.get.class%'
shared: false
public: true
arguments:
- '@pim_custom_entity.action.factory'
- '@pim_custom_entity.action_event_manager'
Expand All @@ -64,6 +66,7 @@ services:
pim_custom_entity.action.rest.getall:
class: '%pim_custom_entity.action.rest.getall.class%'
shared: false
public: true
arguments:
- '@pim_custom_entity.action.factory'
- '@pim_custom_entity.action_event_manager'
Expand All @@ -72,6 +75,7 @@ services:
pim_custom_entity.action.rest.delete:
class: '%pim_custom_entity.action.rest.delete.class%'
shared: false
public: true
arguments:
- '@pim_custom_entity.action.factory'
- '@pim_custom_entity.action_event_manager'
Expand All @@ -80,6 +84,7 @@ services:
pim_custom_entity.action.rest.create:
class: '%pim_custom_entity.action.rest.create.class%'
shared: false
public: true
arguments:
- '@pim_custom_entity.action.factory'
- '@pim_custom_entity.action_event_manager'
Expand All @@ -90,6 +95,7 @@ services:
pim_custom_entity.action.rest.update:
class: '%pim_custom_entity.action.rest.update.class%'
shared: false
public: true
arguments:
- '@pim_custom_entity.action.factory'
- '@pim_custom_entity.action_event_manager'
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/controllers.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
parameters:
pim_ui.controller.ajax_option.class: Pim\Bundle\CustomEntityBundle\Controller\AjaxOptionController
pimee_ui.controller.ajax_option.class: Pim\Bundle\CustomEntityBundle\Controller\EnterpriseAjaxOptionController
pimee_product_asset.controller.ajax_option.class: Pim\Bundle\CustomEntityBundle\Controller\EnterpriseAjaxOptionController
pim_custom_entity.rest_controller.class: Pim\Bundle\CustomEntityBundle\Controller\RestController

services:
pim_custom_entity.controller:
class: '%pim_custom_entity.controller.class%'
scope: request
arguments:
- '@pim_custom_entity.action.factory'
- '@request_stack'
tags:
- { name: controller.service_arguments }

pim_custom_entity.rest_controller:
class: '%pim_custom_entity.rest_controller.class%'
scope: request
arguments:
- '@pim_custom_entity.configuration.registry'
12 changes: 1 addition & 11 deletions Resources/config/mass_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,4 @@ services:
-
name: pim_datagrid.extension.mass_action.handler
alias: custom_mass_edit
operation_group: mass-edit

pim_custom_entity.mass_action.mass_action.handler.quick_export:
class: '%pim_datagrid.extension.mass_action.handler.export.class%'
arguments:
- '@pim_datagrid.datasource.result_record.hydrator.object_id'
- '@event_dispatcher'
tags:
-
name: pim_datagrid.extension.mass_action.handler
alias: custom_quick_export
operation_group: mass-edit
3 changes: 1 addition & 2 deletions Resources/config/savers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ services:
- '@property_accessor'
- '@pim_catalog.repository.locale'
- '@doctrine.orm.entity_manager'
- '@akeneo_file_storage.file_storage.file.file_storer'
- '%tmp_storage_dir%'
- '@akeneo_file_storage.file_storage.file.file_storer'
5 changes: 0 additions & 5 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ services:
arguments:
- '@event_dispatcher'

pim_custom_entity.factory.custom_entity:
class: Pim\Bundle\CustomEntityBundle\Entity\CustomEntityFactory
arguments:
- '@pim_custom_entity.configuration.registry'

pim_custom_entity.repository.attribute:
class: '%pim_custom_entity.repository.attribute.class%'
arguments:
Expand Down
Loading

0 comments on commit d7d94d0

Please sign in to comment.