<commit_before><?php
namespace Vivo\CMS\UI\Content\Editor;

use Vivo\CMS\Api;
use Vivo\CMS\Model;
use Vivo\CMS\Model\Content\Overview as OverviewModel;
use Vivo\UI\AbstractForm;
use Vivo\Form\Form;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;

class Overview extends AbstractForm implements EditorInterface
{
    /**
     * @var \Vivo\CMS\Model\Content\Overview
     */
    private $content;
    /**
     * @var \Vivo\CMS\Api\Document
     */
    private $documentApi;

    public function __construct(Api\Document $documentApi)
    {
        $this->documentApi = $documentApi;
        $this->autoAddCsrf = false;
    }

    public function setContent(Model\Content $content)
    {
        $this->content = $content;
    }

    public function init()
    {
        $this->getForm()->bind($this->content);

        parent::init();
    }

    public function save(Model\ContentContainer $contentContainer)
    {
        if($this->getForm()->isValid()) {
            if($this->content->getUuid()) {
                $this->documentApi->saveContent($this->content);
            }
            else {
                $this->documentApi->createContent($contentContainer, $this->content);
            }
        }
    }

    public function doGetForm()
    {
        $form = new Form('editor-'.$this->content->getUuid());
        $form->setHydrator(new ClassMethodsHydrator(false));
        $form->setOptions(array('use_as_base_fieldset' => true));
        $form->add(array(
            'name' => 'overviewType',
            'type' => 'Vivo\Form\Element\Select',
            'options' => array('label' => 'type'),
            'attributes' => array(
                'options' => array(
                    OverviewModel::TYPE_DYNAMIC => OverviewModel::TYPE_DYNAMIC,
                    OverviewModel::TYPE_STATIC => OverviewModel::TYPE_STATIC
                )
            )
        ));
        //TODO
//         $form->add(array(
//             'name' => 'overviewItems',
//             'type' => 'Vivo\Form\Element\Select',
//             'options' => array('label' => 'items'),
//             'attributes' => array('multiple' => true),
//         ));
        $form->add(array(
            'name' => 'overviewPath',
            'type' => 'Vivo\Form\Element\Text',
            'options' => array('label' => 'path'),
        ));
        $form->add(array(<commit_msg>Set wrap elements = true<commit_after><?php
namespace Vivo\CMS\UI\Content\Editor;

use Vivo\CMS\Api;
use Vivo\CMS\Model;
use Vivo\CMS\Model\Content\Overview as OverviewModel;
use Vivo\UI\AbstractForm;
use Vivo\Form\Form;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;

class Overview extends AbstractForm implements EditorInterface
{
    /**
     * @var \Vivo\CMS\Model\Content\Overview
     */
    private $content;
    /**
     * @var \Vivo\CMS\Api\Document
     */
    private $documentApi;

    public function __construct(Api\Document $documentApi)
    {
        $this->documentApi = $documentApi;
        $this->autoAddCsrf = false;
    }

    public function setContent(Model\Content $content)
    {
        $this->content = $content;
    }

    public function init()
    {
        $this->getForm()->bind($this->content);

        parent::init();
    }

    public function save(Model\ContentContainer $contentContainer)
    {
        if($this->getForm()->isValid()) {
            if($this->content->getUuid()) {
                $this->documentApi->saveContent($this->content);
            }
            else {
                $this->documentApi->createContent($contentContainer, $this->content);
            }
        }
    }

    public function doGetForm()
    {
        $form = new Form('editor-'.$this->content->getUuid());
        $form->setWrapElements(true);
        $form->setHydrator(new ClassMethodsHydrator(false));
        $form->setOptions(array('use_as_base_fieldset' => true));
        $form->add(array(
            'name' => 'overviewType',
            'type' => 'Vivo\Form\Element\Select',
            'options' => array('label' => 'type'),
            'attributes' => array(
                'options' => array(
                    OverviewModel::TYPE_DYNAMIC => OverviewModel::TYPE_DYNAMIC,
                    OverviewModel::TYPE_STATIC => OverviewModel::TYPE_STATIC
                )
            )
        ));
        //TODO
//         $form->add(array(
//             'name' => 'overviewItems',
//             'type' => 'Vivo\Form\Element\Select',
//             'options' => array('label' => 'items'),
//             'attributes' => array('multiple' => true),
//         ));
        $form->add(array(
            'name' => 'overviewPath',
            'type' => 'Vivo\Form\Element\Text',
            'options' => array('label' => 'path'),
        ));
        $form->add(array(
{'fraction_non_alphanumeric': 0.15745568300312826, 'fraction_numerical': 0.0, 'mean_word_length': 2.014456316781898, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5996828', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1374, 'n_words': 221}