Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EmptyGroupCategory.php
Go to the documentation of this file.
1 <?php
8 
12 
17 {
23  private $collection;
24 
30  private $urlBuilder;
31 
37  private $items = null;
38 
43  public function __construct(
44  GroupCollection $collection,
45  UrlInterface $urlBuilder
46  ) {
47  $this->collection = $collection;
48  $this->urlBuilder = $urlBuilder;
49  }
50 
58  public function isDisplayed()
59  {
60  return !empty($this->getItems());
61  }
62 
66  public function getIdentity()
67  {
68  return 'empty_assigned_group_category';
69  }
70 
74  public function getText()
75  {
76  $items = $this->getItems();
77  $groupLinks = [];
78  foreach ($items as $group) {
79  $groupUrl = $this->urlBuilder->getUrl('adminhtml/system_store/editGroup', ['group_id' => $group->getId()]);
80  $groupLinks[] = sprintf('<a href="%s">%s</a>', $groupUrl, $group->getName());
81  }
82  return __(
83  'The following stores are not associated with a root category: '
84  . implode(', ', $groupLinks) . '. For the store to be displayed in the storefront, '
85  . 'it must be associated with a root category.'
86  );
87  }
88 
92  public function getSeverity()
93  {
94  return self::SEVERITY_MAJOR;
95  }
96 
102  private function getItems()
103  {
104  if (null === $this->items) {
105  $this->items = $this->collection->setWithoutAssignedCategoryFilter()->getItems();
106  }
107  return $this->items;
108  }
109 }
$group
Definition: sections.phtml:16
__()
Definition: __.php:13
__construct(GroupCollection $collection, UrlInterface $urlBuilder)