Skip to content

Commit 182451d

Browse files
committed
Fix PHP code samples
1 parent c72a5c4 commit 182451d

298 files changed

Lines changed: 2263 additions & 986 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code_samples/api/public_php_api/src/Command/SegmentCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6464
: 'The user is not assigned to the segment.'
6565
));
6666

67+
$this->segmentationService->removeSegmentGroup($segmentGroup);
68+
6769
return self::SUCCESS;
6870
}
6971
}

deptrac.baseline.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
deptrac:
22
skip_violations:
3+
AcmeFeatureBundle:
4+
- Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension
35
App\AutomatedTranslation\ImageFieldEncoder:
46
- Ibexa\Core\FieldType\Image\Value
57
App\Block\Listener\MyBlockListener:
@@ -92,6 +94,9 @@ deptrac:
9294
- Ibexa\Core\MVC\Symfony\View\View
9395
App\Controller\RelationController:
9496
- Ibexa\Core\MVC\Symfony\View\View
97+
App\Controller\RideController:
98+
- Ibexa\Bundle\Core\Controller
99+
- Ibexa\Core\MVC\Symfony\View\ContentView
95100
App\Controller\SvgController:
96101
- Ibexa\Core\Helper\TranslationHelper
97102
- Ibexa\Core\IO\IOServiceInterface
@@ -130,13 +135,19 @@ deptrac:
130135
- Ibexa\FormBuilder\Event\FormEvents
131136
App\EventSubscriber\HelpMenuSubscriber:
132137
- Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent
138+
App\EventSubscriber\LoginFormViewSubscriber:
139+
- Ibexa\Core\MVC\Symfony\Event\PreContentViewEvent
140+
- Ibexa\Core\MVC\Symfony\MVCEvents
141+
- Ibexa\Core\MVC\Symfony\View\LoginFormView
133142
App\EventSubscriber\MyMenuSubscriber:
134143
- Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent
135144
- Ibexa\AdminUi\Menu\MainMenuBuilder
136145
App\EventSubscriber\NotificationScenarioSubscriber:
137146
- Ibexa\IntegratedHelp\ProductTour\Block\LinkBlock
138147
- Ibexa\IntegratedHelp\ProductTour\Block\TextBlock
139148
- Ibexa\IntegratedHelp\ProductTour\ProductTourStep
149+
App\EventSubscriber\ResolveCampaginEventSubscriber:
150+
- Ibexa\ConnectorActito\Campaign\Campaign
140151
App\Event\RandomBlockListener:
141152
- Ibexa\FieldTypePage\FieldType\Page\Block\Renderer\BlockRenderEvents
142153
- Ibexa\FieldTypePage\FieldType\Page\Block\Renderer\Event\PreRenderEvent
@@ -194,6 +205,8 @@ deptrac:
194205
- Ibexa\Migration\ValueObject\Step\StepInterface
195206
App\Migrations\Step\ReplaceNameStepNormalizer:
196207
- Ibexa\Migration\ValueObject\Step\StepInterface
208+
App\MyService:
209+
- Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface
197210
App\Notification\ListRenderer:
198211
- Ibexa\Core\Notification\Renderer\NotificationRenderer
199212
- Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface
@@ -212,6 +225,8 @@ deptrac:
212225
App\QueryType\OptionsBasedLatestContentQueryType:
213226
- Ibexa\Core\QueryType\OptionsResolverBasedQueryType
214227
- Ibexa\Core\QueryType\QueryType
228+
App\QueryType\RideQueryType:
229+
- Ibexa\Core\QueryType\QueryType
215230
App\Search\Model\Suggestion\ProductSuggestion:
216231
- Ibexa\ProductCatalog\Local\Repository\Values\Product
217232
App\Security\FormPolicyProvider:
@@ -236,6 +251,8 @@ deptrac:
236251
- Ibexa\AdminUi\Limitation\LimitationValueMapperInterface
237252
App\Security\MyPolicyProvider:
238253
- Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider
254+
App\Service\MyService:
255+
- Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface
239256
App\Setting\Group\MyGroup:
240257
- Ibexa\User\UserSetting\Group\AbstractGroup
241258
App\Setting\Unit:
@@ -254,3 +271,9 @@ deptrac:
254271
- Ibexa\Core\MVC\Symfony\View\View
255272
AttributeTypeExtension:
256273
- Ibexa\PageBuilder\Form\Type\Attribute\AttributeType
274+
CustomRepositoryConfigParser:
275+
- Ibexa\Bundle\Core\DependencyInjection\Configuration\RepositoryConfigParserInterface
276+
JohnDoeCanSelectMore:
277+
- Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent
278+
MyMapper:
279+
- Ibexa\ContentForms\Form\Type\FieldType\CheckboxFieldType

