Skip to content

Commit

Permalink
MetadataLoadInterceptor uses only class names from ClassMetadata->nam…
Browse files Browse the repository at this point in the history
…e string property
  • Loading branch information
lisachenko committed Jan 6, 2021
1 parent b130fc3 commit ef1358d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Bridge/Doctrine/MetadataLoadInterceptor.php
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);
/*
* Go! AOP framework
*
Expand All @@ -9,6 +9,7 @@
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*/

namespace Go\Bridge\Doctrine;

use Doctrine\Common\EventSubscriber;
Expand Down Expand Up @@ -52,16 +53,13 @@ public function getSubscribedEvents(): array
*/
public function loadClassMetadata(LoadClassMetadataEventArgs $args): void
{
/**
* @var ClassMetadata $metadata
*/
$metadata = $args->getClassMetadata();

if (1 === preg_match(sprintf('/.+(%s)$/', AspectContainer::AOP_PROXIED_SUFFIX), $metadata->name)) {
$metadata->isMappedSuperclass = true;
$metadata->isEmbeddedClass = false;
$metadata->table = [];
$metadata->customRepositoryClassName = null;
$metadata->isMappedSuperclass = true;
$metadata->isEmbeddedClass = false;
$metadata->table = [];
$metadata->customRepositoryClassName = null;

$this->removeMappingsFromTraits($metadata);
}
Expand Down Expand Up @@ -97,10 +95,11 @@ private function removeMappingsFromTraits(ClassMetadata $metadata): void
/**
* Get ALL traits used by one class.
*
* This method is copied from https://github.com/RunOpenCode/traitor-bundle/blob/master/src/RunOpenCode/Bundle/Traitor/Utils/ClassUtils.php
* This method is copied from
* https://github.com/RunOpenCode/traitor-bundle/blob/master/src/RunOpenCode/Bundle/Traitor/Utils/ClassUtils.php
*
* @param object|string $className Instance of class or FQCN
* @param bool $autoload Weather to autoload class.
* @param class-string $className FQCN
* @param bool $autoload Weather to autoload class.
*
* @throws InvalidArgumentException
* @throws RuntimeException
Expand All @@ -114,8 +113,9 @@ private function getTraits(string $className, bool $autoload = true): array
$traits = [];
// Get traits of all parent classes
do {
$traits = array_merge(class_uses($className, $autoload), $traits);
} while ($className = get_parent_class($className));
$traits = array_merge(class_uses($className, $autoload), $traits);
$className = get_parent_class($className);
} while ($className);

$traitsToSearch = $traits;

Expand Down

0 comments on commit ef1358d

Please sign in to comment.