Exemple #1
0
 /**
  * 
  * 
  * wird die Datei nicht übergeben, wird diese in den EntitiesPath des Modules geschrieben ($this->getGClass()->getClassName().php)
  * auch wenn $this->withRepository gesetzt ist, schreibt dies nur das Entity (wegen overwrite)
  * 
  * @return File
  */
 public function write(File $file = NULL, $overwrite = NULL)
 {
     $this->classWriter->setClass($this->class);
     $this->classWriter->addImport(new GClass('Psc\\Data\\ArrayCollection'));
     $this->classWriter->setUseStyle('lines');
     $this->classWriter->addImport(new GClass('Doctrine\\ORM\\Mapping'), 'ORM');
     if (!isset($file)) {
         $file = $this->inferFile($this->class);
     }
     $this->classWriter->write($file, array(), $overwrite);
     $this->classWriter->syntaxCheck($file);
     $this->writtenFile = $file;
     return $file;
 }
 public function createClassMetadata(GClass $gClass)
 {
     // da wir gClass mehrmals im Test evalen könnten, erzeugen wir einen unique hash für den classname und übergeben den
     // der class metadata
     $className = uniqid($gClass->getClassName());
     $gClass->setClassName($className);
     $gClass->createDocBlock()->addAnnotation(Annotation::createDC('Entity'));
     $classWriter = new ClassWriter($gClass);
     $classWriter->setUseStyle('lines');
     $classWriter->addImport(new GClass('Doctrine\\ORM\\Mapping'), 'ORM');
     // braucht einen AnnotationReader nicht SimpleAnnotationReader
     $classWriter->write($file = $this->newFile('entity.' . $gClass->getClassName() . '.php'));
     require $file;
     $cm = new ClassMetadata($gClass->getFQN());
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->annotationDriver->loadMetadataForClass($gClass->getFQN(), $cm);
     $file->delete();
     return $cm;
 }
Exemple #3
0
    }
    $class->generateGetters();
    $class->generateSetters();
    $class->generateDocBlocks();
    $optionsCode = array();
    $optionsCode[] = '$options = new \\stdClass;';
    $optionsCode[] = sprintf('foreach (%s as $option) {', $class->getCodeWriter()->exportList($properties));
    $optionsCode[] = sprintf('  if ($this->$option !== "%s") {', $undefined);
    $optionsCode[] = sprintf('    $options->$option = $this->$option;');
    $optionsCode[] = '  }';
    $optionsCode[] = '}';
    $optionsCode[] = 'return $options;';
    $class->createMethod('getWidgetOptions', array(), $optionsCode)->createDocBlock()->setSummary('Gibt alle gesetzten Optionen des Widgets zurück')->addSimpleAnnotation('return stdClass');
    $class->getClassDocBlock()->addSimpleAnnotation('compiled jqx-widget-specification console-command on ' . date('d.m.Y H:i'));
    $cw = new ClassWriter($gClass = $class->getGClass());
    $cw->setUseStyle(ClassWriter::USE_STYLE_LINES);
    $phpFile = $command->getProject()->getClassFile($gClass);
    $cw->write($phpFile, array(), $overwrite = ClassWriter::OVERWRITE);
    $output->writeln($phpFile . ' written.');
});
$createCommand('tests:build-from-json', array($arg('file')), function ($input, $output, $command) {
    $jsonc = JSONConverter::create();
    $root = Dir::factoryTS(__DIR__)->sub('../');
    $json = $root->getFile($input->getArgument('file'))->getContents();
    $json = '[' . str_replace('}{', '},{', $json) . ']';
    try {
        $report = $jsonc->parse($json);
    } catch (\Webforge\Common\JS\JSONParsingException $e) {
        $parser = new JsonParser();
        $parsingException = $parser->lint($root->getFile('output.json')->getContents());
        throw $parsingException;
Exemple #4
0
 public function setUp()
 {
     $this->classWriter->setUseStyle(ClassWriter::USE_STYLE_LINES);
     // "use" für jeden import davorschreiben
 }