Skip to content
Snippets Groups Projects
Commit 9fee24c5 authored by Nejc Koporec's avatar Nejc Koporec
Browse files

If no spaces, prompt the user to create one

parent 94d44090
Branches
No related tags found
No related merge requests found
......@@ -53,13 +53,31 @@ class SpaceListBuilder extends EntityListBuilder {
* {@inheritdoc}
*/
public function render() {
$build['table'] = parent::render();
$build = parent::render();
$build['table']['#empty'] = $this->t(
"No spaces available, please <a href='@link'>create a new space.</a>",
[
'@link' => Url::fromUserInput('/space/add')->toString(),
]
);
$total = $this->getStorage()
->getQuery()
->accessCheck(FALSE)
->count()
->execute();
->execute();
if (!$total) {
$this->messenger()->addWarning(
$this->t(
"No spaces available, please <a href='@link'>create a new space.</a>",
[
'@link' => Url::fromUserInput('/space/add')->toString(),
]
)
);
}
$build['summary']['#markup'] = $this->t('Total spaces: @total', ['@total' => $total]);
$build['summary']['#weight'] = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment