Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ yarn.lock
docs/css/*.map
.deptrac.cache
.phpunit.result.cache
code_samples/_inline_php/
15 changes: 15 additions & 0 deletions .php-cs-fixer-factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;

$commonRules = [
'header_comment' => false,
];

return [new InternalConfigFactory(), $commonRules];
29 changes: 29 additions & 0 deletions .php-cs-fixer-inline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

/**
* PHP-CS-Fixer configuration for auto-generated inline snippets in code_samples/_inline_php/.
*
* Builds on top of the shared factory with additional rule overrides:
* - psr_autoloading is disabled: snippet files are named line_N.php and do not
* correspond to any class, so the filename≠class-name rule does not apply.
*/
[$configFactory, $commonRules] = require __DIR__ . '/.php-cs-fixer-factory.php';

$configFactory->withRules(array_merge($commonRules, [
'psr_autoloading' => false,
'AdamWojs/phpdoc_force_fqcn_fixer' => false,
]));

return $configFactory
->buildConfig()
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/code_samples/_inline_php')
->files()->name('*.php')
);
8 changes: 3 additions & 5 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
*/
declare(strict_types=1);

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;
[$configFactory, $commonRules] = require __DIR__ . '/.php-cs-fixer-factory.php';

$configFactory = new InternalConfigFactory();
$configFactory->withRules([
'header_comment' => false,
]);
$configFactory->withRules($commonRules);

return $configFactory
->buildConfig()
Expand All @@ -23,5 +20,6 @@
__DIR__ . '/tests',
], 'is_dir')
)
->exclude('_inline_php') // handled separately by .php-cs-fixer-inline.php
->files()->name('*.php')
);
25 changes: 20 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,25 @@
"ibexa/fastly": "~5.0.x-dev"
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"check-cs": "@fix-cs --dry-run",
"phpstan": "phpstan analyse",
"deptrac": "deptrac analyse",
"check-rector": "rector process --dry-run --ansi",
"fix-cs": [
"php tools/extract-inline-php.php",
"php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"php-cs-fixer fix --config=.php-cs-fixer-inline.php -v --show-progress=dots",
"php tools/sync-inline-php-to-markdown.php"
],
"check-cs": [
"php tools/extract-inline-php.php",
"php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots --dry-run",
"php-cs-fixer fix --config=.php-cs-fixer-inline.php -v --show-progress=dots --dry-run"
],
"phpstan": "php tools/extract-inline-php.php && phpstan analyse",
"deptrac": "php tools/extract-inline-php.php && deptrac analyse",
"fix-rector": [
"php tools/extract-inline-php.php",
"rector process --ansi",
"php tools/sync-inline-php-to-markdown.php"
],
"check-rector": "php tools/extract-inline-php.php && rector process --dry-run --ansi",
"check-yaml": "phpunit --group yaml",
"phpunit": "phpunit --exclude-group=yaml",
"yaml-update-baseline": "php tests/generate-yaml-baseline.php"
Expand All @@ -116,6 +130,7 @@
"check-cs": "Run code style checker for all files",
"phpstan": "Run static code analysis",
"deptrac": "Run Deptrac architecture testing",
"fix-rector": "Automatically applies Rector refactoring to code samples and syncs back to Markdown",
"check-rector": "Check for code refactoring opportunities",
"check-yaml": "Run PHPUnit tests (YAML validation)",
"yaml-update-baseline": "Regenerate tests/yaml-validation-baseline.yaml from current failures"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This mechanism can be modified to fit your site needs, so you can decide from wh
First, create base strategy for returning custom thumbnails from a static file.
Create `StaticStrategy.php` in `src/Strategy`.

```php
``` php
[[= include_code('code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php') =]]
```

Expand Down Expand Up @@ -74,7 +74,7 @@ It enables you to add a thumbnail URL in the text field.

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

```php
``` php {skip-validation}
<?php

declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can format date and time by using the following services:

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

``` php
``` php {skip-validation}
<?php

namespace App\Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The following method adds a new menu section under **Content**, and under it, a

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

``` php
``` php {skip-validation}
$menu->addChild(
'all_content_list',
[
Expand All @@ -105,7 +105,7 @@ You can then use the variable `custom_parameter` in `templates/themes/admin/list

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

