forked from oroinc/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroupSearchProvider.php
52 lines (43 loc) · 1.24 KB
/
GroupSearchProvider.php
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
<?php
namespace Oro\Bundle\ConfigBundle\Provider;
use Oro\Bundle\ConfigBundle\Config\ConfigBag;
use Oro\Bundle\ConfigBundle\Exception\ItemNotFoundException;
use Symfony\Component\Translation\TranslatorInterface;
class GroupSearchProvider implements SearchProviderInterface
{
/** @var ConfigBag */
private $configBag;
/** @var TranslatorInterface */
private $translator;
/**
* @param ConfigBag $configBag
* @param TranslatorInterface $translator
*/
public function __construct(ConfigBag $configBag, TranslatorInterface $translator)
{
$this->configBag = $configBag;
$this->translator = $translator;
}
/**
* {@inheritdoc}
*/
public function supports($name)
{
return $this->configBag->getGroupsNode($name) !== false;
}
/**
* {@inheritdoc}
*/
public function getData($name)
{
$group = $this->configBag->getGroupsNode($name);
if ($group === false) {
throw new ItemNotFoundException(sprintf('Group "%s" is not defined.', $name));
}
$searchData = [];
if (isset($group['title'])) {
$searchData[] = $this->translator->trans($group['title']);
}
return $searchData;
}
}