Skip to content

Commit

Permalink
Fixing build
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermeblanco committed Jul 24, 2019
1 parent d606941 commit 8601d9e
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 34 deletions.
14 changes: 14 additions & 0 deletions lib/Doctrine/ORM/Configuration/MetadataConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\ORM\Configuration;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\ORM\Mapping\Driver\MappingDriver;
use Doctrine\ORM\Mapping\Factory\AbstractClassMetadataFactory;
use Doctrine\ORM\Mapping\Factory\ClassMetadataResolver;
Expand All @@ -30,6 +31,9 @@ class MetadataConfiguration
/** @var MappingDriver */
private $mappingDriver;

/** @var AbstractPlatform */
private $targetPlatform;

/** @var NamingStrategy */
private $namingStrategy;

Expand Down Expand Up @@ -76,6 +80,16 @@ public function setMappingDriver(MappingDriver $mappingDriver)
$this->mappingDriver = $mappingDriver;
}

public function getTargetPlatform() : AbstractPlatform
{
return $this->targetPlatform;
}

public function setTargetPlatform(AbstractPlatform $targetPlatform) : void
{
$this->targetPlatform = $targetPlatform;
}

public function getNamingStrategy() : NamingStrategy
{
if (! $this->namingStrategy) {
Expand Down
10 changes: 0 additions & 10 deletions lib/Doctrine/ORM/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Doctrine\ORM\Cache\Exception\CacheException;
use Doctrine\ORM\Cache\Exception\NonCacheableEntityAssociation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Factory\NamingStrategy;
use Doctrine\ORM\Reflection\ReflectionService;
use Doctrine\ORM\Sequencing\Planning\ValueGenerationPlan;
use Doctrine\ORM\Utility\PersisterHelper;
Expand Down Expand Up @@ -172,13 +171,6 @@ class ClassMetadata extends ComponentMetadata implements TableOwner
*/
public $versionProperty;

/**
* NamingStrategy determining the default column and table names.
*
* @var NamingStrategy
*/
protected $namingStrategy;

/**
* Value generation plan is responsible for generating values for auto-generated fields.
*
Expand All @@ -200,8 +192,6 @@ public function __construct(
) {
parent::__construct($entityName, $metadataBuildingContext);

$this->namingStrategy = $metadataBuildingContext->getNamingStrategy();

if ($parent) {
$this->setParent($parent);
}
Expand Down
6 changes: 1 addition & 5 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@
use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Mapping\Exception\TableGeneratorNotImplementedYet;
use Doctrine\ORM\Mapping\Exception\UnknownGeneratorType;
use Doctrine\ORM\Reflection\ReflectionService;
use Doctrine\ORM\Reflection\RuntimeReflectionService;
use Doctrine\ORM\Sequencing\Executor\ValueGenerationExecutor;
use Doctrine\ORM\Sequencing\Planning\CompositeValueGenerationPlan;
use Doctrine\ORM\Sequencing\Planning\NoopValueGenerationPlan;
use Doctrine\ORM\Sequencing\Planning\SingleValueGenerationPlan;
use Doctrine\ORM\Sequencing\Executor\ValueGenerationExecutor;
use Doctrine\ORM\Utility\StaticClassNameConverter;
use InvalidArgumentException;
use ReflectionException;
use function array_map;
use function array_reverse;
use function count;
use function in_array;
use function reset;
use function sprintf;

/**
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Annotation;
use Doctrine\ORM\Cache\Exception\CacheException;
use Doctrine\ORM\Events;
Expand Down Expand Up @@ -43,8 +42,6 @@
use function sprintf;
use function str_replace;
use function strpos;
use function strtoupper;
use function var_export;

/**
* The AnnotationDriver reads the mapping metadata from docblock annotations.
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function count;
use function current;
use function in_array;
use function reset;
use function sort;
use function str_replace;
use function strtolower;
Expand Down Expand Up @@ -347,7 +348,8 @@ private function buildFieldMappings(Mapping\ClassMetadata $metadata)

// We need to check for the columns here, because we might have associations as id as well.
if ($ids && count($primaryKeys) === 1) {
$generator = $fieldMetadata->getTypeName() === 'bigint'
$fieldMetadata = reset($ids);
$generator = $fieldMetadata->getTypeName() === 'bigint'
? new Generator\BigIntegerIdentityGenerator()
: new Generator\IdentityGenerator();

Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use function sprintf;
use function str_replace;
use function strtoupper;
use function var_export;

/**
* XmlDriver is a metadata driver that enables mapping through XML files.
Expand Down
41 changes: 32 additions & 9 deletions lib/Doctrine/ORM/Mapping/Factory/AbstractClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Mapping\Factory;

use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\ORM\Configuration\MetadataConfiguration;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataBuildingContext;
Expand Down Expand Up @@ -48,6 +49,12 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
/** @var MappingDriver */
protected $mappingDriver;

/** @var AbstractPlatform */
protected $targetPlatform;

/** @var NamingStrategy */
protected $namingStrategy;

/** @var ClassMetadataDefinition[] */
private $definitions = [];

Expand All @@ -56,15 +63,20 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory

public function __construct(MetadataConfiguration $configuration)
{
$mappingDriver = $configuration->getMappingDriver();
$resolver = $configuration->getResolver();
$mappingDriver = $configuration->getMappingDriver();
$resolver = $configuration->getResolver();
$targetPlatform = $configuration->getTargetPlatform();
$namingStrategy = $configuration->getNamingStrategy();
//$autoGenerate = $configuration->getAutoGenerate();

$generator = new ClassMetadataGenerator($mappingDriver);
$generatorStrategy = new ConditionalFileWriterClassMetadataGeneratorStrategy($generator);
$definitionFactory = new ClassMetadataDefinitionFactory($resolver, $generatorStrategy);

$this->mappingDriver = $mappingDriver;
$this->definitionFactory = $definitionFactory;
$this->targetPlatform = $targetPlatform;
$this->namingStrategy = $namingStrategy;
}

/**
Expand Down Expand Up @@ -94,21 +106,32 @@ public function getMetadataFor($className)
return $this->loaded[$entityClassName];
}

$metadataBuildingContext = new ClassMetadataBuildingContext($this, new RuntimeReflectionService());
$parentClassNameList = $this->getParentClassNameList($entityClassName);
$parentClassNameList[] = $entityClassName;
$parent = null;
$metadataBuildingContext = new ClassMetadataBuildingContext(
$this,
new RuntimeReflectionService(),
$this->targetPlatform,
$this->namingStrategy
);

$parentClassMetadata = null;
$parentClassNameList = $this->getParentClassNameList($entityClassName);

$parentClassNameList[] = $entityClassName;

foreach ($parentClassNameList as $parentClassName) {
if (isset($this->loaded[$parentClassName])) {
$parent = $this->loaded[$parentClassName];
$parentClassMetadata = $this->loaded[$parentClassName];

continue;
}

$definition = $this->getOrCreateClassMetadataDefinition($parentClassName, $parent, $metadataBuildingContext);
$definition = $this->getOrCreateClassMetadataDefinition(
$parentClassName,
$parentClassMetadata,
$metadataBuildingContext
);

$parent = $this->loaded[$parentClassName] = $this->createClassMetadata($definition);
$parentClassMetadata = $this->loaded[$parentClassName] = $this->createClassMetadata($definition);
}

$metadataBuildingContext->validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\ORM\Tools\Console\Command;

use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\ORM\Annotation\GeneratedValue;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\AssociationMetadata;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ public function generate(EntityManagerInterface $em, ?object $entity)
// TODO: Implement generate() method.
}

public function isPostInsertGenerator(): bool
public function isPostInsertGenerator() : bool
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
Expand Down Expand Up @@ -223,7 +222,7 @@ protected function createValidClassMetadata()
$fieldMetadata->setPrimaryKey(true);
$fieldMetadata->setValueGenerator(new Mapping\ValueGeneratorMetadata(
Mapping\GeneratorType::SEQUENCE,
new Generator\SequenceGenerator("group_id_seq", 1)
new Generator\SequenceGenerator('group_id_seq', 1)
));

$cm1->addProperty($fieldMetadata);
Expand Down
1 change: 0 additions & 1 deletion tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Doctrine\ORM\Mapping\Factory\UnderscoreNamingStrategy;
use Doctrine\ORM\Mapping\JoinColumnMetadata;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\ORM\Reflection\ReflectionService;
use Doctrine\ORM\Reflection\RuntimeReflectionService;
use Doctrine\ORM\Reflection\StaticReflectionService;
use Doctrine\Tests\Models\CMS;
Expand Down

0 comments on commit 8601d9e

Please sign in to comment.