Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function render(RendererInterface $renderer, array $options = array())
 {
     if (null === $this->name) {
         throw WorkflowException::unboundComponent($this, 'rendering');
     }
     $templates = isset($options['template']) ? array($options['template']) : $this->getRendererTemplates();
     unset($options['template']);
     $context = array_merge($this->getRendererContext(array_replace($this->getDefaultOptions(), $options)), array('name' => $this->name, 'attributes' => $this->attributes, 'options' => $options), $this->vars);
     return $renderer->render($templates, $context, $options);
 }
Esempio n. 2
0
 /**
  * @param string|null $template
  *
  * @return \Twig_Template
  *
  * @throws WorkflowException
  * @throws TemplateException
  */
 private function loadTemplate($template = null)
 {
     if (null === $this->twigEnvironment) {
         throw WorkflowException::twigNotDefined();
     }
     $template = $template ?: $this->defaultTemplate;
     try {
         return $this->twigEnvironment->loadTemplate($template);
     } catch (\Exception $e) {
         throw TemplateException::twigTemplateNotFound($template, $e);
     }
 }
Esempio n. 3
0
 /**
  * Creates columns.
  *
  * @param array $globalOptions
  *
  * @throws WorkflowException
  *
  * @return Column[]
  */
 private function getColumns(array $globalOptions)
 {
     if (null !== $this->columns) {
         return $this->columns;
     }
     if (null === $this->factory) {
         throw WorkflowException::unboundSchema('columns creation');
     }
     $this->columns = array();
     foreach ($this->types as $name => $type) {
         $this->columns[$name] = $this->factory->createColumn($type['name'], array_merge($globalOptions, $type['options']));
     }
     return $this->columns;
 }
Esempio n. 4
0
 /**
  * @param Row         $row
  * @param Entity|null $entity
  *
  * @return Column
  *
  * @throws WorkflowException
  */
 public function build(Row $row, Entity $entity = null)
 {
     if (null === $this->options) {
         throw WorkflowException::notConfiguredColumn($this, 'row building');
     }
     $cell = isset($this->handlers[$row->getType()]) ? $this->handlers[$row->getType()]->handle($this, $entity, $this->options) : new Cell();
     $row->add($this->name, $cell);
     return $this;
 }