/**
  * @param DatagridEntity $source
  * @param Callable $callback
  *
  * @return DatagridEntity
  */
 public function addTranslationSupport(DatagridEntity $source, $callback = null)
 {
     $locale = $this->systemCore->getApplicationCore()->getEditLocale();
     $source->manipulateQuery(function (QueryBuilder $query) use($source, $locale, $callback) {
         $this->addQueryTranslationSupport($query, $source, $locale);
         if (is_callable($callback)) {
             $callback($query);
         }
     });
     return $source;
 }
示例#2
0
 /**
  * Get Globals
  *
  * @return array
  */
 public function getGlobals()
 {
     $section = null;
     if ($this->systemCore->isLoaded()) {
         $section = $this->systemCore->getApplicationCore()->getSection();
     }
     return array('section' => $section, 'project_title' => $this->container->getParameter('unifik_system.metadata.title'), 'project_description' => $this->container->getParameter('unifik_system.metadata.description'), 'project_keywords' => $this->container->getParameter('unifik_system.metadata.keywords'));
 }
 /**
  * Fallback
  *
  * Fallback to the parent if it exists or to the current Section in the Core
  *
  * @param $element
  * @param $locale
  *
  * @return mixed
  */
 protected function fallBack($element, $locale)
 {
     if ($parent = $element->getParent()) {
         $this->setElement($parent);
         $data = $this->generate();
         $url = $data[$locale->getCode()]['url'];
     } elseif (false == $element instanceof Section) {
         $this->setElement($this->core->getSection());
         $data = $this->generate();
         $url = $data[$locale->getCode()]['url'];
     } else {
         // Fallback to the homepage
         try {
             $url = $this->router->generate('section_id_1', array('_locale' => $locale->getCode()));
         } catch (\Exception $e) {
             $url = '';
         }
     }
     return $url;
 }