Skip to content

Commit

Permalink
Update book module method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Feb 7, 2025
1 parent 6dee16c commit 0a21fa5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/Form/StanfordFieldBookAdminEditForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StanfordFieldBookAdminEditForm extends BookAdminEditForm {
/**
* {@inheritDoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) {
public function buildForm(array $form, FormStateInterface $form_state, ?NodeInterface $node = NULL): array {
$form = parent::buildForm($form, $form_state, $node);
foreach (Element::children($form['table']) as $key) {
if (isset($form['table'][$key]['#nid'])) {
Expand All @@ -31,7 +31,7 @@ public function buildForm(array $form, FormStateInterface $form_state, NodeInter
/**
* {@inheritDoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
public function submitForm(array &$form, FormStateInterface $form_state): void {
foreach (Element::children($form['table']) as $key) {
if (isset($form['table'][$key]['#nid'])) {
$page_title = $form['table'][$key]['title']['#markup'];
Expand Down
50 changes: 25 additions & 25 deletions src/Service/StanfordFieldsBookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ public function __construct(protected BookManagerInterface $bookManager, protect
/**
* {@inheritdoc}
*/
public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) {
return $this->bookManager->bookTreeAllData($bid, $link, $max_depth);
public function bookTreeAllData(int $bid, ?array $link = NULL, ?int $max_depth = NULL, ?int $min_depth = NULL): array {
return $this->bookManager->bookTreeAllData($bid, $link, $max_depth, $min_depth);
}

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function getActiveTrailIds($bid, $link) {
public function getActiveTrailIds(string $bid, array $link): array {
return $this->bookManager->getActiveTrailIds($bid, $link);
}

Expand All @@ -59,7 +59,7 @@ public function getActiveTrailIds($bid, $link) {
*
* @codeCoverageIgnore
*/
public function loadBookLink($nid, $translate = TRUE) {
public function loadBookLink(int $nid, bool $translate = TRUE): array {
return $this->bookManager->loadBookLink($nid, $translate);
}

Expand All @@ -68,7 +68,7 @@ public function loadBookLink($nid, $translate = TRUE) {
*
* @codeCoverageIgnore
*/
public function loadBookLinks($nids, $translate = TRUE) {
public function loadBookLinks(array $nids, bool $translate = TRUE): array {
return $this->bookManager->loadBookLinks($nids, $translate);
}

Expand All @@ -77,16 +77,16 @@ public function loadBookLinks($nids, $translate = TRUE) {
*
* @codeCoverageIgnore
*/
public function getTableOfContents($bid, $depth_limit, array $exclude = []) {
return $this->bookManager->getTableOfContents($bid, $depth_limit, $exclude);
public function getTableOfContents(int|string $bid, int $depth_limit, array $exclude = [], bool $truncate = TRUE): array {
return $this->bookManager->getTableOfContents($bid, $depth_limit, $exclude, $truncate);
}

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function getParentDepthLimit(array $book_link) {
public function getParentDepthLimit(array $book_link): int {
return $this->bookManager->getParentDepthLimit($book_link);
}

Expand All @@ -95,16 +95,16 @@ public function getParentDepthLimit(array $book_link) {
*
* @codeCoverageIgnore
*/
public function bookTreeCollectNodeLinks(&$tree, &$node_links) {
return $this->bookManager->bookTreeCollectNodeLinks($tree, $node_links);
public function bookTreeCollectNodeLinks(array &$tree, array &$node_links): void{
$this->bookManager->bookTreeCollectNodeLinks($tree, $node_links);
}

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function bookLinkTranslate(&$link) {
public function bookLinkTranslate(array &$link): array{
return $this->bookManager->bookLinkTranslate($link);
}

Expand All @@ -113,7 +113,7 @@ public function bookLinkTranslate(&$link) {
*
* @codeCoverageIgnore
*/
public function bookTreeGetFlat(array $book_link) {
public function bookTreeGetFlat(array $book_link): array{
return $this->bookManager->bookTreeGetFlat($book_link);
}

Expand All @@ -122,14 +122,14 @@ public function bookTreeGetFlat(array $book_link) {
*
* @codeCoverageIgnore
*/
public function getAllBooks() {
public function getAllBooks(): array {
return $this->bookManager->getAllBooks();
}

/**
* {@inheritdoc}
*/
public function updateOutline(NodeInterface $node) {
public function updateOutline(NodeInterface $node): bool {
if (isset($node->book['weight'])) {

// Before saving the node, look at the book weight data . The weight has
Expand Down Expand Up @@ -177,7 +177,7 @@ public function updateOutline(NodeInterface $node) {
*
* @codeCoverageIgnore
*/
public function saveBookLink(array $link, $new) {
public function saveBookLink(array $link, bool $new): array {
return $this->bookManager->saveBookLink($link, $new);
}

Expand All @@ -186,7 +186,7 @@ public function saveBookLink(array $link, $new) {
*
* @codeCoverageIgnore
*/
public function getLinkDefaults($nid) {
public function getLinkDefaults(int|string $nid): array {
return $this->bookManager->getLinkDefaults($nid);
}

Expand All @@ -195,7 +195,7 @@ public function getLinkDefaults($nid) {
*
* @codeCoverageIgnore
*/
public function getBookParents(array $item, array $parent = []) {
public function getBookParents(array $item, array $parent = []): array {
return $this->bookManager->getBookParents($item, $parent);
}

Expand All @@ -217,7 +217,7 @@ protected function nodeAllowedInBook(NodeInterface $node): bool {
/**
* {@inheritdoc}
*/
public function addFormElements(array $form, FormStateInterface $form_state, NodeInterface $node, AccountInterface $account, $collapsed = TRUE) {
public function addFormElements(array $form, FormStateInterface $form_state, NodeInterface $node, AccountInterface $account, bool $collapsed = TRUE): array {
// The book module will add the book settings to all node types for admins,
// which makes it annoying. This checks the node against the settings
// instead of only the 'administer book outlines' permission.
Expand Down Expand Up @@ -433,16 +433,16 @@ public static function parentChosen(array &$form, FormStateInterface $form_state
*
* @codeCoverageIgnore
*/
public function deleteFromBook($nid) {
return $this->bookManager->deleteFromBook($nid);
public function deleteFromBook(int $nid): void {
$this->bookManager->deleteFromBook($nid);
}

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function bookTreeOutput(array $tree) {
public function bookTreeOutput(array $tree): array {
return $this->bookManager->bookTreeOutput($tree);
}

Expand All @@ -451,16 +451,16 @@ public function bookTreeOutput(array $tree) {
*
* @codeCoverageIgnore
*/
public function bookTreeCheckAccess(&$tree, $node_links = []) {
return $this->bookManager->bookTreeCheckAccess($tree, $node_links);
public function bookTreeCheckAccess(array &$tree, array $node_links = []): void {
$this->bookManager->bookTreeCheckAccess($tree, $node_links);
}

/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function bookSubtreeData($link) {
public function bookSubtreeData(array $link): array{
return $this->bookManager->bookSubtreeData($link);
}

Expand All @@ -469,7 +469,7 @@ public function bookSubtreeData($link) {
*
* @codeCoverageIgnore
*/
public function checkNodeIsRemovable(NodeInterface $node) {
public function checkNodeIsRemovable(NodeInterface $node): bool {
return $this->bookManager->checkNodeIsRemovable($node);
}

Expand Down

0 comments on commit 0a21fa5

Please sign in to comment.