Skip to content

Commit

Permalink
Removed deprecated methods of the AttributeManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Clement Gautier authored and pierallard committed Feb 22, 2016
1 parent db9eb9a commit ae2493c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 255 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
- Removed `Pim\Bundle\EnrichBundle\AbstractController\AbstractDoctrineController` and `Pim\Bundle\EnrichBundle\AbstractController\AbstractController`.
- Change constructor of `Pim\Bundle\EnrichBundle\Filter\ProductEditDataFilter` to add `Pim\Bundle\CatalogBundle\Filter\CollectionFilterInterface` and to remove `Oro\Bundle\SecurityBundle\SecurityFacade`, `Pim\Bundle\CatalogBundle\Filter\ObjectFilterInterface`, `Pim\Component\Catalog\Repository\AttributeRepositoryInterface`, `Pim\Component\Catalog\Repository\LocaleRepositoryInterface` and `Pim\Component\Catalog\Repository\ChannelRepositoryInterface`
- Change constructor of `Pim\Bundle\EnrichBundle\MassEditAction\Operation\EditCommonAttributes` to add `Pim\Bundle\CatalogBundle\Filter\CollectionFilterInterface`
- Change constructor of `Pim\Bundle\EnrichBundle\Controller\AttributeController` to add `Pim\Bundle\CatalogBundle\Factory\AttributeFactory`
- Change constructor of `Pim\Bundle\EnrichBundle\Controller\AttributeOptionController` to add `Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface`
- Change constructor of `Pim\Bundle\TransformBundle\Transformer\AttributeTransformer` to remove `Pim\Bundle\CatalogBundle\Manager\AttributeManager` and add `Pim\Bundle\CatalogBundle\Factory\AttributeFactory`

# 1.5.0-ALPHA1 (2016-01-26)

Expand Down
11 changes: 0 additions & 11 deletions spec/Pim/Bundle/CatalogBundle/Manager/AttributeManagerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ function let(
);
}

function it_instantiates_an_attribute($factory, AttributeInterface $attribute)
{
$factory->createAttribute(null)->willReturn($attribute);
$this->createAttribute()->shouldReturn($attribute);
}

function it_provides_the_attribute_class_used()
{
$this->getAttributeClass()->shouldReturn(self::ATTRIBUTE_CLASS);
}

