-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathUserEditRightSidebarBuilder.php
More file actions
86 lines (76 loc) · 2.74 KB
/
Copy pathUserEditRightSidebarBuilder.php
File metadata and controls
86 lines (76 loc) · 2.74 KB
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
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\AdminUi\Menu;
use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent;
use Ibexa\Contracts\AdminUi\Menu\AbstractBuilder;
use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions;
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Knp\Menu\ItemInterface;
/**
* KnpMenuBundle Menu Builder service implementation for AdminUI Content Edit contextual sidebar menu.
*
* @see https://symfony.com/doc/current/bundles/KnpMenuBundle/menu_builder_service.html
*/
class UserEditRightSidebarBuilder extends AbstractBuilder implements TranslationContainerInterface
{
/* Menu items */
public const ITEM__UPDATE = 'user_edit__sidebar_right__update';
public const ITEM__CANCEL = 'user_edit__sidebar_right__cancel';
/**
* @return string
*/
protected function getConfigureEventName(): string
{
return ConfigureMenuEvent::USER_EDIT_SIDEBAR_RIGHT;
}
/**
* @param array $options
*
* @return \Knp\Menu\ItemInterface
*
* @throws \InvalidArgumentException
* @throws ApiExceptions\BadStateException
* @throws \InvalidArgumentException
*/
public function createStructure(array $options): ItemInterface
{
/** @var \Knp\Menu\ItemInterface|\Knp\Menu\ItemInterface[] $menu */
$menu = $this->factory->createItem('root');
$menu->setChildren([
self::ITEM__UPDATE => $this->createMenuItem(
self::ITEM__UPDATE,
[
'attributes' => [
'class' => 'ibexa-btn--trigger',
'data-click' => '#ezplatform_content_forms_user_update_update',
],
]
),
self::ITEM__CANCEL => $this->createMenuItem(
self::ITEM__CANCEL,
[
'attributes' => [
'class' => 'ibexa-btn--trigger',
'data-click' => '#ezplatform_content_forms_user_update_cancel',
],
]
),
]);
return $menu;
}
/**
* @return \JMS\TranslationBundle\Model\Message[]
*/
public static function getTranslationMessages(): array
{
return [
(new Message(self::ITEM__UPDATE, 'ibexa_menu'))->setDesc('Save and close'),
(new Message(self::ITEM__CANCEL, 'ibexa_menu'))->setDesc('Discard changes'),
];
}
}
class_alias(UserEditRightSidebarBuilder::class, 'EzSystems\EzPlatformAdminUi\Menu\UserEditRightSidebarBuilder');