} elseif (!
$book_link['bid'
]) { $form['#prefix'
] .= '<em>' .
$this->
t('No book selected.'
) . '</em>';
} else { $form =
[ '#type' => 'select',
'#title' =>
$this->
t('Parent item'
),
'#default_value' =>
$book_link['pid'
],
'#description' =>
$this->
t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.',
['@maxdepth' =>
static::BOOK_MAX_DEPTH
]),
'#options' =>
$this->
getTableOfContents($book_link['bid'
],
$book_link['parent_depth_limit'
],
[$book_link['nid'
]]),
'#attributes' =>
['class' =>
['book-title-select'
]],
'#prefix' => '<div id="edit-book-plid-wrapper">',
'#suffix' => '</div>',
];
} $this->renderer->
addCacheableDependency($form,
$config);
return $form;
} /**
* Recursively processes and formats book links for getTableOfContents().
*
* This helper function recursively modifies the table of contents array for
* each item in the book tree, ignoring items in the exclude array or at a
* depth greater than the limit. Truncates titles over thirty characters and
* appends an indentation string incremented by depth.
*
* @param array $tree
* The data structure of the book's outline tree. Includes hidden links.
* @param string $indent
* A string appended to each node title. Increments by '--' per depth
* level.
* @param array $toc
* Reference to the table of contents array. This is modified in place, so
* the function does not have a return value.
* @param array $exclude
* Optional array of Node ID values. Any link whose node ID is in this
* array will be excluded (along with its children).
* @param int $depth_limit
* Any link deeper than this value will be excluded (along with its
* children).
*/