Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::mapManyReference PHP Method

mapManyReference() public method

Map a collection of document references.
public mapManyReference ( array $mapping )
$mapping array The mapping information.
    public function mapManyReference(array $mapping)
    {
        $mapping['reference'] = true;
        $mapping['type'] = 'many';
        $this->mapField($mapping);
    }

Usage Example

 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;
 }
All Usage Examples Of Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::mapManyReference
ClassMetadataInfo