Skip to content

Commit

Permalink
Add support for Gedmo DoctrineExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Jun 7, 2019
1 parent af224ea commit aad1404
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,28 @@

use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Sylius\Component\Resource\Metadata\RegistryInterface;

final class ResourceMappingDriver implements MappingDriver
final class ResourceMappingDriverChain extends MappingDriverChain
{
/** @var MappingDriver */
private $mappingDriver;

/** @var RegistryInterface */
private $resourceRegistry;

public function __construct(MappingDriver $mappingDriver, RegistryInterface $resourceRegistry)
{
$this->mappingDriver = $mappingDriver;
$this->resourceRegistry = $resourceRegistry;

$this->setDefaultDriver($mappingDriver);
}

public function loadMetadataForClass($className, ClassMetadata $metadata): void
{
$this->mappingDriver->loadMetadataForClass($className, $metadata);
parent::loadMetadataForClass($className, $metadata);

$this->convertResourceMappedSuperclass($metadata);
}

public function getAllClassNames(): iterable
{
return $this->mappingDriver->getAllClassNames();
}

public function isTransient($className): bool
{
return $this->mappingDriver->isTransient($className);
}

private function convertResourceMappedSuperclass(ClassMetadata $metadata): void
{
if (!isset($metadata->isMappedSuperclass)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<services>
<defaults public="true" />

<service id="sylius_resource.doctrine.mapping_driver"
class="Sylius\Bundle\ResourceBundle\Doctrine\ResourceMappingDriver"
<service id="sylius_resource.doctrine.mapping_driver_chain"
class="Sylius\Bundle\ResourceBundle\Doctrine\ResourceMappingDriverChain"
decorates="doctrine.orm.default_metadata_driver">
<argument type="service" id="sylius_resource.doctrine.mapping_driver.inner" />
<argument type="service" id="sylius_resource.doctrine.mapping_driver_chain.inner" />
<argument type="service" id="sylius.resource_registry" />
</service>
</services>
Expand Down

0 comments on commit aad1404

Please sign in to comment.