Skip to content

Commit

Permalink
Merged in fix/entity_manager_injection (pull request #5)
Browse files Browse the repository at this point in the history
Removing the entityManager injection
  • Loading branch information
Djamy Tirouche committed Dec 5, 2016
2 parents 4e9f49c + 95d5689 commit 52ce724
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
23 changes: 5 additions & 18 deletions ImportExport/Strategy/ProductStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Synolia\Bundle\OroneoBundle\ImportExport\Strategy;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager;
use Oro\Bundle\EntityConfigBundle\Config\ConfigManager;
use Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper;
use Oro\Bundle\LocaleBundle\Entity\LocalizedFallbackValue;
Expand All @@ -26,9 +25,6 @@ class ProductStrategy extends Strategy
/** @var ConfigManager */
protected $configManager;

/** @var EntityManager */
protected $entityManager;

/** @var BusinessUnitRepository */
protected $businessUnitRepo;

Expand All @@ -47,6 +43,10 @@ class ProductStrategy extends Strategy
public function setDoctrineHelper(DoctrineHelper $doctrineHelper)
{
$this->doctrineHelper = $doctrineHelper;

$this->businessUnitRepo = $doctrineHelper->getEntityRepositoryForClass('OroOrganizationBundle:BusinessUnit');
$this->productUnitRepo = $doctrineHelper->getEntityRepositoryForClass('OroProductBundle:ProductUnit');
$this->categoryRepo = $doctrineHelper->getEntityRepositoryForClass('OroCatalogBundle:Category');
}

/**
Expand All @@ -57,18 +57,6 @@ public function setConfigManager(ConfigManager $configManager)
$this->configManager = $configManager;
}

/**
* @param EntityManager $entityManager
*/
public function setEntityManager(EntityManager $entityManager)
{
$this->entityManager = $entityManager;

$this->businessUnitRepo = $entityManager->getRepository('OroOrganizationBundle:BusinessUnit');
$this->productUnitRepo = $entityManager->getRepository('OroProductBundle:ProductUnit');
$this->categoryRepo = $entityManager->getRepository('OroCatalogBundle:Category');
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -121,8 +109,7 @@ public function afterProcessEntity($entity)
}

$category->addProduct($entity);

$this->entityManager->persist($category);
$this->doctrineHelper->getEntityManagerForClass(get_class($category))->persist($category);
}

$metadata = $this->doctrineHelper->getEntityMetadata($this->localizedFallbackValueClass);
Expand Down
1 change: 0 additions & 1 deletion Resources/config/import_export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ services:
parent: oro_product.importexport.strategy.product
calls:
- [setConfigManager, ['@oro_entity_config.config_manager']]
- [setEntityManager, ['@doctrine.orm.entity_manager']]
- [setDoctrineHelper, ['@oro_entity.doctrine_helper']]

synolia.import.strategy.product_file:
Expand Down

0 comments on commit 52ce724

Please sign in to comment.