/** * {@inheritdoc} */ public function generate(array $schema, PhpClass $class) { if (!empty($schema['inherit'])) { $class->setParentClassName($schema['inherit']); } elseif ($schema['type'] === 'Custom') { // generate 'id' property and '__toString' method only for Custom entity without inheritance $class->setProperty(PhpProperty::create('id')->setVisibility('protected')); $class->setMethod($this->generateClassMethod('getId', 'return $this->id;')); $this->generateToStringMethod($schema, $class); } $this->generateConstructor($schema, $class); $class->addInterfaceName('Oro\\Bundle\\EntityExtendBundle\\Entity\\ExtendEntityInterface'); $this->generateProperties('property', $schema, $class); $this->generateProperties('relation', $schema, $class); $this->generateProperties('default', $schema, $class); $this->generateCollectionMethods($schema, $class); }
/** * {@inheritdoc} */ protected function doGenerate(ClassMetadata $metadata, array $data, array $options = array()) { static $docBlock; if (empty($docBlock)) { $writer = new Writer(); $writer->writeln('/**')->writeln(' * This code was generated automatically by the FixtureDumper library, manual changes to it')->writeln(' * may be lost upon next generation.')->writeln(' */'); $docBlock = $writer->getContent(); } $fixtureClass = new PhpClass($options['namespace'] . '\\' . $this->namingStrategy->fixtureName($metadata)); $fixtureClass->setDocblock($docBlock); $fixtureClass->setParentClassName('Doctrine\\Common\\DataFixtures\\AbstractFixture'); $fixtureClass->addUseStatement($metadata->getName()); if (count($metadata->getAssociationNames()) !== 0) { $this->addDependentFixtureInterface($fixtureClass, $metadata, $options); } $this->generateLoadMethod($fixtureClass, $metadata, $data); $generator = new DefaultGeneratorStrategy(); $content = $generator->generate($fixtureClass); return $content; }