docs/administration/back_office/back_office_elements/extending_thumbnails.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ It enables you to add a thumbnail URL in the text field.
7474

7575
Add `FieldValueUrl.php` in `src/Thumbnails`.
7676

77-
``` php {skip-validation}
77+
``` php
7878
<?php
7979

8080
declare(strict_types=1);
8181

8282
namespace App\Thumbnails;
8383

84+
use Ibexa\Contracts\Core\Repository\Strategy\ContentThumbnail\Field\FieldTypeBasedThumbnailStrategy;
8485
use Ibexa\Contracts\Core\Repository\Values\Content\Field;
8586
use Ibexa\Contracts\Core\Repository\Values\Content\Thumbnail;
86-
use Ibexa\Contracts\Core\Repository\Strategy\ContentThumbnail\Field\FieldTypeBasedThumbnailStrategy;
8787
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
8888

8989
class FieldValueUrl implements FieldTypeBasedThumbnailStrategy

docs/administration/back_office/back_office_elements/formatting_date_and_time.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ You can format date and time by using the following services:
1919

2020
To use them, create an `src/Service/MyService.php` file containing:
2121

22-
``` php {skip-validation}
22+
``` php
2323
<?php
2424

2525
namespace App\Service;
@@ -28,19 +28,12 @@ use Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface;
2828

