|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\SalesBundle\Autocomplete; |
|
4
|
|
|
|
|
5
|
|
|
use Oro\Bundle\FormBundle\Autocomplete\SearchHandler; |
|
6
|
|
|
use Oro\Bundle\OrganizationBundle\Provider\BusinessUnitAclProvider; |
|
7
|
|
|
|
|
8
|
|
|
class ForecastWidgetBusinessUnitSearchHandler extends SearchHandler |
|
9
|
|
|
{ |
|
10
|
|
|
/** @var BusinessUnitAclProvider */ |
|
11
|
|
|
protected $businessUnitAclProvider; |
|
12
|
|
|
|
|
13
|
|
|
/** @var string */ |
|
14
|
|
|
protected $opportunityClassName; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param string $entityName |
|
18
|
|
|
* @param array $properties |
|
19
|
|
|
* @param BusinessUnitAclProvider $businessUnitAclProvider |
|
20
|
|
|
* @param string $opportunityClassName |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct( |
|
23
|
|
|
$entityName, |
|
24
|
|
|
$properties, |
|
25
|
|
|
BusinessUnitAclProvider $businessUnitAclProvider, |
|
26
|
|
|
$opportunityClassName |
|
27
|
|
|
) { |
|
28
|
|
|
parent::__construct($entityName, $properties); |
|
29
|
|
|
$this->businessUnitAclProvider = $businessUnitAclProvider; |
|
30
|
|
|
$this->opportunityClassName = $opportunityClassName; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $search |
|
35
|
|
|
* @param int $firstResult |
|
36
|
|
|
* @param int $maxResults |
|
37
|
|
|
* @return array |
|
38
|
|
|
*/ |
|
39
|
|
|
protected function searchIds($search, $firstResult, $maxResults) |
|
40
|
|
|
{ |
|
41
|
|
|
$ids = []; |
|
42
|
|
|
$allowedBusinessUnitIds = $this |
|
43
|
|
|
->businessUnitAclProvider |
|
44
|
|
|
->getBusinessUnitIds($this->opportunityClassName, 'VIEW'); |
|
45
|
|
|
|
|
46
|
|
|
if (!is_array($allowedBusinessUnitIds) || count($allowedBusinessUnitIds) === 0) { |
|
47
|
|
|
return $ids; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$this->indexer->setIsAllowedApplyAcl(false); |
|
|
|
|
|
|
51
|
|
|
$result = $this->indexer->simpleSearch($search, $firstResult, $maxResults, $this->entitySearchAlias); |
|
52
|
|
|
$elements = $result->getElements(); |
|
53
|
|
|
|
|
54
|
|
|
foreach ($elements as $element) { |
|
55
|
|
|
if (in_array($element->getRecordId(), $allowedBusinessUnitIds, true)) { |
|
56
|
|
|
$ids[] = $element->getRecordId(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return $ids; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.