Exemple #1
0
 /**
  * @return ClassBuilderProperty
  */
 public function createPropertyIfNotExists($propertyName, Type $type = NULL)
 {
     if ($this->classBuilder->hasProperty($propertyName)) {
         return $this->classBuilder->getProperty($propertyName);
     } else {
         return $this->classBuilder->addProperty($propertyName, $type);
     }
 }
Exemple #2
0
 public function testPropertyElevation()
 {
     $gClass = new GClass('Psc\\OtherException');
     $parentClass = new GClass('Psc\\Exception');
     $classBuilder = new ClassBuilder($gClass);
     $classBuilder->setParentClass($parentClass);
     $this->assertInstanceOf('Psc\\Code\\Generate\\ClassBuilderProperty', $classBuilder->getProperty('message'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $overwrite = $input->getOption('overwrite') ? ClassWriter::OVERWRITE : NULL;
     $controllerName = $input->getArgument('name');
     $entityClass = $this->getDoctrineModule()->getEntityName($controllerName);
     $gClass = new GClass();
     $gClass->setClassName($controllerName . 'Controller');
     $gClass->setNamespace($this->getProject()->getNamespace() . '\\Controllers');
     // siehe auch EntityService
     $gClass->setParentClass(new GClass('Psc\\CMS\\Controller\\AbstractEntityController'));
     $classBuilder = new ClassBuilder($gClass);
     $classBuilder->createProtectedMethod('setUp', array(), array("parent::setUp();"));
     $classBuilder->createMethod('getEntityName', array(), array(sprintf("return '%s';", $entityClass)));
     $imports = array(new GClass($entityClass));
     $classWriter = new ClassWriter();
     $classWriter->setClass($gClass);
     $classWriter->write($file = $this->getProject()->getClassFile($gClass), $imports, $overwrite);
     $output->writeLn('Controller in Datei: "' . $file . '" geschrieben');
     return 0;
 }
 /**
  * @depends testAddProperty
  */
 public function testGenerateDocBlocks(ClassBuilder $cb)
 {
     $this->assertChainable($cb->generateDocBlocks());
     foreach ($cb->getProperties() as $property) {
         $this->assertNotNull($property->getDocBlock());
     }
     $this->assertNotNull($cb->getGClass()->getDocBlock());
 }
Exemple #5
0
 /**
  * @param string $entityName der name des Entities ohne den EntitiesNamespace davor
  */
 public function __construct($entity, Module $doctrineModule, ClassWriter $classWriter = NULL, TypeExporter $DCTypeExporter = NULL, array $languages = array())
 {
     $this->module = $doctrineModule;
     if (!$entity instanceof GClass) {
         $entity = new GClass($this->getDefaultNamespace() . '\\' . $entity);
     }
     parent::__construct($entity);
     $this->class->setAbstract(TRUE);
     $this->classWriter = $classWriter ?: new ClassWriter();
     $this->dcTypeExporter = $DCTypeExporter ?: new TypeExporter(new CodeWriter());
     $this->setLanguages($languages);
 }
 /**
  * 
  * Hilfsfunktion zum ermöglichen von geilen chainables:
  * 
  *  $cb = new ClassBuilder();
  *  $cb->addProperty('eins')->setType('MyType1')->addProperty('zwei'->setType('MyType2')
  * 
  * usw
  */
 public function addProperty($name)
 {
     return $this->builder->addProperty($name);
 }