Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator)
 {
     parent::generate($originalClass, $classGenerator);
     $interfaces = $classGenerator->getImplementedInterfaces();
     $interfaces[] = 'Bravo3\\Orm\\Proxy\\OrmProxyInterface';
     $classGenerator->setImplementedInterfaces($interfaces);
     $classGenerator->addProperty('_modified_relatives', [], PropertyGenerator::FLAG_PRIVATE);
     $classGenerator->addProperty('_original_indices', [], PropertyGenerator::FLAG_PRIVATE);
     $classGenerator->addProperty('_original_id', null, PropertyGenerator::FLAG_PRIVATE);
     $classGenerator->addMethodFromGenerator(new setRelativeModified());
     $classGenerator->addMethodFromGenerator(new isRelativeModified());
     $classGenerator->addMethodFromGenerator(new setEntityPersisted());
     $classGenerator->addMethodFromGenerator(new setIndexOriginalValue());
     $classGenerator->addMethodFromGenerator(new getIndexOriginalValue());
     $classGenerator->addMethodFromGenerator(new setOriginalId());
     $classGenerator->addMethodFromGenerator(new getOriginalId());
 }
 /**
  * Generates a proxy for the given class name, and retrieves its class name
  *
  * @param string $parentClassName
  *
  * @return string
  */
 private function generateProxy($parentClassName)
 {
     $generatedClassName = __NAMESPACE__ . '\\' . UniqueIdentifierGenerator::getIdentifier('Foo');
     $generator = new LazyLoadingGhostGenerator();
     $generatedClass = new ClassGenerator($generatedClassName);
     $strategy = new EvaluatingGeneratorStrategy();
     $generator->generate(new ReflectionClass($parentClassName), $generatedClass);
     $strategy->generate($generatedClass);
     return $generatedClassName;
 }