]> _ Git - cubist_cms-back.git/commitdiff
wip #3323 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 15 Jan 2020 18:24:00 +0000 (19:24 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 15 Jan 2020 18:24:00 +0000 (19:24 +0100)
src/app/Magic/Menu/Item.php
src/app/Magic/Menu/Menu.php
src/app/Magic/Models/Locale.php
src/app/Magic/Search.php

index 44f82fc1e65b661e27709634833f1660fe58723f..69ccc8b3c3913a1312ae4ab51d0ecb06e2f21801 100644 (file)
@@ -107,7 +107,7 @@ class Item
     /**
      * @var string
      */
-    protected $_variant = 'default';
+    protected $_variant = '';
 
     /**
      * @var CubistMagicPageModel
@@ -422,7 +422,7 @@ class Item
 
     public function getURL()
     {
-        $domain = Locale::getMainDomain($this->getLocale());
+        $domain = Locale::getMainDomain($this->getLocale(), $this->getVariant());
         $href = $this->getHref();
         if ($href === 'home') {
             $href = '';
@@ -460,6 +460,9 @@ class Item
         if (!$locale) {
             $item->setLocale($this->getLocale());
         }
+        if (!$item->getVariant() && $this->getVariant()) {
+            $item->setVariant($this->getVariant());
+        }
         $item->setParent($this);
         $this->_children[] = $item;
     }
index 031f0f4da3ed03948c47834d12d296eda60d6313..75325e353c3b7025e0d046b6567d9f8890ab98e6 100644 (file)
@@ -59,9 +59,13 @@ class Menu extends BaseMenu
             $variant = App::getVariant();
         }
 
-        if (!isset(self::$_nav[$locale])) {
+        if (!isset(self::$_nav[$variant])) {
+            self::$_nav[$variant] = [];
+        }
+
+        if (!isset(self::$_nav[$variant][$locale])) {
             \Barryvdh\Debugbar\Facade::startMeasure('nav', 'Init Navigation object');
-            self::$_nav[$locale] = Cache::tags(self::CACHE_TAG)->remember('navigation_' . $variant . '_' . $locale, 43200, function () use ($locale, $variant) {
+            self::$_nav[$variant][$locale] = Cache::tags(self::CACHE_TAG)->remember('navigation_' . $variant . '_' . $locale, 43200, function () use ($locale, $variant) {
                 $nav = new Item();
                 $nav->setLocale($locale);
                 $nav->setVariant($variant);
@@ -70,7 +74,7 @@ class Menu extends BaseMenu
             });
             \Barryvdh\Debugbar\Facade::stopMeasure('nav');
         }
-        return self::$_nav[$locale];
+        return self::$_nav[$variant][$locale];
 
     }
 
index 09de439f694599e214b038a6aea96604c411c136..6b1c704a9cac01b96dbfbacc7fb1df8c3f421c71 100644 (file)
@@ -171,7 +171,7 @@ class Locale extends CubistMagicAbstractModel
             $variant = App::getVariant();
         }
 
-        $all = self::getLocalesData()['locales'];
+        $all = self::getLocalesData($variant)['locales'];
         foreach ($all as $data) {
             if ($data->locale === $locale) {
                 return $data;
@@ -191,7 +191,7 @@ class Locale extends CubistMagicAbstractModel
         }
 
         if (!isset(self::$_mainDomains[$variant][$locale])) {
-            $loc = self::getLocaleData($locale);
+            $loc = self::getLocaleData($locale, $variant);
             if (null === $loc) {
                 return false;
             }
index 63da78276a7ea59ac2c135a325e3474cb5308be7..62e6efa0c38a5fbceb1960411dfda6d4a7ee6725 100644 (file)
@@ -187,6 +187,10 @@ class Search
         $pages = Menu::getAllNavigablePages($locale, $variant);
         $indexed = [];
 
+        if($variant==='MICHSCI'){
+            dd(array_keys($pages));
+        }
+
         foreach ($pages as $url => $page) {
             $html = @file_get_contents($url);
             if (!$html) {
@@ -222,7 +226,7 @@ class Search
                 'id' => $url,
             ];
 
-            echo 'Indexing ' . $url . "\n";
+            echo 'Indexing ' . $variant . ' - ' . $locale . ' | ' . $url . "\n";
 
             $indexed[$url] = true;
             Elasticsearch::index($data);