Skip to content

Commit 9316997

Browse files
committed
Move code to a separate file
1 parent d25766e commit 9316997

File tree

2 files changed

+53
-52
lines changed

2 files changed

+53
-52
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\EventSubscriber;
6+
7+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8+
use Symfony\Contracts\EventDispatcher\Event;
9+
10+
final class HelpMenuSubscriber implements EventSubscriberInterface
11+
{
12+
public function __construct(
13+
private readonly bool $kernelDebug
14+
) {}
15+
16+
public static function getSubscribedEvents(): array
17+
{
18+
return [
19+
'ibexa_integrated_help.menu_configure.help_menu' => 'onHelpMenuConfigure',
20+
];
21+
}
22+
23+
public function onHelpMenuConfigure(Event $event): void
24+
{
25+
$menu = $event->getMenu();
26+
27+
// Remove roadmap menu item
28+
if ($menu->getChild('help__general')) {
29+
$generalSection = $menu->getChild('help__general');
30+
if ($generalSection->getChild('help__product_roadmap')) {
31+
$generalSection->removeChild('help__product_roadmap');
32+
}
33+
}
34+
35+
// Add videos tab, shown only in production
36+
if ($this->kernelDebug === false) {
37+
$resourcesSection = $menu->addChild('help__videos', [
38+
'label' => 'Product videos',
39+
]);
40+
41+
$resourcesSection->addChild('help__webinar_v5', [
42+
'label' => 'Webinar: Introducing Ibexa DXP v5',
43+
'uri' => 'https://www.youtube.com/watch?v=qWaBHG2LRm8',
44+
'extras' => [
45+
'isHighlighted' => false,
46+
'icon' => 'https://doc.ibexa.co/en/5.0/templating/twig_function_reference/img/icons/video.svg.png',
47+
'description' => 'Discover new features and improvements brought by Ibexa DXP v5.',
48+
],
49+
]);
50+
}
51+
}
52+
}

docs/administration/back_office/customize_integrated_help.md

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -70,58 +70,7 @@ In this example, it removes a product roadmap entry from the menu and adds a hel
7070
The tab is displayed in a production environment only.
7171
7272
``` php
73-
<?php
74-
75-
declare(strict_types=1);
76-
77-
namespace App\EventSubscriber;
78-
79-
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
80-
use Symfony\Contracts\EventDispatcher\Event;
81-
82-
final class HelpMenuSubscriber implements EventSubscriberInterface
83-
{
84-
public function __construct(
85-
private readonly bool $kernelDebug
86-
) {}
87-
88-
public static function getSubscribedEvents(): array
89-
{
90-
return [
91-
'ibexa_integrated_help.menu_configure.help_menu' => 'onHelpMenuConfigure',
92-
];
93-
}
94-
95-
public function onHelpMenuConfigure(Event $event): void
96-
{
97-
$menu = $event->getMenu();
98-
99-
// Remove roadmap menu item
100-
if ($menu->getChild('help__general')) {
101-
$generalSection = $menu->getChild('help__general');
102-
if ($generalSection->getChild('help__product_roadmap')) {
103-
$generalSection->removeChild('help__product_roadmap');
104-
}
105-
}
106-
107-
// Add videos tab, shown only in production
108-
if ($this->kernelDebug === false) {
109-
$resourcesSection = $menu->addChild('help__videos', [
110-
'label' => 'Product videos',
111-
]);
112-
113-
$resourcesSection->addChild('help__webinar_v5', [
114-
'label' => 'Webinar: Introducing Ibexa DXP v5',
115-
'uri' => 'https://www.youtube.com/watch?v=qWaBHG2LRm8',
116-
'extras' => [
117-
'isHighlighted' => false,
118-
'icon' => 'https://doc.ibexa.co/en/5.0/templating/twig_function_reference/img/icons/video.svg.png',
119-
'description' => 'Discover new features and improvements brought by Ibexa DXP v5.',
120-
],
121-
]);
122-
}
123-
}
124-
}
73+
[[= include_file('code_samples/back_office/menu/menu_item/src/EventSubscriber/HelpMenuSubscriber.php') =]]
12574
```
12675

12776
!!! tip

0 commit comments

Comments
 (0)