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;
*/
public function register()
{
- $this->commands([InstallCommand::class, GenerateCommand::class, MigrateCommand::class]);
+ $this->commands([InstallCommand::class, GenerateCommand::class, MigrateCommand::class, SearchIndexCommand::class]);
}
}
+++ /dev/null
-<?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);
- }
- }
-}
--- /dev/null
+<?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);
+ }
+ }
+}