Files
BookStack/app/View/ViewBlocks/BooksShowDetails.php
T
Dan Brown 01b29515c8 Layouts: Updated view block ids/labels to be static
So that their metadata can be read without having to create instances
and fullfill dependancy injection just to list.

Also added title to interface prefs page.
2026-08-16 10:41:43 +01:00

35 lines
994 B
PHP

<?php
namespace BookStack\View\ViewBlocks;
use BookStack\Activity\Tools\UserEntityWatchOptions;
use BookStack\Entities\Models\Book;
use BookStack\References\ReferenceFetcher;
use BookStack\View\ViewBlock;
use Illuminate\Http\Request;
class BooksShowDetails extends ViewBlock
{
protected static string $id = 'builtin_books-show-details';
protected static string $view = 'books.parts.show-sidebar-section-details';
protected static string $labelTranslationKey = 'common.details';
public function __construct(
protected ReferenceFetcher $referenceFetcher,
) {
}
public function withData(array $viewData): array
{
/** @var Book $book */
$book = $viewData['book'];
$referenceCount = $this->referenceFetcher->getReferenceCountToEntity($book);
return [
'book' => $book,
'watchOptions' => new UserEntityWatchOptions(user(), $book),
'referenceCount' => $referenceCount,
];
}
}