]> _ Git - cubist_cms-back.git/commitdiff
wip #2941 0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 19 Aug 2019 10:48:31 +0000 (12:48 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 19 Aug 2019 10:48:31 +0000 (12:48 +0200)
src/CubistBackpackServiceProvider.php
src/app/Console/Commands/SearchIndex.php [deleted file]
src/app/Console/Commands/SearchIndexCommand.php [new file with mode: 0644]

index 7269d76db3f16c6f01c2f985b2e8919cd8c68061..b55da23f56e79fd9b8926ee653e9b195fa09e711 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Cubist\Backpack;
 
+use Composer\Command\SearchCommand;
 use Cubist\Backpack\app\Console\Command\MigrateCommand;
 use Cubist\Backpack\app\Console\Commands\GenerateCommand;
 use Cubist\Backpack\app\Console\Commands\InstallCommand;
@@ -49,6 +50,6 @@ class CubistBackpackServiceProvider extends ServiceProvider
      */
     public function register()
     {
-        $this->commands([InstallCommand::class, GenerateCommand::class, MigrateCommand::class]);
+        $this->commands([InstallCommand::class, GenerateCommand::class, MigrateCommand::class, SearchIndexCommand::class]);
     }
 }
diff --git a/src/app/Console/Commands/SearchIndex.php b/src/app/Console/Commands/SearchIndex.php
deleted file mode 100644 (file)
index 2566f93..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-
-namespace Cubist\Backpack\app\Console\Commands;
-
-use Cubist\Backpack\app\Magic\Menu\Menu;
-use Cubist\Backpack\app\Magic\Menu\PageItem;
-use Cubist\Backpack\app\Magic\Menu\VirtualItem;
-use Cubist\Backpack\app\Template\Navigation;
-use Cubist\Backpack\app\Template\Redirection;
-use Cviebrock\LaravelElasticsearch\Facade;
-use DOMDocument;
-use Illuminate\Console\Command;
-
-
-class SearchIndex extends Command
-{
-    protected $signature = 'cubist:search:index';
-    protected $description = 'Index data for search engine';
-
-    public function handle()
-    {
-        Facade::
-        /** @var Cubist\Backpack\app\Magic\Menu\Item[] $pages */
-        $pages = Menu::getNavigation()->findAll();
-
-        foreach ($pages as $page) {
-            // Skip nav items
-            if ($page instanceof VirtualItem) {
-                continue;
-            }
-            // Skip redirection & navigation pages
-            if ($page instanceof PageItem) {
-                /** @var PageItem $template */
-                $template = $page->getPage()->getUsedTemplate();
-                if ($template instanceof Redirection || $template instanceof Navigation) {
-                    continue;
-                }
-            }
-
-            libxml_use_internal_errors(true);
-            $doc = new DOMDocument();
-            $doc->loadHTMLFile($page->getHref());
-
-            $title = $doc->getElementsByTagName('title');
-            $body = $doc->getElementsByTagName('body');
-
-            $data = [
-                'body' => [
-                    'title' => $title->item(0)->nodeValue,
-                    'body' => $body->item(0)->nodeValue,
-                ],
-                'index' => env('ELASTICSEARCH_INDEX_NAME', 'cubist_elastic_default'),
-                'type' => 'cmspage',
-                'id' => $page->getHref(),
-            ];
-
-            print_r($data);
-
-            Elasticsearch::index($data);
-        }
-    }
-}
diff --git a/src/app/Console/Commands/SearchIndexCommand.php b/src/app/Console/Commands/SearchIndexCommand.php
new file mode 100644 (file)
index 0000000..cecef08
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Console\Commands;
+
+use Cubist\Backpack\app\Magic\Menu\Menu;
+use Cubist\Backpack\app\Magic\Menu\PageItem;
+use Cubist\Backpack\app\Magic\Menu\VirtualItem;
+use Cubist\Backpack\app\Template\Navigation;
+use Cubist\Backpack\app\Template\Redirection;
+use Cviebrock\LaravelElasticsearch\Facade;
+use DOMDocument;
+use Illuminate\Console\Command;
+
+
+class SearchIndexCommand extends Command
+{
+    protected $signature = 'cubist:search:index';
+    protected $description = 'Index data for search engine';
+
+    public function handle()
+    {
+        Facade::
+        /** @var Cubist\Backpack\app\Magic\Menu\Item[] $pages */
+        $pages = Menu::getNavigation()->findAll();
+
+        foreach ($pages as $page) {
+            // Skip nav items
+            if ($page instanceof VirtualItem) {
+                continue;
+            }
+            // Skip redirection & navigation pages
+            if ($page instanceof PageItem) {
+                /** @var PageItem $template */
+                $template = $page->getPage()->getUsedTemplate();
+                if ($template instanceof Redirection || $template instanceof Navigation) {
+                    continue;
+                }
+            }
+
+            libxml_use_internal_errors(true);
+            $doc = new DOMDocument();
+            $doc->loadHTMLFile($page->getHref());
+
+            $title = $doc->getElementsByTagName('title');
+            $body = $doc->getElementsByTagName('body');
+
+            $data = [
+                'body' => [
+                    'title' => $title->item(0)->nodeValue,
+                    'body' => $body->item(0)->nodeValue,
+                ],
+                'index' => env('ELASTICSEARCH_INDEX_NAME', 'cubist_elastic_default'),
+                'type' => 'cmspage',
+                'id' => $page->getHref(),
+            ];
+
+            print_r($data);
+
+            Elasticsearch::index($data);
+        }
+    }
+}