<commit_before><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\PageBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;

use Sonata\Cache\CacheManagerInterface;

/**
 * Admin definition for the Snapshot class
 *
 * @author <NAME> <<EMAIL>>
 */
class SnapshotAdmin extends Admin
{
    protected $cacheManager;

    protected $parentAssociationMapping = 'page';

    /**
     * {@inheritdoc}
     */
    public function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('url')
            ->add('enabled')
            ->add('publicationDateStart')
            ->add('publicationDateEnd')
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('routeName');
    }

    /**
     * {@inheritdoc}
     */
    public function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('enabled', null, array('required' => false))
            ->add('publicationDateStart', 'sonata_type_datetime_picker', array('dp_side_by_side' => true))
            ->add('publicationDateEnd', 'sonata_type_datetime_picker', array('dp_side_by_side' => true))
//            ->add('content')
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function getBatchActions()
    {
        $actions = parent::getBatchActions();

        $actions['toggle_enabled'] = array(
            'label'            => $this->trans('toggle_enabled'),
            'ask_confirmation' => true
        );

        return $actions;
    }

    /**
     * {@inheritdoc}
     */
    public function postUpdate($object)
    {
        $this->cacheManager->invalidate(array(
            'page_id' => $object->getPage()->getId()
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function postPersist($object)
    {
        $this->cacheManager->invalidate(array(
            'page_id' => $object->getPage()->getId()
        ));
    }

    /**
     * @param \Sonata\Cache\CacheManagerInterface $cacheManager
     */
    public function setCacheManager(CacheManagerInterface $cacheManager)
    {
        $this->cacheManager = $cacheManager;
    }
}
<commit_msg>make snapshot publicationDateEnd not required<commit_after><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\PageBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;

use Sonata\Cache\CacheManagerInterface;

/**
 * Admin definition for the Snapshot class
 *
 * @author <NAME> <<EMAIL>>
 */
class SnapshotAdmin extends Admin
{
    protected $cacheManager;

    protected $parentAssociationMapping = 'page';

    /**
     * {@inheritdoc}
     */
    public function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('url')
            ->add('enabled')
            ->add('publicationDateStart')
            ->add('publicationDateEnd')
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('routeName');
    }

    /**
     * {@inheritdoc}
     */
    public function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('enabled', null, array('required' => false))
            ->add('publicationDateStart', 'sonata_type_datetime_picker', array('dp_side_by_side' => true))
            ->add('publicationDateEnd', 'sonata_type_datetime_picker', array('required' => false, 'dp_side_by_side' => true))
//            ->add('content')
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function getBatchActions()
    {
        $actions = parent::getBatchActions();

        $actions['toggle_enabled'] = array(
            'label'            => $this->trans('toggle_enabled'),
            'ask_confirmation' => true
        );

        return $actions;
    }

    /**
     * {@inheritdoc}
     */
    public function postUpdate($object)
    {
        $this->cacheManager->invalidate(array(
            'page_id' => $object->getPage()->getId()
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function postPersist($object)
    {
        $this->cacheManager->invalidate(array(
            'page_id' => $object->getPage()->getId()
        ));
    }

    /**
     * @param \Sonata\Cache\CacheManagerInterface $cacheManager
     */
    public function setCacheManager(CacheManagerInterface $cacheManager)
    {
        $this->cacheManager = $cacheManager;
    }
}

{'fraction_non_alphanumeric': 0.13570180547466512, 'fraction_numerical': 0.0, 'mean_word_length': 2.393939393939394, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 68, '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': '5751156', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1476, 'n_words': 274}