1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Indexer\Model\Message;
/**
* Message about invalid indexers.
*/
class Invalid implements \Magento\Framework\Notification\MessageInterface
{
/**
* @var \Magento\Indexer\Model\Indexer\Collection
*/
protected $collection;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;
/**
* @param \Magento\Indexer\Model\Indexer\Collection $collection
* @param \Magento\Framework\UrlInterface $urlBuilder
*/
public function __construct(
\Magento\Indexer\Model\Indexer\Collection $collection,
\Magento\Framework\UrlInterface $urlBuilder
) {
$this->collection = $collection;
$this->urlBuilder = $urlBuilder;
}
/**
* Check whether all indices are valid or not
*
* @return bool
*/
public function isDisplayed()
{
/** @var \Magento\Indexer\Model\Indexer $indexer */
foreach ($this->collection->getItems() as $indexer) {
if ($indexer->getStatus() == \Magento\Framework\Indexer\StateInterface::STATUS_INVALID) {
return true;
}
}
return false;
}
//@codeCoverageIgnoreStart
/**
* Retrieve unique message identity
*
* @return string
*/
public function getIdentity()
{
return md5('INDEX_INVALID');
}
/**
* Retrieve message text
*
* @return \Magento\Framework\Phrase
*/
public function getText()
{
$url = $this->urlBuilder->getUrl('indexer/indexer/list');
//@codingStandardsIgnoreStart
return __(
'One or more <a href="%1">indexers are invalid</a>. Make sure your <a href="%2" target="_blank">Magento cron job</a> is running.',
$url,
'https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-cron.html#create-or-remove-the-magento-crontab'
);
//@codingStandardsIgnoreEnd
}
/**
* Retrieve message severity
*
* @return int
*/
public function getSeverity()
{
return self::SEVERITY_MAJOR;
}
//@codeCoverageIgnoreEnd
}