/**
  * {@inheritDoc).
  */
 public function createQuery($context = 'list')
 {
     $query = parent::createQuery($context);
     // Filter on blocks without page and parents
     $query->andWhere($query->expr()->isNull($query->getRootAlias() . '.site'));
     return $query;
 }
 public function getNewInstance()
 {
     $instance = parent::getNewInstance();
     if (!$this->hasRequest()) {
         return $instance;
     }
     if ($site = $this->getSite()) {
         $instance->setSite($site);
     }
     return $instance;
 }
 /**
  * {@inheritdoc}
  */
 public function getBatchActions()
 {
     $actions = parent::getBatchActions();
     $actions['snapshot'] = array('label' => $this->trans('create_snapshot'), 'ask_confirmation' => true);
     return $actions;
 }
 public function __construct($code, $class, $baseControllerName, SitePool $sitePool)
 {
     parent::__construct($code, $class, $baseControllerName);
     $this->sitePool = $sitePool;
 }
 /**
  * Constructor
  *
  * @param string             $code               A Sonata admin code
  * @param string             $class              A Sonata admin class name
  * @param string             $baseControllerName A Sonata admin base controller name
  * @param RoutePageGenerator $routePageGenerator Sonata route page generator service
  */
 public function __construct($code, $class, $baseControllerName, RoutePageGenerator $routePageGenerator)
 {
     $this->routePageGenerator = $routePageGenerator;
     parent::__construct($code, $class, $baseControllerName);
 }
 public function getNewInstance()
 {
     /**
      * @var Site $object
      */
     $object = parent::getNewInstance();
     $object->setEnabled(true);
     $lv = new LanguageVersion();
     $lv->setEnabled(true);
     $lv->setName('Default');
     $lv->setHost('localhost');
     $lv->setRelativePath('');
     $lv->setLocale('cs');
     $lv->setIsDefault(true);
     $object->addLanguageVersion($lv);
     return $object;
 }
 /**
  * @param \Symbio\OrangeGate\PageBundle\Entity\Block $object
  * @return mixed|void
  */
 public function preUpdate($object)
 {
     parent::preUpdate($object);
     $translations = $object->getTranslations();
     foreach ($translations as $trans) {
         $trans->setObject($object);
     }
     foreach ($object->getPostHasImages() as $phi) {
         $phi->setPost($object);
     }
     foreach ($object->getPostHasFiles() as $phf) {
         $phf->setPost($object);
     }
 }