function it_provides_the_list_of_attribute_types($registry)
{
$registry->getAliases()->willReturn(['foo', 'bar']);
Expand Down
48 changes: 0 additions & 48 deletions src/Pim/Bundle/CatalogBundle/Manager/AttributeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,6 @@ public function __construct(
$this->factory = $factory;
}

/**
* Create an attribute
*
* @param string $type
*
* @return AttributeInterface
*
* @deprecated will be removed in 1.6, please use AttributeFactory::createAttribute
*/
public function createAttribute($type = null)
{
return $this->factory->createAttribute($type);
}

/**
* Get the attribute FQCN
*
* @return string
*
* @deprecated will be removed in 1.6 please use %pim_catalog.entity.attribute.class%
*/
public function getAttributeClass()
{
return $this->attributeClass;
}

/**
* Get a list of available attribute types
*
Expand Down Expand Up @@ -116,26 +90,4 @@ public function updateSorting(AttributeInterface $attribute, array $sorting = []
}
$this->optionSaver->saveAll($attribute->getOptions()->toArray());
}

/**
* Get an attribute or throw an exception
*
* @param int $id
*
* @throws EntityNotFoundException
*
* @return AttributeInterface
*
* @deprecated will be removed in 1.6 please use AttributeRepositoryInterface->find()
*/
public function getAttribute($id)
{
$attribute = $this->repository->find($id);

if (null === $attribute) {
throw new EntityNotFoundException();
}

return $attribute;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Akeneo\Component\StorageUtils\Saver\SaverInterface;
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
use Pim\Bundle\CatalogBundle\AttributeType\AttributeTypes;
use Pim\Bundle\CatalogBundle\Factory\AttributeFactory;
use Pim\Bundle\CatalogBundle\Manager\AttributeManager;
use Pim\Bundle\CatalogBundle\Manager\AttributeOptionManager;
use Pim\Bundle\CatalogBundle\Repository\GroupRepositoryInterface;
Expand Down Expand Up @@ -98,6 +99,7 @@ class AttributeController
* @param HandlerInterface $attributeHandler
* @param Form $attributeForm
* @param AttributeManager $attributeManager
* @param AttributeFactory $attributeFactory
* @param AttributeOptionManager $optionManager
* @param LocaleRepositoryInterface $localeRepository
* @param VersionManager $versionManager
Expand All @@ -116,6 +118,7 @@ public function __construct(
HandlerInterface $attributeHandler,
Form $attributeForm,
AttributeManager $attributeManager,
AttributeFactory $attributeFactory,
AttributeOptionManager $optionManager,
LocaleRepositoryInterface $localeRepository,
VersionManager $versionManager,
Expand All @@ -133,6 +136,7 @@ public function __construct(
$this->attributeHandler = $attributeHandler;
$this->attributeForm = $attributeForm;
$this->attributeManager = $attributeManager;
$this->attributeFactory = $attributeFactory;
$this->optionManager = $optionManager;
$this->localeRepository = $localeRepository;
$this->versionManager = $versionManager;
Expand Down Expand Up @@ -176,7 +180,7 @@ public function createAction(Request $request)
return new RedirectResponse($this->router->generate('pim_enrich_attribute_index'));
}

$attribute = $this->attributeManager->createAttribute($attributeType);
$attribute = $this->attributeFactory->createAttribute($attributeType);

if ($this->attributeHandler->process($attribute)) {
$this->request->getSession()->getFlashBag()
Expand Down Expand Up @@ -356,7 +360,7 @@ protected function findAttributeOr404($id)

if (null === $attribute) {
throw new NotFoundHttpException(
sprintf('%s entity not found', $this->attributeManager->getAttributeClass())
sprintf('%s entity not found', $this->attributeRepository->getClassName())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Pim\Bundle\CatalogBundle\Manager\AttributeOptionManager;
use Pim\Component\Catalog\Model\AttributeInterface;
use Pim\Component\Catalog\Model\AttributeOptionInterface;
use Pim\Component\Catalog\Repository\AttributeRepositoryInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down Expand Up @@ -44,6 +45,9 @@ class AttributeOptionController
/** @var AttributeManager */
protected $attributeManager;

/** @var AttributeRepositoryInterface */
protected $attributeRepository;

/** @var AttributeOptionManager */
protected $optionManager;

Expand All @@ -56,14 +60,15 @@ class AttributeOptionController
/**
* Constructor
*
* @param NormalizerInterface $normalizer
* @param EntityManager $entityManager
* @param FormFactoryInterface $formFactory
* @param ViewHandlerInterface $viewHandler
* @param AttributeManager $attributeManager
* @param AttributeOptionManager $optionManager
* @param SaverInterface $optionSaver
* @param RemoverInterface $optionRemover
* @param NormalizerInterface $normalizer
* @param EntityManager $entityManager
* @param FormFactoryInterface $formFactory
* @param ViewHandlerInterface $viewHandler
* @param AttributeManager $attributeManager
* @param AttributeOptionManager $optionManager
* @param SaverInterface $optionSaver
* @param RemoverInterface $optionRemover
* @param AttributeRepositoryInterface $attributeRepository
*/
public function __construct(
NormalizerInterface $normalizer,
Expand All @@ -73,16 +78,18 @@ public function __construct(
AttributeManager $attributeManager,
AttributeOptionManager $optionManager,
SaverInterface $optionSaver,
RemoverInterface $optionRemover
RemoverInterface $optionRemover,
AttributeRepositoryInterface $attributeRepository
) {
$this->normalizer = $normalizer;
$this->entityManager = $entityManager;
$this->formFactory = $formFactory;
$this->viewHandler = $viewHandler;
$this->attributeManager = $attributeManager;
$this->optionManager = $optionManager;
$this->optionRemover = $optionRemover;
$this->optionSaver = $optionSaver;
$this->normalizer = $normalizer;
$this->entityManager = $entityManager;
$this->formFactory = $formFactory;
$this->viewHandler = $viewHandler;
$this->attributeManager = $attributeManager;
$this->optionManager = $optionManager;
$this->optionRemover = $optionRemover;
$this->optionSaver = $optionSaver;
$this->attributeRepository = $attributeRepository;
}

/**
Expand Down Expand Up @@ -228,7 +235,7 @@ protected function manageFormSubmission(AttributeOptionInterface $attributeOptio
protected function findAttributeOr404($id)
{
try {
$result = $this->attributeManager->getAttribute($id);
$result = $this->attributeRepository->find($id);
} catch (EntityNotFoundException $e) {
throw new NotFoundHttpException($e->getMessage());
}
Expand Down
2 changes: 2 additions & 0 deletions src/Pim/Bundle/EnrichBundle/Resources/config/controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ services:
- '@pim_enrich.form.handler.attribute'
- '@pim_enrich.form.attribute'
- '@pim_catalog.manager.attribute'
- '@pim_catalog.factory.attribute'
- '@pim_catalog.manager.attribute_option'
- '@pim_catalog.repository.locale'
- '@pim_versioning.manager.version'
Expand All @@ -154,6 +155,7 @@ services:
- '@pim_catalog.manager.attribute_option'
- '@pim_catalog.saver.attribute_option'
- '@pim_catalog.remover.attribute_option'
- '@pim_catalog.repository.attribute'

pim_enrich.controller.product:
scope: request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
parent: pim_transform.transformer.entity
arguments:
- '@pim_transform.transformer.registry'
- '@pim_catalog.manager.attribute'
- '@pim_catalog.factory.attribute'
- '@pim_catalog.manager.attribute_option'
- '@pim_transform.cache.doctrine_cache'
tags:
Expand Down
Loading

0 comments on commit ae2493c

Please sign in to comment.