/** * @param array $settings * * @return mixed */ public function resolve(array $settings = []) { $driver = new FluentDriver(array_get($settings, 'mappings')); $namingStrategy = $this->getNamingStrategy($settings); $driver->setFluentFactory(function (ClassMetadata $meta) use($namingStrategy) { return new Builder(new ClassMetadataBuilder($meta), $namingStrategy); }); return $driver; }
public function test_allow_other_fluent_implementations() { $driver = new FluentDriver(); $driver->setFluentFactory(function (ClassMetadata $metadata) { return new CustomBuilder(new ClassMetadataBuilder($metadata)); }); $mapping = $this->getMock(EntityMapping::class); $mapping->expects($this->once())->method('map')->with($this->isInstanceOf(CustomBuilder::class)); $driver->getMappers()->addMapper('fake', new EntityMapper($mapping)); $driver->loadMetadataForClass('fake', new ClassMetadataInfo('fake')); }
/** * @param FluentDriver $mappingDriver * * @throws \Doctrine\Common\Persistence\Mapping\MappingException */ private function addMappings(FluentDriver $mappingDriver) { $mappingDriver->addMapping(new NameMapping()); $mappingDriver->addMapping(new EmailMapping()); $mappingDriver->addMapping(new PasswordMapping()); }