Map a collection of document references.
public mapManyReference ( array $mapping ) | ||
$mapping | array | The mapping information. |
public function generateBookDocumentFixture() { $metadata = new ClassMetadataInfo($this->namespace . '\\DocumentGeneratorBook'); $metadata->namespace = $this->namespace; $metadata->customRepositoryClassName = $this->namespace . '\\DocumentGeneratorBookRepository'; $metadata->collection = 'book'; $metadata->mapField(array('fieldName' => 'name', 'type' => 'string')); $metadata->mapField(array('fieldName' => 'status', 'type' => 'string')); $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); $metadata->mapOneReference(array('fieldName' => 'author', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Tools\\DocumentGeneratorAuthor')); $metadata->mapManyReference(array('fieldName' => 'comments', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Tools\\DocumentGeneratorComment')); $metadata->mapManyReference(array('fieldName' => 'searches', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Tools\\DocumentGeneratorSearch')); $metadata->addLifecycleCallback('loading', 'postLoad'); $metadata->addLifecycleCallback('willBeRemoved', 'preRemove'); $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM); $this->generator->writeDocumentClass($metadata, $this->tmpDir); return $metadata; }
public function testOwningSideAndInverseSide() { $cm = new ClassMetadataInfo('Documents\\User'); $cm->mapManyReference(array('fieldName' => 'articles', 'inversedBy' => 'user')); $this->assertTrue($cm->fieldMappings['articles']['isOwningSide']); $cm = new ClassMetadataInfo('Documents\\Article'); $cm->mapOneReference(array('fieldName' => 'user', 'mappedBy' => 'articles')); $this->assertTrue($cm->fieldMappings['user']['isInverseSide']); }
function it_configures_the_mappings_of_an_original_model_that_is_override($configuration) { $metadataInfo = new ClassMetadataInfo('Foo\\Bar\\OriginalQux'); $metadataInfo->mapOneReference(['fieldName' => 'relation1', 'targetEntity' => 'Foo']); $metadataInfo->mapManyReference(['fieldName' => 'relation2', 'targetEntity' => 'Foo']); $metadataInfo->mapOneEmbedded(['fieldName' => 'relation3', 'targetEntity' => 'Foo', 'mappedBy' => 'baz']); $metadataInfo->mapManyEmbedded(['fieldName' => 'relation4', 'targetEntity' => 'Foo']); $overrides = [['original' => 'Foo\\Bar\\OriginalQux', 'override' => 'Acme\\Bar\\OverrideQux'], ['original' => 'Foo\\Baz\\OriginalQux', 'override' => 'Acme\\Baz\\OverrideQux']]; $this->configure($metadataInfo, $overrides, $configuration)->shouldBeAnOverrideModel(); }