<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\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class SnapshotAdminController extends Controller
{
    public function createAction()
    {
        if (false === $this->admin->isGranted('CREATE')) {
            throw new AccessDeniedException();
        }

        $class = $this->get('sonata.page.manager.snapshot')->getClass();
        $snapshot = new $class;

        if ($this->getRequest()->getMethod() == 'GET' && $this->getRequest()->get('pageId')) {
            $page = $this->get('sonata.page.manager.page')->findOne(array('id' => $this->getRequest()->get('pageId')));
        } elseif ($this->admin->isChild()) {
            $page = $this->admin->getParent()->getSubject();
        } else {
            $page = null; // no page selected ...
        }

        $snapshot->setPage($page);

        $form = $this->createForm('sonata_page_create_snapshot', $snapshot);

        if ( $this->getRequest()->getMethod() == 'POST') {

            $form->bindRequest($this->getRequest());

            if ($form->isValid()) {
                $snapshotManager = $this->get('sonata.page.manager.snapshot');

                $snapshot = $snapshotManager->create($form->getData()->getPage());
                $snapshotManager->save($snapshot);
                $snapshotManager->enableSnapshots($snapshot);
            }

            return $this->redirect( $this->admin->generateUrl('edit', array('id' => $snapshot->getId())));
        }<commit_msg>Fix method call<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\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class SnapshotAdminController extends Controller
{
    public function createAction()
    {
        if (false === $this->admin->isGranted('CREATE')) {
            throw new AccessDeniedException();
        }

        $class = $this->get('sonata.page.manager.snapshot')->getClass();
        $snapshot = new $class;

        if ($this->getRequest()->getMethod() == 'GET' && $this->getRequest()->get('pageId')) {
            $page = $this->get('sonata.page.manager.page')->findOne(array('id' => $this->getRequest()->get('pageId')));
        } elseif ($this->admin->isChild()) {
            $page = $this->admin->getParent()->getSubject();
        } else {
            $page = null; // no page selected ...
        }

        $snapshot->setPage($page);

        $form = $this->createForm('sonata_page_create_snapshot', $snapshot);

        if ( $this->getRequest()->getMethod() == 'POST') {

            $form->bindRequest($this->getRequest());

            if ($form->isValid()) {
                $snapshotManager = $this->get('sonata.page.manager.snapshot');

                $snapshot = $snapshotManager->create($form->getData()->getPage());
                $snapshotManager->save($snapshot);
                $snapshotManager->enableSnapshots($page->getSite(), $snapshot);
            }

            return $this->redirect( $this->admin->generateUrl('edit', array('id' => $snapshot->getId())));
        }
{'fraction_non_alphanumeric': 0.16597724922440538, 'fraction_numerical': 0.0, 'mean_word_length': 2.9279187817258885, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 82, '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': '3000627', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1065, 'n_words': 201}