Skip to content

Commit

Permalink
Add setter/getter to set empty state message
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Oct 24, 2024
1 parent e0918eb commit 14dd9cc
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/Common/BaseItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ abstract class BaseItemList extends BaseHtmlElement

protected $tag = 'ul';

/** @var ?string Message when the list is empty */
protected $emptyStateMessage;

/**
* Create a new item list
*
Expand Down Expand Up @@ -76,6 +79,34 @@ protected function createListItem(object $data)
return new $className($data, $this);

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.

Check failure on line 79 in src/Common/BaseItemList.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Method ipl\Web\Common\BaseItemList::createListItem() should return ipl\Web\Common\BaseListItem|ipl\Web\Common\BaseTableRowItem but returns object.
}

/**
* Get message to show for empty list
*
* @return string
*/
public function getEmptyStateMessage(): string
{
if ($this->emptyStateMessage === null) {
return t('No items found.');
}

return $this->emptyStateMessage;
}

/**
* Set message for empty list
*
* @param string $message
*
* @return $this
*/
public function setEmptyStateMessage(string $message): self
{
$this->emptyStateMessage = $message;

return $this;
}

protected function assemble(): void
{
foreach ($this->data as $data) {
Expand All @@ -87,7 +118,7 @@ protected function assemble(): void

if ($this->isEmpty()) {
$this->setTag('div');
$this->addHtml(new EmptyStateBar(t('No items found.')));
$this->addHtml(new EmptyStateBar($this->getEmptyStateMessage()));
}
}
}

0 comments on commit 14dd9cc

Please sign in to comment.