Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$blueprint->setTemplate(')->string($this->templateName)->raw(', new \\Phn\\Dal\\Template(')->indent()->write('[')->indent()->each($this->arguments, function ($argument, Loop $loop) use($compiler) {
         $compiler->write('')->string($argument['argument'])->raw(' => ');
         if (isset($argument['default'])) {
             $compiler->raw('new \\Phn\\Dal\\Argument\\ArgumentWithDefault(')->string($argument['type'])->raw(', ')->compile($argument['default'])->raw(')');
         } else {
             $compiler->raw('new \\Phn\\Dal\\Argument\\Argument(')->string($argument['type'])->raw(')');
         }
         if ($loop->isNotLast()) {
             $compiler->raw(',');
         }
     })->outdent()->write('],')->write('')->compile($this->body)->outdent()->write('));');
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$blueprint->setFunction(')->string($this->functionName)->raw(', new \\Phn\\Dal\\Func(')->indent()->write('[')->indent()->each($this->arguments, function ($argument, Loop $loop) use($compiler) {
         $compiler->write('')->string($argument['argument'])->raw(' => ');
         if (isset($argument['default'])) {
             $compiler->raw('new \\Phn\\Dal\\Argument\\ArgumentWithDefault(')->string($argument['type'])->raw(', ')->compile($argument['default'])->raw(')');
         } else {
             $compiler->raw('new \\Phn\\Dal\\Argument\\Argument(')->string($argument['type'])->raw(')');
         }
         if ($loop->isNotLast()) {
             $compiler->raw(',');
         }
     })->outdent()->write('],')->write('')->compile($this->body)->raw(',')->write('new \\Phn\\Dal\\ExecutionStrategy\\ReturnExpr(')->string($this->returnExpr['expr'])->raw(', ')->repr($this->returnExpr['field'] ?? null)->raw(', ')->repr($this->returnExpr['type'] ?? null)->raw(')')->outdent()->write('));');
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$mapper->setCompositeType(')->string($this->typeName)->raw(', ')->repr($this->definition['mapping'])->raw(', ')->run(function () use($compiler) {
         $normalizer = null;
         if (isset($this->definition['options']['normalizer'])) {
             $normalizer = $this->definition['options']['normalizer'];
         }
         $compiler->repr($normalizer);
     })->raw(');');
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('$mapper->export(')->string($this->resourceName)->runIf($this->alias !== null, function () use($compiler) {
         $compiler->raw(', ')->string($this->alias);
     })->raw(');');
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function compile(Compiler $compiler)
 {
     $compiler->write('/**')->write(' * This file has been generated by Phn and should not be edited by hand.')->write(' * Just don\'t do it. I dare you! I double dare you!')->write(' *')->write(' * @author Phn <*****@*****.**>')->write(' */')->write('return new class($mapper, $blueprint) extends \\Phn\\Dal\\Language\\AbstractDal')->write('{')->indent()->write('/**')->write(' * Constructor.')->write(' *')->write(' * @param \\Phn\\Mapping\\HierarchicalMapper $mapper')->write(' * @param \\Phn\\Dal\\HierarchicalBlueprint  $blueprint')->write(' */')->write('public function __construct(\\Phn\\Mapping\\HierarchicalMapper $mapper, \\Phn\\Dal\\HierarchicalBlueprint $blueprint)')->write('{')->indent()->each($this->definition, function (NodeInterface $definition) use($compiler) {
         $compiler->compile($definition)->nl();
     })->write('parent::__construct($blueprint);')->outdent()->write('}')->outdent()->write('};');
 }