}
foreach ($chain as $currentEntity) {
-
if (is_null($currentEntity->restricted)) {
- throw new InvalidArgumentException("Entity restricted field used but has not been loaded");
+ throw new InvalidArgumentException('Entity restricted field used but has not been loaded');
}
if ($currentEntity->restricted) {
}
$this->avatarUrl = $avatar;
+
return $avatar;
}
namespace BookStack\Console\Commands;
use BookStack\Entities\Models\Entity;
-use BookStack\Entities\Tools\SearchIndex;
+use BookStack\Search\SearchIndex;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use BookStack\Auth\Permissions\JointPermission;
use BookStack\Auth\Permissions\JointPermissionBuilder;
use BookStack\Auth\Permissions\PermissionApplicator;
-use BookStack\Entities\Tools\SearchIndex;
use BookStack\Entities\Tools\SlugGenerator;
use BookStack\Interfaces\Deletable;
use BookStack\Interfaces\Favouritable;
use BookStack\Interfaces\Sluggable;
use BookStack\Interfaces\Viewable;
use BookStack\Model;
+use BookStack\Search\SearchIndex;
+use BookStack\Search\SearchTerm;
use BookStack\Traits\HasCreatorAndUpdater;
use BookStack\Traits\HasOwner;
use Carbon\Carbon;
namespace BookStack\Http\Controllers\Api;
use BookStack\Entities\Models\Entity;
-use BookStack\Entities\Tools\SearchOptions;
-use BookStack\Entities\Tools\SearchResultsFormatter;
-use BookStack\Entities\Tools\SearchRunner;
+use BookStack\Search\SearchOptions;
+use BookStack\Search\SearchResultsFormatter;
+use BookStack\Search\SearchRunner;
use Illuminate\Http\Request;
class SearchApiController extends ApiController
{
$page = $this->pageRepo->getBySlug($bookSlug, $pageSlug);
$revisions = $page->revisions()->select([
- 'id', 'page_id', 'name', 'created_at', 'created_by', 'updated_at',
- 'type', 'revision_number', 'summary',
- ])
+ 'id', 'page_id', 'name', 'created_at', 'created_by', 'updated_at',
+ 'type', 'revision_number', 'summary',
+ ])
->selectRaw("IF(markdown = '', false, true) as is_markdown")
->with(['page.book', 'createdBy'])
->get();
return view('pages.revisions', [
'revisions' => $revisions,
- 'page' => $page,
+ 'page' => $page,
]);
}
namespace BookStack\Http\Controllers;
use BookStack\Entities\Queries\Popular;
-use BookStack\Entities\Tools\SearchOptions;
-use BookStack\Entities\Tools\SearchResultsFormatter;
-use BookStack\Entities\Tools\SearchRunner;
use BookStack\Entities\Tools\SiblingFetcher;
+use BookStack\Search\SearchOptions;
+use BookStack\Search\SearchResultsFormatter;
+use BookStack\Search\SearchRunner;
use Illuminate\Http\Request;
class SearchController extends Controller
<?php
-namespace BookStack\Entities\Tools;
+namespace BookStack\Search;
use BookStack\Actions\Tag;
use BookStack\Entities\EntityProvider;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
-use BookStack\Entities\Models\SearchTerm;
use DOMDocument;
use DOMNode;
use Illuminate\Database\Eloquent\Builder;
<?php
-namespace BookStack\Entities\Tools;
+namespace BookStack\Search;
use Illuminate\Http\Request;
class SearchOptions
{
- /**
- * @var array
- */
- public $searches = [];
-
- /**
- * @var array
- */
- public $exacts = [];
-
- /**
- * @var array
- */
- public $tags = [];
-
- /**
- * @var array
- */
- public $filters = [];
+ public array $searches = [];
+ public array $exacts = [];
+ public array $tags = [];
+ public array $filters = [];
/**
* Create a new instance from a search string.
<?php
-namespace BookStack\Entities\Tools;
+namespace BookStack\Search;
use BookStack\Actions\Tag;
use BookStack\Entities\Models\Entity;
<?php
-namespace BookStack\Entities\Tools;
+namespace BookStack\Search;
use BookStack\Auth\Permissions\PermissionApplicator;
use BookStack\Auth\User;
use BookStack\Entities\Models\BookChild;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
-use BookStack\Entities\Models\SearchTerm;
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
*
* @var string[]
*/
- protected $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!='];
+ protected array $queryOperators = ['<=', '>=', '=', '<', '>', 'like', '!='];
/**
* Retain a cache of score adjusted terms for specific search options.
<?php
-namespace BookStack\Entities\Models;
+namespace BookStack\Search;
use BookStack\Model;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
-use BookStack\Entities\Tools\SearchIndex;
+use BookStack\Search\SearchIndex;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
-use BookStack\Entities\Tools\SearchIndex;
+use BookStack\Search\SearchIndex;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
namespace Tests\Entity;
-use BookStack\Entities\Tools\SearchOptions;
+use BookStack\Search\SearchOptions;
use Tests\TestCase;
class SearchOptionsTest extends TestCase
-<?php namespace Tests;
+<?php
+
+namespace Tests;
use BookStack\Actions\Favourite;
use BookStack\Auth\User;