2929
class MyService
3030
{
31-
/** @var \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface */
32-
private $shortDateTimeFormatter;
33-
34-
public function __construct(FormatterInterface $shortDateTimeFormatter)
31+
public function __construct(private readonly FormatterInterface $shortDateTimeFormatter)
3532
{
3633
// your code
37-
38-
$this->shortDateTimeFormatter = $shortDateTimeFormatter;
39-
40-
// your code
4134
}
4235

43-
public function foo()
36+
public function foo(): void
4437
{
4538
// your code
4639

docs/administration/back_office/back_office_menus/back_office_menus.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ The following method adds a new menu section under **Content**, and under it, a
8585

8686
You can also pass parameters to templates used to render menu items with `template_parameters`:
8787

88-
``` php {skip-validation}
88+
``` php
89+
/** @var \Knp\Menu\ItemInterface $menu */
8990
$menu->addChild(
9091
'all_content_list',
9192
[
@@ -105,7 +106,8 @@ You can then use the variable `custom_parameter` in `templates/themes/admin/list
105106

106107
To have translatable labels, use `translation.key` from the `messages` domain:
107108

108-
``` php {skip-validation}
109+
``` php
110+
/** @var \Knp\Menu\ItemInterface $menu */
109111
$menu->addChild(
110112
'all_content_list',
111113
[

docs/administration/back_office/browser/browser.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,40 +146,42 @@ If an event listener catches additional parameters passed with context, it uses
146146

147147
In the example below, the `johndoe` parameter enables the user to choose multiple items from a **Browser window** by changing `multiple: false` from `my_custom_udw` configuration to `multiple: true`.
148148

149-
``` php {skip-validation} hl_lines="29 30 31"
149+
``` php hl_lines="31-35"
150+
<?php
151+
152+
use Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent;
153+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
154+
150155
class JohnDoeCanSelectMore implements EventSubscriberInterface
151156
{
152-
private const CONFIGURATION_NAME = 'my_custom_udw';
157+
private const string CONFIGURATION_NAME = 'my_custom_udw';
153158
154159
/**
155160
* Returns an array of event names this subscriber wants to listen to.
156161
*
157-
* @return array The event names to listen to
162+
* @return array<string, string> The event names to listen to
158163
*/
159-
public static function getSubscribedEvents()
164+
public static function getSubscribedEvents(): array
160165
{
161166
return [
162167
ConfigResolveEvent::NAME => 'onUdwConfigResolve',
163168
];
164169
}
165170
166-
/**
167-
* @param \Ibexa\AdminUi\UniversalDiscovery\Event $event
168-
*/
169-
public function onUdwConfigResolve(ConfigResolveEvent $event)
171+
public function onUdwConfigResolve(ConfigResolveEvent $event): void
170172
{
171173
if ($event->getConfigName() !== self::CONFIGURATION_NAME) {
172-
return;
173-
}
174+
return;
175+
}
174176
175177
$config = $event->getConfig();
176-
$context = $event->getContext();
178+
$context = $event->getContext();
177179
178180
if (isset($context['some_contextual_parameter'])) {
179-
if ($context['some_contextual_parameter'] === 'johndoe') {
180-
$config['multiple'] = true;
181-
}
182-
}
181+
if ($context['some_contextual_parameter'] === 'johndoe') {
182+
$config['multiple'] = true;
183+
}
184+
}
183185
184186
$event->setConfig($config);
185187
}

docs/administration/back_office/customize_calendar.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ To add an in-memory collection as an event source, create `src/Calendar/Holidays
8080

8181
For example:
8282

83-
``` php {skip-validation}
83+
``` php
84+
use App\Calendar\Holidays\Event;
85+
use Ibexa\Contracts\Calendar\EventCollection;
86+
87+
/** @var \App\Calendar\Holidays\EventType $eventType */
8488
$collection = new EventCollection([
85-
$this->createEvent("Event 1", new DateTime("2024-01-01")),
86-
$this->createEvent("Event 2", new DateTime("2024-01-02")),
89+
new Event('Event 1', new DateTime('2024-01-01'), $eventType),
90+
new Event('Event 2', new DateTime('2024-01-02'), $eventType),
8791
// ...
92+
]);
8893
```
8994

9095
Next, register the event source as a service:

docs/administration/back_office/notifications.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ There are four types of notifications: `info`, `success`, `warning` and `error`.
2525

2626
To send a notification from PHP, inject the `TranslatableNotificationHandlerInterface` into your class.
2727

28-
``` php {skip-validation}
29-
$this->notificationHandler->info(
28+
``` php
29+
/** @var \Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface $notificationHandler */
30+
$notificationHandler->info(
3031
/** @Desc("Notification text") */
3132
'example.notification.text',
3233
[],

docs/administration/configuration/configuration.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ parameters:
7272
an_array: [apple, banana, pear]
7373
```
7474
75-
``` php {skip-validation}
75+
``` php
7676
// Usage inside a controller
77-
$myParameter = $this->container->getParameter( 'myapp.parameter.name' );
77+
/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */
78+
$myParameter = $container->getParameter('myapp.parameter.name');
7879
```
7980

8081
## Configuration settings

docs/administration/configuration/dynamic_configuration.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ parameters:
2727
myapp.default.my_param: Default value
2828
```
2929
30-
Inside a controller, in `site_group` SiteAccess, you can use the parameters in the following way (the same applies for `hasParameter()`):
30+
Inside a controller extending the `Ibexa\Core\MVC\Symfony\Controller\Controller` class, in `site_group` SiteAccess, you can use the parameters in the following way (the same applies for `hasParameter()`):
3131

3232
``` php {skip-validation}
3333
$configResolver = $this->getConfigResolver();
34-
 
34+
3535
// ibexa.site_access.config is the default namespace, so no need to specify it
3636
// The following will resolve ibexa.site_access.config.<siteaccessName>.content.default_ttl
3737
// In the case of site_group, it will return 3600.
@@ -77,24 +77,18 @@ For more information about dependency injection, see [Service container](php_api
7777
Don't store the retrieved config value unless you know what you're doing.
7878
SiteAccess can change during code execution, which means you might work on the wrong value.
7979

80-
``` php {skip-validation}
80+
``` php
8181
namespace App;
8282
8383
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
84-
 
84+
8585
class Service
8686
{
87-
 /**
88-
* @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface
89-
*/
90-
private $configResolver;
91-
 
92-
public function __construct( ConfigResolverInterface $configResolver )
87+
public function __construct(private readonly ConfigResolverInterface $configResolver)
9388
{
94-
$this->configResolver = $configResolver;
9589
}
9690
97-
public function someMethodThatNeedConfig()
91+
public function someMethodThatNeedConfig(): void
9892
{
9993
$configValue = $this->configResolver->getParameter('my_param', 'myapp');
10094
}

0 commit comments

Comments
 (0)