-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCalendarEventGridHelper.php
43 lines (36 loc) · 1.26 KB
/
CalendarEventGridHelper.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
<?php
namespace Oro\Bundle\CalendarBundle\Datagrid;
use Oro\Bundle\CalendarBundle\Manager\CalendarEvent\NotificationManager;
use Oro\Bundle\DataGridBundle\Datasource\ResultRecord;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Provides a method to build URL to be used to delete calendar event.
*/
class CalendarEventGridHelper
{
/** @var UrlGeneratorInterface */
private $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}
public function getDeleteLinkProperty(string $gridName, string $keyName, array $node): callable
{
if (!isset($node['route'])) {
throw new \InvalidArgumentException(sprintf(
'Cannot build callable fo grid "%s" because the "route" option is mandatory.',
$gridName
));
}
$route = $node['route'];
return function (ResultRecord $record) use ($route) {
return $this->urlGenerator->generate(
$route,
[
'id' => $record->getValue('id'),
'notifyAttendees' => NotificationManager::ALL_NOTIFICATIONS_STRATEGY,
]
);
};
}
}