``` php
``` php {skip-validation}
$menu->addChild(
'all_content_list',
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A custom tab can extend one of the following classes:
- [`AbstractControllerBasedTab`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-AdminUi-Tab-AbstractControllerBasedTab.html) - embeds the results of a controller action in the tab
- [`AbstractRouteBasedTab`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-AdminUi-Tab-AbstractRouteBasedTab.html) - embeds the results of the selected route, passing applicable parameters

``` php
``` php {skip-validation}
//...
[[= include_file('code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php', 16, 18) =]]
//...
Expand Down
2 changes: 1 addition & 1 deletion docs/administration/back_office/browser/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ If an event listener catches additional parameters passed with context, it uses

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`.

```php hl_lines="29 30 31"
``` php {skip-validation} hl_lines="29 30 31"
class JohnDoeCanSelectMore implements EventSubscriberInterface
{
private const CONFIGURATION_NAME = 'my_custom_udw';
Expand Down
6 changes: 3 additions & 3 deletions docs/administration/back_office/customize_calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Here, you define a new class for your event based on `Ibexa\Contracts\Calendar\E

Next, create `src/Calendar/Holidays/EventType.php`:

```php hl_lines="20-23"
``` php hl_lines="20-23"
[[= include_code('code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php') =]]
```

Expand All @@ -68,7 +68,7 @@ An event source must implement `Ibexa\Contracts\Calendar\EventSource\EventSource
One such built-in implementation is `InMemoryEventSource`.
To add an in-memory collection as an event source, create `src/Calendar/Holidays/EventSourceFactory.php`:

```php
``` php
[[= include_file('code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php', 0, 20) =]]
[[= include_file('code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php', 26, 36) =]]

Expand All @@ -80,7 +80,7 @@ To add an in-memory collection as an event source, create `src/Calendar/Holidays

For example:

``` php
``` php {skip-validation}
$collection = new EventCollection([
$this->createEvent("Event 1", new DateTime("2024-01-01")),
$this->createEvent("Event 2", new DateTime("2024-01-02")),
Expand Down
2 changes: 1 addition & 1 deletion docs/administration/back_office/customize_product_tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ibexa:
Then, create a subscriber that modifies the scenario.
```php hl_lines="32-34 36-38 40-42 44-55"
``` php hl_lines="32-34 36-38 40-42 44-55"
[[= include_code('code_samples/back_office/product_tour/src/EventSubscriber/NotificationScenarioSubscriber.php') =]]
```

Expand Down
8 changes: 4 additions & 4 deletions docs/administration/back_office/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ There are four types of notifications: `info`, `success`, `warning` and `error`.

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

``` php
``` php {skip-validation}
$this->notificationHandler->info(
/** @Desc("Notification text") */
'example.notification.text',
Expand Down Expand Up @@ -90,7 +90,7 @@ You can send notifications to users which are displayed in the user menu.
To create a new notification you can use the [`NotificationService::createNotification(CreateStruct $createStruct)` method](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_createNotification)
like in the example below:

```php
``` php
[[= include_code('code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php') =]]
```

Expand All @@ -102,7 +102,7 @@ To display a user notification, write a renderer and tag it as a service.

The example below presents a renderer that uses Twig to render a view:

```php
``` php
[[= include_code('code_samples/back_office/notifications/src/Notification/MyRenderer.php') =]]
```

Expand All @@ -126,7 +126,7 @@ To display a list of notifications, expand the above renderer.

The example below presents a modified renderer that uses Twig to render a list view:

```php
``` php
[[= include_code('code_samples/back_office/notifications/src/Notification/ListRenderer.php') =]]
```

Expand Down
2 changes: 1 addition & 1 deletion docs/administration/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ parameters:
an_array: [apple, banana, pear]
```
``` php
``` php {skip-validation}
// Usage inside a controller
$myParameter = $this->container->getParameter( 'myapp.parameter.name' );
```
Expand Down
4 changes: 2 additions & 2 deletions docs/administration/configuration/dynamic_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ parameters:
Inside a controller, in `site_group` SiteAccess, you can use the parameters in the following way (the same applies for `hasParameter()`):

``` php
``` php {skip-validation}
$configResolver = $this->getConfigResolver();
 
// ibexa.site_access.config is the default namespace, so no need to specify it
Expand Down Expand Up @@ -77,7 +77,7 @@ For more information about dependency injection, see [Service container](php_api
Don't store the retrieved config value unless you know what you're doing.
SiteAccess can change during code execution, which means you might work on the wrong value.

``` php
``` php {skip-validation}
namespace App;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
Expand Down
6 changes: 3 additions & 3 deletions docs/administration/configuration/repository_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ This enables you to use different settings for different repositories.

To do this, create a parser that implements `Ibexa\Bundle\Core\DependencyInjection\Configuration\RepositoryConfigParserInterface`:

``` php
``` php {skip-validation}
use Ibexa\Bundle\Core\DependencyInjection\Configuration\RepositoryConfigParserInterface;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

Expand All @@ -326,7 +326,7 @@ final class CustomRepositoryConfigParser implements RepositoryConfigParserInterf

You need to register this configuration extension in the following way:

``` php
``` php {skip-validation}
final class AcmeFeatureBundle extends Bundle
{
public function build(ContainerBuilder $container): void
Expand All @@ -342,6 +342,6 @@ final class AcmeFeatureBundle extends Bundle

To access the configuration settings, use the `Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider::getRepositoryConfig` method:

``` php
``` php {skip-validation}
$acmeConfig = $repositoryConfigProvider->getRepositoryConfig()['acme'];
```
4 changes: 2 additions & 2 deletions docs/administration/recent_activity/recent_activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ See [Activity Log Search Criteria reference](activity_log_criteria.md) and [Acti
In the following example, log groups that contain at least one creation of a Content item are displayed in terminal, with a maximum of 10 groups within the last hour.
It uses the default `admin` user that has a [permission](#permission-and-security) to list everyone's entries.

```php hl_lines="34-38"
``` php hl_lines="34-38"
[[= include_code('code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php') =]]
```

Expand Down Expand Up @@ -173,7 +173,7 @@ First, inject `Ibexa\Contracts\ActivityLog\ActivityLogServiceInterface` into you
In the following example, an event subscriber is subscribing to an event dispatched by a custom feature.
This event has the information needed by a log entry (see details after the example).

```php
``` php
[[= include_code('code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php') =]]
```

Expand Down
4 changes: 2 additions & 2 deletions docs/ai/ai_actions/configure_ai_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ composer require ibexa/connector-anthropic

If not using Symfony Flex, enable the bundle in `config/bundles.php`:

``` php
``` php {skip-validation}
Ibexa\Bundle\ConnectorAnthropic\IbexaConnectorAnthropicBundle::class => ['all' => true],
```

Expand Down Expand Up @@ -105,7 +105,7 @@ composer require ibexa/connector-gemini

Then, if not using Symfony Flex, enable the bundle in `config/bundles.php`:

``` php
``` php {skip-validation}
Ibexa\Bundle\ConnectorGemini\IbexaConnectorGeminiBundle::class => ['all' => true],
```

Expand Down
4 changes: 2 additions & 2 deletions docs/api/graphql/graphql_custom_ft.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Only implement methods that you need, the rest is handled by other mappers (conf
When a mapper method is decorated, you need to call the decorated service method for unsupported types.
To do that, you need to replace `mapXXX` by the method it's in:

```php
``` php
[[= include_code('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php', 21, 24, remove_indent=True) =]]
```

Expand All @@ -99,7 +99,7 @@ For example, `ibexa_matrix` generates its own input types depending on the confi

Example of a `MyFieldDefinitionMapper` mapper for a complex field type:

```php
``` php
[[= include_code('code_samples/api/graphql/src/GraphQL/Schema/MyFieldDefinitionMapper.php') =]]
```

Expand Down
2 changes: 1 addition & 1 deletion docs/api/notification_channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ The [`…\Service\NotificationServiceInterface::send()`](/api/php_api/php_api_re
For example, to send a notification, you often use a combination like the following:
```php hl_lines="11-14"
``` php hl_lines="11-14"
[[= include_code('code_samples/api/notifications/notification_send.php', 2) =]]
```
Expand Down
4 changes: 2 additions & 2 deletions docs/api/php_api/php_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ You can use this method to perform an action that the current user doesn't have

For example, to [hide a Location](managing_content.md#hiding-and-revealing-locations), use:

``` php
``` php {skip-validation}
use Ibexa\Contracts\Core\Repository\Repository;

//...
Expand Down Expand Up @@ -146,7 +146,7 @@ For example if you're using a command which takes the content ID as a parameter,

Both cases should be covered with error messages:

``` php
``` php {skip-validation}
try {
// ...
} catch (\Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If the returned value was depending on a location, it could have been wrapped in

`CachedValue` is used in the following way:

```php
``` php {skip-validation}
return new CachedValue(
new MyValue($args…),
['locationId'=> $locationId]
Expand Down
Loading
Loading