Ejemplo n.º 1
0
 /**
  * @param $site
  * @return $this
  */
 protected function addMenuItems($site)
 {
     $pageRoot = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById(1);
     /**
      * 404 Page
      */
     $newPage = new \Fraym\Menu\Entity\MenuItem();
     $newPage->site = $site;
     $newPage->caching = true;
     $newPage->https = false;
     $newPage->checkPermission = false;
     $newPage->is404 = true;
     $newPage->parent = $pageRoot;
     $newPageTranslation = new \Fraym\Menu\Entity\MenuItemTranslation();
     $newPageTranslation->menuItem = $newPage;
     $newPageTranslation->visible = false;
     $newPageTranslation->active = true;
     $newPageTranslation->title = $this->translation->autoTranslation('404 Page not found', 'en', $this->locale->getLocale()->locale);
     $newPageTranslation->subtitle = '';
     $newPageTranslation->url = '/' . $this->translation->autoTranslation('error', 'en', $this->locale->getLocale()->locale) . '-404';
     $newPageTranslation->description = $this->translation->autoTranslation('404 Page not found', 'en', $this->locale->getLocale()->locale);
     $newPageTranslation->externalUrl = false;
     $this->db->persist($newPageTranslation);
     $this->db->flush();
     $this->db->clear();
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @param $key
  * @param $locale
  * @param string $default
  * @param string $defaultLocale
  * @return Entity\Translation|mixed|object
  */
 private function getTranslationEntity($key, $locale, $default = '', $defaultLocale = 'en_US')
 {
     $translationString = empty($default) ? $key : $default;
     $translation = $this->db->getRepository('\\Fraym\\Translation\\Entity\\Translation')->findOneByKey($key);
     if (null === $translation) {
         return $this->createTranslation($key, $translationString, $locale, $defaultLocale);
     }
     $repository = $this->db->getRepository('Gedmo\\Translatable\\Entity\\Translation');
     $translations = $repository->findTranslations($translation);
     if (isset($translations[$locale])) {
         return (object) $translations[$locale];
     } elseif ($this->locale->getLocale()->locale == $locale) {
         $translation->locale = $locale;
         $this->db->refresh($translation);
         $this->db->clear();
         return $translation;
     } else {
         return $this->updateTranslationLocales($translation, $translationString, $locale, $defaultLocale);
     }
     return (object) $translations[$locale];
 }
Ejemplo n.º 3
0
 /**
  * @static
  * @return array|bool
  */
 private function parseRoute()
 {
     $fullMenuItemUrl = '';
     $requestedRoute = $this->getRequestRoute(true, false);
     $routePath = explode('/', $requestedRoute);
     $routeHost = $this->getHostname();
     $qb = $this->prepareMenuQuery()->where("(domain.address = :domain AND\n            translation.url IN (:url)) AND\n            site.active = 1 AND\n            menu.active = 1 AND\n            translation.externalUrl = 0");
     $concatPath = '';
     foreach ($routePath as &$path) {
         $concatPath .= ($path == '' ? '' : '/') . $path;
         $routeArray[] = $concatPath;
     }
     $routeArray = array_reverse($routeArray);
     $result = $qb->setParameter('url', $routeArray)->setParameter('domain', $routeHost)->getQuery()->getOneOrNullResult();
     if ($result !== null) {
         $fullMenuItemUrl = $routeHost . $result->url;
         $this->setCurrentDomain($routeHost);
     }
     $this->addionalRoute = str_replace($fullMenuItemUrl, '', $this->getRequestRoute());
     $this->db->clear();
     return $result;
 }
Ejemplo n.º 4
0
 private function addMenuItems($site)
 {
     $gp = $this->request->getGPAsObject();
     /**
      * Root Page
      */
     $pageRoot = new \Fraym\Menu\Entity\MenuItem();
     $pageRoot->site = $site;
     $pageRoot->caching = true;
     $pageRoot->visible = true;
     $pageRoot->active = true;
     $pageRoot->https = false;
     $pageRoot->checkPermission = false;
     $pageRoot->is404 = false;
     $pageRootTranslation = new \Fraym\Menu\Entity\MenuItemTranslation();
     $pageRootTranslation->menuItem = $pageRoot;
     $pageRootTranslation->title = $this->translation->autoTranslation('Home', 'en', $gp->locale);
     $pageRootTranslation->subtitle = $this->translation->autoTranslation('Welcome to my website.', 'en', $gp->locale);
     $pageRootTranslation->url = "";
     $pageRootTranslation->shortDescription = $this->translation->autoTranslation('My short website description', 'en', $gp->locale);
     $pageRootTranslation->longDescription = $this->translation->autoTranslation('My long website description', 'en', $gp->locale);
     $pageRootTranslation->externalUrl = false;
     $this->db->persist($pageRootTranslation);
     /**
      * 404 Page
      */
     $newPage = new \Fraym\Menu\Entity\MenuItem();
     $newPage->site = $site;
     $newPage->caching = true;
     $newPage->visible = false;
     $newPage->active = true;
     $newPage->https = false;
     $newPage->checkPermission = false;
     $newPage->is404 = true;
     $newPage->parent = $pageRoot;
     $newPageTranslation = new \Fraym\Menu\Entity\MenuItemTranslation();
     $newPageTranslation->menuItem = $newPage;
     $newPageTranslation->title = $this->translation->autoTranslation('404 Page not found', 'en', $gp->locale);
     $newPageTranslation->subtitle = '';
     $newPageTranslation->url = '/' . $this->translation->autoTranslation('error', 'en', $gp->locale) . '-404';
     $newPageTranslation->shortDescription = $this->translation->autoTranslation('404 Page not found', 'en', $gp->locale);
     $newPageTranslation->longDescription = $this->translation->autoTranslation('404 Page not found', 'en', $gp->locale);
     $newPageTranslation->externalUrl = false;
     $this->db->persist($newPageTranslation);
     /**
      * Blog Page
      */
     $newPage = new \Fraym\Menu\Entity\MenuItem();
     $newPage->site = $site;
     $newPage->caching = true;
     $newPage->visible = true;
     $newPage->active = true;
     $newPage->https = false;
     $newPage->checkPermission = false;
     $newPage->is404 = false;
     $newPage->parent = $pageRoot;
     $newPageTranslation = new \Fraym\Menu\Entity\MenuItemTranslation();
     $newPageTranslation->menuItem = $newPage;
     $newPageTranslation->title = $this->translation->autoTranslation('Blog', 'en', $gp->locale);
     $newPageTranslation->subtitle = $this->translation->autoTranslation('This is my blog.', 'en', $gp->locale);
     $newPageTranslation->url = "blog";
     $newPageTranslation->shortDescription = $this->translation->autoTranslation('Check out my blog.', 'en', $gp->locale);
     $newPageTranslation->longDescription = $this->translation->autoTranslation('Check out my blog.', 'en', $gp->locale);
     $newPageTranslation->externalUrl = false;
     $this->db->persist($newPageTranslation);
     $this->db->flush();
     $this->db->clear();
     return $this;
 }