Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function createView(FormViewInterface $parent = null)
 {
     if (null === $parent && $this->parent) {
         $parent = $this->parent->createView();
     }
     $view = new FormView($this->config->getName());
     $view->setParent($parent);
     $types = (array) $this->config->getTypes();
     $options = $this->config->getOptions();
     foreach ($types as $type) {
         $type->buildView($view, $this, $options);
         foreach ($type->getExtensions() as $typeExtension) {
             $typeExtension->buildView($view, $this, $options);
         }
     }
     foreach ($this->children as $child) {
         $view->add($child->createView($view));
     }
     foreach ($types as $type) {
         $type->finishView($view, $this, $options);
         foreach ($type->getExtensions() as $typeExtension) {
             $typeExtension->finishView($view, $this, $options);
         }
     }
     return $view;
 }
Пример #2
0
    /**
     * Creates a view.
     *
     * @param FormView $parent The parent view
     *
     * @return FormView The view
     */
    public function createView(FormView $parent = null)
    {
        if (null === $parent && $this->parent) {
            $parent = $this->parent->createView();
        }

        $view = new FormView();

        $view->setParent($parent);

        $types = (array) $this->types;

        foreach ($types as $type) {
            $type->buildView($view, $this);

            foreach ($type->getExtensions() as $typeExtension) {
                $typeExtension->buildView($view, $this);
            }
        }

        $childViews = array();

        foreach ($this->children as $key => $child) {
            $childViews[$key] = $child->createView($view);
        }

        $view->setChildren($childViews);

        foreach ($types as $type) {
            $type->buildViewBottomUp($view, $this);

            foreach ($type->getExtensions() as $typeExtension) {
                $typeExtension->buildViewBottomUp($view, $this);
            }
        }

        return $view;
    }
Пример #3
0
    /**
     * Creates a view.
     *
     * @param FormView $parent The parent view
     *
     * @return FormView The view
     */
    public function createView(FormView $parent = null)
    {
        if (null === $parent && $this->parent) {
            $parent = $this->parent->createView();
        }

        $view = new FormView();

        $view->setParent($parent);

        $types = (array) $this->types;

        foreach ($types as $type) {
            $type->buildView($view, $this);

            foreach ($type->getExtensions() as $typeExtension) {
                $typeExtension->buildView($view, $this);
            }
        }

        $childViews = array();

        foreach ($this->children as $key => $child) {
            $childViews[$key] = $child->createView($view);
        }

        if (null !== $prototype = $view->get('prototype')) {
            $protoView = $prototype->getForm()->createView($view);
            $protoTypes = $protoView->get('types');
            $protoTypes[] = 'prototype';
            $childViews[$prototype->getName()] = $protoView
                ->set('types', $protoTypes)
                ->set('proto_id', $view->get('id').'_prototype');
            ;
        }

        $view->setChildren($childViews);

        foreach ($types as $type) {
            $type->buildViewBottomUp($view, $this);

            foreach ($type->getExtensions() as $typeExtension) {
                $typeExtension->buildViewBottomUp($view, $this);
            }
        }

        return $view;
    }