diff --git a/.gitignore b/.gitignore index 10f1a32e27..56f76dfb72 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ yarn.lock docs/css/*.map .deptrac.cache .phpunit.result.cache +code_samples/_inline_php/ diff --git a/composer.json b/composer.json index 351e081fec..3d2ca1b01e 100644 --- a/composer.json +++ b/composer.json @@ -101,18 +101,18 @@ "ibexa/fastly": "~5.0.x-dev" }, "scripts": { - "fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots", + "fix-cs": "php tools/extract-inline-php.php && 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", + "phpstan": "php tools/extract-inline-php.php && phpstan analyse", + "deptrac": "php tools/extract-inline-php.php && deptrac analyse", + "check-rector": "php tools/extract-inline-php.php && rector process --dry-run --ansi", "phpunit": "phpunit", "phpunit-update-baseline": "php tests/generate-yaml-baseline.php" }, "scripts-descriptions": { "fix-cs": "Automatically fixes code style in all files", "check-cs": "Run code style checker for all files", - "phpstan": "Run static code analysis", + "phpstan": "Run static code analysis (extracts inline PHP snippets from docs/ first)", "deptrac": "Run Deptrac architecture testing", "check-rector": "Check for code refactoring opportunities", "phpunit": "Run PHPUnit tests (YAML validation)", diff --git a/docs/administration/back_office/back_office_elements/formatting_date_and_time.md b/docs/administration/back_office/back_office_elements/formatting_date_and_time.md index ff14689b20..56ed659966 100644 --- a/docs/administration/back_office/back_office_elements/formatting_date_and_time.md +++ b/docs/administration/back_office/back_office_elements/formatting_date_and_time.md @@ -40,7 +40,7 @@ class MyService // your code } - public function foo() + public function foo(): void { // your code diff --git a/docs/administration/back_office/back_office_menus/back_office_menus.md b/docs/administration/back_office/back_office_menus/back_office_menus.md index 5ae4e704bb..8604a0663f 100644 --- a/docs/administration/back_office/back_office_menus/back_office_menus.md +++ b/docs/administration/back_office/back_office_menus/back_office_menus.md @@ -86,6 +86,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 +/** @var \Knp\Menu\ItemInterface $menu */ $menu->addChild( 'all_content_list', [ @@ -106,6 +107,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 +/** @var \Knp\Menu\ItemInterface $menu */ $menu->addChild( 'all_content_list', [ diff --git a/docs/administration/back_office/browser/browser.md b/docs/administration/back_office/browser/browser.md index 1addc5b3d8..6d3f8cd1a8 100644 --- a/docs/administration/back_office/browser/browser.md +++ b/docs/administration/back_office/browser/browser.md @@ -147,6 +147,11 @@ 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" + The event names to listen to */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConfigResolveEvent::NAME => 'onUdwConfigResolve', ]; } - /** - * @param \Ibexa\AdminUi\UniversalDiscovery\Event $event - */ - public function onUdwConfigResolve(ConfigResolveEvent $event) + public function onUdwConfigResolve(ConfigResolveEvent $event): void { if ($event->getConfigName() !== self::CONFIGURATION_NAME) { return; diff --git a/docs/administration/back_office/customize_calendar.md b/docs/administration/back_office/customize_calendar.md index 5e56e0a7cd..7db6eee94f 100644 --- a/docs/administration/back_office/customize_calendar.md +++ b/docs/administration/back_office/customize_calendar.md @@ -81,10 +81,15 @@ To add an in-memory collection as an event source, create `src/Calendar/Holidays For example: ``` php + use Ibexa\Contracts\Calendar\EventCollection; + use Ibexa\Contracts\Calendar\EventInterface; + + /** @var \App\Calendar\Holidays\EventSourceFactory $this */ $collection = new EventCollection([ - $this->createEvent("Event 1", new DateTime("2024-01-01")), - $this->createEvent("Event 2", new DateTime("2024-01-02")), + $this->createEvent("Event 1", new DateTime("2024-01-01")), // @phpstan-ignore method.private + $this->createEvent("Event 2", new DateTime("2024-01-02")), // @phpstan-ignore method.private // ... + ]); ``` Next, register the event source as a service: diff --git a/docs/administration/back_office/notifications.md b/docs/administration/back_office/notifications.md index 29c2d69f54..fe5414e33a 100644 --- a/docs/administration/back_office/notifications.md +++ b/docs/administration/back_office/notifications.md @@ -27,7 +27,8 @@ There are four types of notifications: `info`, `success`, `warning` and `error`. To send a notification from PHP, inject the `TranslatableNotificationHandlerInterface` into your class. ``` php -$this->notificationHandler->info( +/** @var \Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface $notificationHandler */ +$notificationHandler->info( /** @Desc("Notification text") */ 'example.notification.text', [], diff --git a/docs/administration/configuration/configuration.md b/docs/administration/configuration/configuration.md index eb26f7ec2a..871f4c5f19 100644 --- a/docs/administration/configuration/configuration.md +++ b/docs/administration/configuration/configuration.md @@ -74,7 +74,8 @@ parameters: ``` php // Usage inside a controller -$myParameter = $this->container->getParameter( 'myapp.parameter.name' ); +/** @var \Symfony\Component\DependencyInjection\ContainerInterface $container */ +$myParameter = $container->getParameter( 'myapp.parameter.name' ); ``` ## Configuration settings diff --git a/docs/administration/configuration/dynamic_configuration.md b/docs/administration/configuration/dynamic_configuration.md index c847e0899d..a8ba5dbfab 100644 --- a/docs/administration/configuration/dynamic_configuration.md +++ b/docs/administration/configuration/dynamic_configuration.md @@ -29,9 +29,9 @@ 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 // The following will resolve ibexa.site_access.config..content.default_ttl // In the case of site_group, it will return 3600. @@ -81,20 +81,20 @@ For more information about dependency injection, see [Service container](php_api namespace App; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; -  + class Service { -  /** + /** * @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ private $configResolver; -  - public function __construct( ConfigResolverInterface $configResolver ) + + public function __construct(ConfigResolverInterface $configResolver) { $this->configResolver = $configResolver; } - public function someMethodThatNeedConfig() + public function someMethodThatNeedConfig(): void { $configValue = $this->configResolver->getParameter('my_param', 'myapp'); } diff --git a/docs/administration/configuration/repository_configuration.md b/docs/administration/configuration/repository_configuration.md index f0d036194e..c2e867de12 100644 --- a/docs/administration/configuration/repository_configuration.md +++ b/docs/administration/configuration/repository_configuration.md @@ -327,6 +327,9 @@ final class CustomRepositoryConfigParser implements RepositoryConfigParserInterf You need to register this configuration extension in the following way: ``` php +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\Bundle; + final class AcmeFeatureBundle extends Bundle { public function build(ContainerBuilder $container): void @@ -343,5 +346,7 @@ final class AcmeFeatureBundle extends Bundle To access the configuration settings, use the `Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider::getRepositoryConfig` method: ``` php +/** @var \Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider $repositoryConfigProvider */ +/** @phpstan-ignore-next-line */ $acmeConfig = $repositoryConfigProvider->getRepositoryConfig()['acme']; ``` diff --git a/docs/ai_actions/configure_ai_actions.md b/docs/ai_actions/configure_ai_actions.md index 038798c5c6..f67727b75e 100644 --- a/docs/ai_actions/configure_ai_actions.md +++ b/docs/ai_actions/configure_ai_actions.md @@ -92,7 +92,10 @@ composer require ibexa/connector-gemini Then, you **must** add the bundle to the list in `config/bundles.php` manually: ``` php +return [ + // ... Ibexa\Bundle\ConnectorGemini\IbexaConnectorGeminiBundle::class => ['all' => true], +]; ``` This command adds the feature code, including basic handlers that let you refine text or generate alternative text for images. diff --git a/docs/api/graphql/graphql_custom_ft.md b/docs/api/graphql/graphql_custom_ft.md index 002ceb7420..2241e15330 100644 --- a/docs/api/graphql/graphql_custom_ft.md +++ b/docs/api/graphql/graphql_custom_ft.md @@ -78,7 +78,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 skip-validation if (!$this->canMap($fieldDefinition)) { return parent::mapToFieldValueType($fieldDefinition); } @@ -88,7 +88,7 @@ It's required for every implemented method, so that other mappers are called for The [`RelationFieldDefinitionMapper`](https://github.com/ibexa/graphql/blob/main/src/lib/Schema/Domain/Content/Mapper/FieldDefinition/RelationFieldDefinitionMapper.php) example: -```php hl_lines="14" +```php hl_lines="14" skip-validation class RelationFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper { public function mapToFieldValueType(FieldDefinition $fieldDefinition): ?string @@ -149,7 +149,7 @@ For example, `ibexa_matrix` generates its own input types depending on the confi Example of a `MyCustomFieldDefinitionMapper` mapper for a complex field type: -```php +```php skip-validation class MyFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper { public function mapToFieldValueInputType(ContentType contentType, FieldDefinition fieldDefinition): ?string @@ -172,4 +172,4 @@ The following variables are available in the resolver's expression: - `location` is the content item's resolved location. For more information, see [Querying Locations](graphql_queries.md#querying-locations) - `item` is the content together with its location `\Ibexa\GraphQL\Value\Item` -`RelationFieldValueBuilder` or `SelectionFieldValueBuilder` can be used as examples. \ No newline at end of file +`RelationFieldValueBuilder` or `SelectionFieldValueBuilder` can be used as examples. diff --git a/docs/api/php_api/php_api.md b/docs/api/php_api/php_api.md index e9d3b7fd94..c11ffc80fd 100644 --- a/docs/api/php_api/php_api.md +++ b/docs/api/php_api/php_api.md @@ -110,10 +110,13 @@ For example, to [hide a Location](managing_content.md#hiding-and-revealing-locat ``` php use Ibexa\Contracts\Core\Repository\Repository; +use Ibexa\Contracts\Core\Repository\Values\Content\Location; //... -$hiddenLocation = $repository->sudo(function (Repository $repository) use ($location) { +/** @var Repository $repository */ +/** @var Location $location */ +$hiddenLocation = $repository->sudo(function (Repository $repository) use ($location): Location { return $repository->getLocationService()->hideLocation($location); }); ``` @@ -150,9 +153,9 @@ Both cases should be covered with error messages: ``` php try { // ... -} catch (\Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException $e) { +} catch (\Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException $e) { // @phpstan-ignore catch.neverThrown $output->writeln("No content with id $contentId found"); -} catch (\Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException $e) { +} catch (\Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException $e) { // @phpstan-ignore catch.neverThrown $output->writeln("Permission denied on content with id $contentId"); } ``` diff --git a/docs/api/rest_api/extending_rest_api/creating_new_rest_resource.md b/docs/api/rest_api/extending_rest_api/creating_new_rest_resource.md index 37e53f8f0a..4d8ad711e6 100644 --- a/docs/api/rest_api/extending_rest_api/creating_new_rest_resource.md +++ b/docs/api/rest_api/extending_rest_api/creating_new_rest_resource.md @@ -69,8 +69,12 @@ If the returned value was depending on a location, it could have been wrapped in `CachedValue` is used in the following way: ```php +use Ibexa\Rest\Server\Values\CachedValue; + +/** @var array $args */ +/** @var int $locationId */ return new CachedValue( - new MyValue($args…), + new MyValue($args), // @phpstan-ignore class.notFound ['locationId'=> $locationId] ); ``` diff --git a/docs/commerce/cart/cart_api.md b/docs/commerce/cart/cart_api.md index d8208d737a..01beffecb0 100644 --- a/docs/commerce/cart/cart_api.md +++ b/docs/commerce/cart/cart_api.md @@ -69,6 +69,9 @@ use Ibexa\Contracts\Cart\Value\CartMetadataUpdateStruct; // ... +/** @var \Ibexa\Contracts\Core\Repository\UserService $userService */ +/** @var \Ibexa\Contracts\Cart\CartServiceInterface $cartService */ +/** @var \Ibexa\Contracts\Cart\Value\CartInterface $cart */ $updateMetadataStruct = new CartMetadataUpdateStruct(); $updateMetadataStruct->setOwner($userService->loadUserByLogin('user')); @@ -151,7 +154,13 @@ It can include any relevant information that you want to associate with a partic To add context data to a cart, follow this example: ```php -$createStruct = new CartCreateStruct(...); +use Ibexa\Contracts\Cart\Value\CartCreateStruct; +use Ibexa\Contracts\Core\Collection\ArrayMap; +use Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface; + +/** @var \Ibexa\Contracts\Cart\CartServiceInterface $cartService */ +/** @var CurrencyInterface $currency */ +$createStruct = new CartCreateStruct('My Cart', $currency); $createStruct->setContext(new ArrayMap([ 'coupon_code' => 'X1MF7699', ])); @@ -167,7 +176,14 @@ You also add "X1MF7699" coupon code as context data to the cart. To attach context data to a cart entry, proceed as follows: ```php -$entryAddStruct = new EntryAddStruct(...); +use Ibexa\Contracts\Cart\Value\EntryAddStruct; +use Ibexa\Contracts\Core\Collection\ArrayMap; +use Ibexa\Contracts\ProductCatalog\Values\ProductInterface; + +/** @var \Ibexa\Contracts\Cart\CartServiceInterface $cartService */ +/** @var \Ibexa\Contracts\Cart\Value\CartInterface $cart */ +/** @var ProductInterface $product */ +$entryAddStruct = new EntryAddStruct($product); // @phpstan-ignore argument.type $entryAddStruct->setContext(new ArrayMap([ 'tshirt_text' => 'EqEqEqEq', ])); diff --git a/docs/commerce/shopping_list/install_shopping_list.md b/docs/commerce/shopping_list/install_shopping_list.md index 13d530d9d4..ba7de84f4e 100644 --- a/docs/commerce/shopping_list/install_shopping_list.md +++ b/docs/commerce/shopping_list/install_shopping_list.md @@ -18,7 +18,10 @@ The associated Symfony Flex recipe configures the bundle and its routes. Check that the following line has been added by the recipe to `config/bundles.php` file's array: ```php +return [ + // ... Ibexa\Bundle\ShoppingList\IbexaShoppingListBundle::class => ['all' => true], +]; ``` And that you have a `config/routes/ibexa_shopping_list.yaml` file configuring the following routes: diff --git a/docs/commerce/shopping_list/shopping_list_api.md b/docs/commerce/shopping_list/shopping_list_api.md index 1532d523a5..6ab27c80e2 100644 --- a/docs/commerce/shopping_list/shopping_list_api.md +++ b/docs/commerce/shopping_list/shopping_list_api.md @@ -41,7 +41,11 @@ and with sort clauses from the [`SortClause` namespace](/api/php_api/php_api_ref To get all shopping lists (of the current user or of the whole repository depending on the current user limitation), use the search method without criterion: ```php -$lists = $this->shoppingListService->findShoppingLists(new ShoppingListQuery()); +use Ibexa\Contracts\ShoppingList\ShoppingListServiceInterface; +use Ibexa\Contracts\ShoppingList\Value\ShoppingListQuery; + +/** @var ShoppingListServiceInterface $shoppingListService */ +$lists = $shoppingListService->findShoppingLists(new ShoppingListQuery()); ``` For more information about the shopping list search, @@ -57,11 +61,16 @@ In the following example, if some assignments (`$list =`) are removed, the dumpe If only the middle assignment is removed, the last dumped variable contains the up-to-date shopping list. ```php -$list = $this->shoppingListService->getOrCreateDefaultShoppingList(); +use Ibexa\Contracts\ShoppingList\ShoppingListServiceInterface; +use Ibexa\Contracts\ShoppingList\Value\EntryAddStruct; + +/** @var ShoppingListServiceInterface $shoppingListService */ +/** @var string $productCode */ +$list = $shoppingListService->getOrCreateDefaultShoppingList(); dump($list); -$list = $this->shoppingListService->clearShoppingList($list); +$list = $shoppingListService->clearShoppingList($list); dump($list); -$list = $this->shoppingListService->addEntries($list, [new EntryAddStruct($productCode)]); +$list = $shoppingListService->addEntries($list, [new EntryAddStruct($productCode)]); dump($list); ``` When adding array of entries with `ShoppingListService::addEntries()`, diff --git a/docs/commerce/storefront/extend_storefront.md b/docs/commerce/storefront/extend_storefront.md index 82fc5e0dff..511d763555 100644 --- a/docs/commerce/storefront/extend_storefront.md +++ b/docs/commerce/storefront/extend_storefront.md @@ -100,6 +100,12 @@ Define your own logic in a custom controller. Refer to the code snippet below and create your own file, for example, `CustomProductRenderController.php`: ``` php +use Ibexa\Contracts\ProductCatalog\Values\ProductInterface; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Response; + +class CustomProductRenderController extends AbstractController +{ public function renderAction(ProductInterface $product): Response { return $this->render('@ibexadesign/storefront/product_card.html.twig', [ @@ -109,4 +115,5 @@ Refer to the code snippet below and create your own file, for example, `CustomPr 'is_relative' => true, ]); } +} ``` diff --git a/docs/commerce/transactional_emails/extend_transactional_emails.md b/docs/commerce/transactional_emails/extend_transactional_emails.md index 665ed1cb9a..f29004a33d 100644 --- a/docs/commerce/transactional_emails/extend_transactional_emails.md +++ b/docs/commerce/transactional_emails/extend_transactional_emails.md @@ -102,8 +102,9 @@ final class TransactionalMailFactoryEventSubscriber implements EventSubscriberIn { $recipient = $event->getRecipient(); $profile = $event->getProfile(); + // @phpstan-ignore-next-line $user = $recipient->getUser(); - + // Provide additional data if your profile has more attributes: $attributes = $profile->getAttributes(); $attributes[] = new Attribute('name', $user->getName()); @@ -120,8 +121,8 @@ final class TransactionalMailFactoryEventSubscriber implements EventSubscriberIn $profile->setSegmentations($segmentations); // Use the same mechanism to pass other profile data - $profile->setSubscriptions(...); - $profile->setDataCollection(...); + // $profile->setSubscriptions($subscriptions); + // $profile->setDataCollection($dataCollection); } } ``` diff --git a/docs/content_management/content_api/browsing_content.md b/docs/content_management/content_api/browsing_content.md index 3f57158cf7..87f3b18484 100644 --- a/docs/content_management/content_api/browsing_content.md +++ b/docs/content_management/content_api/browsing_content.md @@ -104,7 +104,9 @@ You can get the current version's `VersionInfo` using [`ContentService::loadVers You can also specify the version number as the second argument to get Relations for a specific version: ``` php -$versionInfo = $this->contentService->loadVersionInfo($contentInfo, 2); +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +$versionInfo = $contentService->loadVersionInfo($contentInfo, 2); ``` `loadRelationList` provides an iterable [`RelationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-RelationList.html) object @@ -170,12 +172,18 @@ The repository is SiteAccess-aware, so languages defined by the SiteAccess are a To load a specific language, provide its language code when loading the content item: ``` php -$content = $this->contentService->loadContent($contentId, ['ger-DE']); +/** @var int $contentId */ +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +$content = $contentService->loadContent($contentId, ['ger-DE']); ``` To load all languages as a prioritized list, use `Language::ALL`: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Language; + +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */ $contentService->loadContent($content->id, Language::ALL); ``` @@ -203,7 +211,10 @@ You can do it through the `getMainLocation` method of the ContentInfo object. Next, use the `getParentLocation` method of the location object to access the parent location: ``` php +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ +/** @var \Symfony\Component\Console\Output\OutputInterface $output */ $mainLocation = $contentInfo->getMainLocation(); +/** @phpstan-ignore-next-line */ $output->writeln("Parent Location: " . $mainLocation->getParentLocation()->pathString); ``` @@ -223,10 +234,15 @@ The versions must have the same language. For example, to get the comparison between the `name` field of two versions: ```php -$versionFrom = $this->contentService->loadVersionInfo($contentInfo, $versionFromId); -$versionTo = $this->contentService->loadVersionInfo($contentInfo, $versionToId); - -$nameComparison = $this->comparisonService->compare($versionFrom, $versionTo)->getFieldValueDiffByIdentifier('name')->getComparisonResult(); +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ +/** @var int $versionFromId */ +/** @var int $versionToId */ +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +/** @var \Ibexa\Contracts\VersionComparison\Service\VersionComparisonServiceInterface $comparisonService */ +$versionFrom = $contentService->loadVersionInfo($contentInfo, $versionFromId); +$versionTo = $contentService->loadVersionInfo($contentInfo, $versionToId); + +$nameComparison = $comparisonService->compare($versionFrom, $versionTo)->getFieldValueDiffByIdentifier('name')->getComparisonResult(); ``` `getComparisonResult` returns a `ComparisonResult` object, which depends on the field type being compared. diff --git a/docs/content_management/content_api/creating_content.md b/docs/content_management/content_api/creating_content.md index bed7373eb5..c52ce43063 100644 --- a/docs/content_management/content_api/creating_content.md +++ b/docs/content_management/content_api/creating_content.md @@ -104,5 +104,8 @@ You can delete a single translation from a content item's version using [`Conten The method must be provided with a `VersionInfo` object and the code of the language to delete: ``` php -$this->contentService->deleteTranslationFromDraft($versionInfo, $language); +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo */ +/** @var string $language */ +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +$contentService->deleteTranslationFromDraft($versionInfo, $language); ``` diff --git a/docs/content_management/content_api/managing_content.md b/docs/content_management/content_api/managing_content.md index 976b53354c..e27a5844c5 100644 --- a/docs/content_management/content_api/managing_content.md +++ b/docs/content_management/content_api/managing_content.md @@ -117,8 +117,12 @@ The content item is restored under its previous location. You can also provide a different location to restore in as a second argument: ``` php -$newParent = $this->locationService->loadLocation($location); -$this->trashService->recover($trashItem, $newParent); +/** @var int $location */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\TrashItem $trashItem */ +/** @var \Ibexa\Contracts\Core\Repository\LocationService $locationService */ +/** @var \Ibexa\Contracts\Core\Repository\TrashService $trashService */ +$newParent = $locationService->loadLocation($location); +$trashService->recover($trashItem, $newParent); ``` You can also search through Trash items and sort the results using several public PHP API Search Criteria and Sort Clauses that have been exposed for `TrashService` queries. diff --git a/docs/content_management/field_types/field_type_reference/addressfield.md b/docs/content_management/field_types/field_type_reference/addressfield.md index d374937caa..e036100b2d 100644 --- a/docs/content_management/field_types/field_type_reference/addressfield.md +++ b/docs/content_management/field_types/field_type_reference/addressfield.md @@ -28,6 +28,8 @@ provided by the `ibexa/fieldtype-address` package. ### Example input ```php +use Ibexa\FieldTypeAddress\FieldType; + new FieldType\Value( 'My home address', 'PL', diff --git a/docs/content_management/field_types/field_type_reference/authorfield.md b/docs/content_management/field_types/field_type_reference/authorfield.md index c26c2dcb11..267478a933 100644 --- a/docs/content_management/field_types/field_type_reference/authorfield.md +++ b/docs/content_management/field_types/field_type_reference/authorfield.md @@ -19,7 +19,9 @@ This field type allows the storage and retrieval of one or more authors. For eac Example: ``` php -$authorList = Author\Value([ +use Ibexa\Core\FieldType\Author; + +$authorList = new Author\Value([ new Author\Author([ 'id' => 1, 'name' => 'Boba Fett', @@ -40,7 +42,7 @@ The hash format mostly matches the value object. It has the following key `autho Example ``` php -[ +return [ [ 'id' => 1, 'name' => 'Boba Fett', @@ -50,8 +52,8 @@ Example 'id' => 2, 'name' => 'Darth Vader', 'email' => 'darth.vader@example.com' - ] -] + ], +]; ``` ##### String representation @@ -85,6 +87,6 @@ Following `defaultAuthor` default value options are available as constants in use Ibexa\Core\FieldType\Author\Type; $settings = [ - "defaultAuthor" => Type::DEFAULT_VALUE_EMPTY + "defaultAuthor" => Type::DEFAULT_VALUE_EMPTY, ]; ``` diff --git a/docs/content_management/field_types/field_type_reference/binaryfilefield.md b/docs/content_management/field_types/field_type_reference/binaryfilefield.md index 3b7d612234..d115b6653e 100644 --- a/docs/content_management/field_types/field_type_reference/binaryfilefield.md +++ b/docs/content_management/field_types/field_type_reference/binaryfilefield.md @@ -47,6 +47,7 @@ The hash format mostly matches the value object. It has the following keys: Example: ```php +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentCreateStruct $fileContentCreateStruct */ $fileContentCreateStruct->setField('file', new Ibexa\Core\FieldType\BinaryFile\Value([ 'fileName' => 'example.pdf', 'inputUri' => '/tmp/example_for_website.pdf', diff --git a/docs/content_management/field_types/field_type_reference/checkboxfield.md b/docs/content_management/field_types/field_type_reference/checkboxfield.md index 54380b2469..2d90eff81e 100644 --- a/docs/content_management/field_types/field_type_reference/checkboxfield.md +++ b/docs/content_management/field_types/field_type_reference/checkboxfield.md @@ -20,16 +20,16 @@ The Value class of this field type contains the following properties: ``` php //Value object content examples -use Ibexa\Core\FieldType\Checkbox\Type; +use Ibexa\Core\FieldType\Checkbox as Checkbox; // Instantiates a checkbox value with a default state (false) $checkboxValue = new Checkbox\Value(); // Checked -$value->bool = true; +$checkboxValue->bool = true; // Unchecked -$value->bool = false; +$checkboxValue->bool = false; ``` ##### Constructor @@ -38,7 +38,7 @@ The `Checkbox\Value` constructor accepts a boolean value: ``` php // Constructor example -use Ibexa\Core\FieldType\Checkbox\Type; +use Ibexa\Core\FieldType\Checkbox as Checkbox; // Instantiates a checkbox value with a checked state $checkboxValue = new Checkbox\Value( true ); diff --git a/docs/content_management/field_types/field_type_reference/countryfield.md b/docs/content_management/field_types/field_type_reference/countryfield.md index 521b06bd94..499ca9d396 100644 --- a/docs/content_management/field_types/field_type_reference/countryfield.md +++ b/docs/content_management/field_types/field_type_reference/countryfield.md @@ -13,7 +13,7 @@ This field type represents one or multiple countries. Example array: ``` php -[ +return [ "JP" => [ "Name" => "Japan", "Alpha2" => "JP", @@ -51,6 +51,8 @@ It's also available when setting value on the content field, by setting the valu ``` php // Value object content example +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */ +// @phpstan-ignore-next-line assign.propertyReadOnly $content->fields["countries"] = [ "JP", "NO" ]; ``` @@ -68,6 +70,7 @@ The Value class of this field type contains the following properties: ``` php // Value object content example +/** @var \Ibexa\Core\FieldType\Country\Value $value */ $value->countries = [ "JP" => [ "Name" => "Japan", @@ -85,6 +88,7 @@ It expects an array as input. ``` php // Constructor example +use Ibexa\Core\FieldType\Country as Country; // Instantiates a Country Value object $countryValue = new Country\Value( diff --git a/docs/content_management/field_types/field_type_reference/dateandtimefield.md b/docs/content_management/field_types/field_type_reference/dateandtimefield.md index d0d5e3fd25..94cec9a836 100644 --- a/docs/content_management/field_types/field_type_reference/dateandtimefield.md +++ b/docs/content_management/field_types/field_type_reference/dateandtimefield.md @@ -110,6 +110,6 @@ The template called by the [`ibexa_render_field()` Twig function](field_twig_fun Example: -``` php +``` html+twig {{ ibexa_render_field(content, 'datetime') }} ``` diff --git a/docs/content_management/field_types/field_type_reference/emailaddressfield.md b/docs/content_management/field_types/field_type_reference/emailaddressfield.md index db376e9eee..ee1c1b6b92 100644 --- a/docs/content_management/field_types/field_type_reference/emailaddressfield.md +++ b/docs/content_management/field_types/field_type_reference/emailaddressfield.md @@ -21,10 +21,10 @@ The `Value` class of this field type contains the following properties: ``` php // Value object content example -use Ibexa\Core\FieldType\EmailAddress\Type; +use Ibexa\Core\FieldType\EmailAddress\Value; // Instantiates an EmailAddress Value object with default value (empty string) -$emailaddressValue = new Type\Value(); +$emailaddressValue = new Value(); // Email definition $emailaddressValue->email = "someuser@example.com"; @@ -38,10 +38,10 @@ It accepts a string as input. ``` php // Constructor example -use Ibexa\Core\FieldType\EmailAddress\Type; +use Ibexa\Core\FieldType\EmailAddress\Value; // Instantiates an EmailAddress Value object -$emailaddressValue = new Type\Value( "someuser@example.com" ); +$emailaddressValue = new Value( "someuser@example.com" ); ``` ##### String representation diff --git a/docs/content_management/field_types/field_type_reference/floatfield.md b/docs/content_management/field_types/field_type_reference/floatfield.md index ec09b0eeaf..b0e6a72122 100644 --- a/docs/content_management/field_types/field_type_reference/floatfield.md +++ b/docs/content_management/field_types/field_type_reference/floatfield.md @@ -30,12 +30,12 @@ The Value class of this field type contains the following properties: ``` php // Value object content example -use Ibexa\Core\FieldType\Float\Type; +use Ibexa\Core\FieldType\Float\Value as FloatValue; // Instantiates a Float Value object -$floatValue = new Type\Value(); +$floatValue = new FloatValue(); -$float->value = 284.773 +$floatValue->value = 284.773; ``` ##### Constructor @@ -46,10 +46,10 @@ It expects a numeric value with or without decimals. ``` php // Constructor example -use Ibexa\Core\FieldType\Float\Type; +use Ibexa\Core\FieldType\Float\Value as FloatValue; // Instantiates a Float Value object -$floatValue = new Type\Value( 284.773 ); +$floatValue = new FloatValue( 284.773 ); ``` ### Validation @@ -64,8 +64,7 @@ This field type supports `FloatValueValidator`, defining maximum and minimum flo ``` php // Validator configuration example in PHP -use Ibexa\Core\FieldType\Float\Type; - +/** @var \Ibexa\Contracts\Core\Repository\Repository $repository */ $contentTypeService = $repository->getContentTypeService(); $floatFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( "float", "ibexa_float" ); diff --git a/docs/content_management/field_types/field_type_reference/imageassetfield.md b/docs/content_management/field_types/field_type_reference/imageassetfield.md index 65da261fd9..4bac72c2a2 100644 --- a/docs/content_management/field_types/field_type_reference/imageassetfield.md +++ b/docs/content_management/field_types/field_type_reference/imageassetfield.md @@ -32,6 +32,8 @@ Value object of `ibexa_image_asset` contains the following properties: ``` php // Value object content example +/** @var \Ibexa\Core\FieldType\ImageAsset\Value $imageAssetValue */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ $imageAssetValue->destinationContentId = $contentInfo->id; $imageAssetValue->alternativeText = "Picture of an apple."; ``` @@ -44,6 +46,9 @@ It expects an ID of a content item representing asset and the alternative text. ``` php // Constructor example +use Ibexa\Core\FieldType\ImageAsset as ImageAsset; + +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ // Instantiates a ImageAsset Value object $imageAssetValue = new ImageAsset\Value($contentInfo->id, "Picture of an apple."); ``` diff --git a/docs/content_management/field_types/field_type_reference/imagefield.md b/docs/content_management/field_types/field_type_reference/imagefield.md index 3752a8bef1..40377a8d0c 100644 --- a/docs/content_management/field_types/field_type_reference/imagefield.md +++ b/docs/content_management/field_types/field_type_reference/imagefield.md @@ -150,6 +150,9 @@ The variation service, `ibexa.field_type.ibexa_image.variation_service`, can be It expects a VersionInfo, the Image field, and the variation name as a string (`large`, `medium`, and more.): ``` php +/** @var \Ibexa\Contracts\Core\Variation\VariationHandler $imageVariationHandler */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Field $imageField */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo */ $variation = $imageVariationHandler->getVariation( $imageField, $versionInfo, 'large' ); @@ -165,8 +168,10 @@ As for any field type, there are several ways to input content to a field. For an Image, the quickest is to call `setField()` on the ContentStruct: ``` php +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +/** @var \Ibexa\Contracts\Core\Repository\ContentTypeService $contentTypeService */ $createStruct = $contentService->newContentCreateStruct( - $contentTypeService->loadContentType( 'image' ), + $contentTypeService->loadContentTypeByIdentifier( 'image' ), 'eng-GB' ); @@ -177,8 +182,10 @@ To customize the Image's alternative texts, you must first get an `Image\Value` For that, you can use the `Image\Value::fromString()` method that accepts the path to a local file: ``` php +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +/** @var \Ibexa\Contracts\Core\Repository\ContentTypeService $contentTypeService */ $createStruct = $contentService->newContentCreateStruct( - $contentTypeService->loadContentType( 'image' ), + $contentTypeService->loadContentTypeByIdentifier( 'image' ), 'eng-GB' ); @@ -190,6 +197,7 @@ $createStruct->setField( 'image', $imageField ); You can also provide a hash of `Image\Value` properties, either to `setField()`, or to the constructor: ``` php +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentCreateStruct $createStruct */ $imageValue = new \Ibexa\Core\FieldType\Image\Value( [ 'id' => '/tmp/image.png', diff --git a/docs/content_management/field_types/field_type_reference/integerfield.md b/docs/content_management/field_types/field_type_reference/integerfield.md index c1eb8f3b9d..17da940854 100644 --- a/docs/content_management/field_types/field_type_reference/integerfield.md +++ b/docs/content_management/field_types/field_type_reference/integerfield.md @@ -26,7 +26,8 @@ The Value class of this field type contains the following properties: ``` php // Value object content example -$integer->value = 8 +/** @var \Ibexa\Core\FieldType\Integer\Value $integer */ +$integer->value = 8; ``` ##### Constructor diff --git a/docs/content_management/field_types/field_type_reference/isbnfield.md b/docs/content_management/field_types/field_type_reference/isbnfield.md index 8b4baf9c51..3e603db50d 100644 --- a/docs/content_management/field_types/field_type_reference/isbnfield.md +++ b/docs/content_management/field_types/field_type_reference/isbnfield.md @@ -33,8 +33,7 @@ The input passed into this field type is subject of ISBN validation depending on An example of this field setting is shown below and controls if input is validated as ISBN-13 or ISBN-10: ``` php -Array -( - [isISBN13] => true -) +return [ + 'isISBN13' => true, +]; ``` diff --git a/docs/content_management/field_types/field_type_reference/keywordfield.md b/docs/content_management/field_types/field_type_reference/keywordfield.md index 1d1d09b35f..8885f90d4b 100644 --- a/docs/content_management/field_types/field_type_reference/keywordfield.md +++ b/docs/content_management/field_types/field_type_reference/keywordfield.md @@ -34,7 +34,7 @@ use Ibexa\Core\FieldType\Keyword\Value; $keywordValue = new Value(); // Sets an array of keywords as a value -$keyword->value = [ "php", "css3", "html5", "Ibexa Platform" ]; +$keywordValue->values = [ "php", "css3", "html5", "Ibexa Platform" ]; ``` #### Constructor diff --git a/docs/content_management/field_types/field_type_reference/maplocationfield.md b/docs/content_management/field_types/field_type_reference/maplocationfield.md index feaf4ef115..e0f64d78b4 100644 --- a/docs/content_management/field_types/field_type_reference/maplocationfield.md +++ b/docs/content_management/field_types/field_type_reference/maplocationfield.md @@ -38,6 +38,7 @@ Accepted keys are `latitude` (`float`), `longitude` (`float`), `address` (`strin ``` php // Constructor example +use Ibexa\Core\FieldType\MapLocation as MapLocation; // Instantiates a MapLocation Value object $MapLocationValue = new MapLocation\Value( diff --git a/docs/content_management/field_types/field_type_reference/matrixfield.md b/docs/content_management/field_types/field_type_reference/matrixfield.md index 1542ceeebd..7353e329d6 100644 --- a/docs/content_management/field_types/field_type_reference/matrixfield.md +++ b/docs/content_management/field_types/field_type_reference/matrixfield.md @@ -19,6 +19,8 @@ The Matrix field type is available via the Matrix Bundle provided by the [ibexa/ Example of input: ```php +use Ibexa\FieldTypeMatrix\FieldType; + new FieldType\Value([ new FieldType\Value\Row(['col1' => 'Row 1, Col 1', 'col2' => 'Row 1, Col 2']), new FieldType\Value\Row(['col1' => 'Row 2, Col 1', 'col2' => 'Row 2, Col 2']), @@ -47,6 +49,8 @@ If, after removing empty rows, the number of rows doesn't fulfill the configured For example, the following input doesn't validate if `Minimum number of rows` is set to 3, because the second row is empty: ```php +use Ibexa\FieldTypeMatrix\FieldType; + new FieldType\Value([ new FieldType\Value\Row(['col1' => 'Row 1, Col 1', 'col2' => 'Row 1, Col 2']), new FieldType\Value\Row(['col1' => '', 'col2' => '']), diff --git a/docs/content_management/field_types/field_type_reference/measurementfield.md b/docs/content_management/field_types/field_type_reference/measurementfield.md index 5db02da753..502d6b0a0d 100644 --- a/docs/content_management/field_types/field_type_reference/measurementfield.md +++ b/docs/content_management/field_types/field_type_reference/measurementfield.md @@ -45,10 +45,12 @@ Depending on the selected input type, the object resembles the following example ``` php // Simple input (single value) example -// @var MeasurementServiceInterface $measurementService +use Ibexa\Measurement\FieldType\MeasurementValue as Measurement; + +/** @var \Ibexa\Contracts\Measurement\MeasurementServiceInterface $measurementService */ // Instantiates a Measurement Value object -$measurementValue = new Measurement\Value( +$measurementValue = new Measurement( $measurementService->buildSimpleValue( 'length', 13.5, @@ -60,10 +62,12 @@ $measurementValue = new Measurement\Value( ``` php // Range input value example -// @var MeasurementServiceInterface $measurementService +use Ibexa\Measurement\FieldType\MeasurementValue as Measurement; + +/** @var \Ibexa\Contracts\Measurement\MeasurementServiceInterface $measurementService */ // Instantiates a Measurement Value object -$measurementValue = new Measurement\Value( +$measurementValue = new Measurement( $measurementService->buildRangeValue( 'volume', 0.5, diff --git a/docs/content_management/field_types/field_type_reference/mediafield.md b/docs/content_management/field_types/field_type_reference/mediafield.md index 42c04d15b9..a1d49b6a45 100644 --- a/docs/content_management/field_types/field_type_reference/mediafield.md +++ b/docs/content_management/field_types/field_type_reference/mediafield.md @@ -76,6 +76,7 @@ The field type supports `FileSizeValidator`, defining maximum size of media file use Ibexa\Core\FieldType\Media\Type; +/** @var \Ibexa\Contracts\Core\Repository\Repository $repository */ $contentTypeService = $repository->getContentTypeService(); $mediaFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( "media", "ibexa_media" ); @@ -112,6 +113,7 @@ List of all available `mediaType` constants is defined in the `Ibexa\Core\FieldT use Ibexa\Core\FieldType\Media\Type; +/** @var \Ibexa\Contracts\Core\Repository\Repository $repository */ $contentTypeService = $repository->getContentTypeService(); $mediaFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( "media", "ibexa_media" ); diff --git a/docs/content_management/field_types/field_type_reference/relationfield.md b/docs/content_management/field_types/field_type_reference/relationfield.md index 6f8b9a8543..08d02a58c3 100644 --- a/docs/content_management/field_types/field_type_reference/relationfield.md +++ b/docs/content_management/field_types/field_type_reference/relationfield.md @@ -28,6 +28,8 @@ The Value class of this field type contains the following properties: ``` php // Value object content example +/** @var \Ibexa\Core\FieldType\Relation\Value $relation */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ $relation->destinationContentId = $contentInfo->id; ``` @@ -37,7 +39,9 @@ The `Relation\Value` constructor initializes a new value object with the value p ``` php // Constructor example +use Ibexa\Core\FieldType\Relation as Relation; +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ // Instantiates a Relation Value object $relationValue = new Relation\Value( $contentInfo->id ); ``` diff --git a/docs/content_management/field_types/field_type_reference/relationlistfield.md b/docs/content_management/field_types/field_type_reference/relationlistfield.md index f920a2a9ae..45813c490e 100644 --- a/docs/content_management/field_types/field_type_reference/relationlistfield.md +++ b/docs/content_management/field_types/field_type_reference/relationlistfield.md @@ -29,7 +29,10 @@ This field type makes it possible to store and retrieve values of a relation to ``` php // Value object content example -$relationList->destinationContentId = [ +/** @var \Ibexa\Core\FieldType\RelationList\Value $relationList */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo1 */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo2 */ +$relationList->destinationContentIds = [ $contentInfo1->id, $contentInfo2->id, 170 @@ -43,7 +46,10 @@ It expects a mixed array as value. ``` php //Constructor example +use Ibexa\Core\FieldType\RelationList as RelationList; +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo1 */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo2 */ // Instantiates a RelationList Value object $relationListValue = new RelationList\Value( [ diff --git a/docs/content_management/field_types/field_type_reference/richtextfield.md b/docs/content_management/field_types/field_type_reference/richtextfield.md index 0f6605a0ba..9581fa3e19 100644 --- a/docs/content_management/field_types/field_type_reference/richtextfield.md +++ b/docs/content_management/field_types/field_type_reference/richtextfield.md @@ -71,6 +71,8 @@ You can use the [[= product_name_base =]] flavor of the DocBook format in PHP AP The following example shows how to pass DocBook content to a [create struct](creating_content.md#creating-content-item-draft): ``` php +/** @var \Ibexa\Contracts\Core\Repository\ContentService $contentService */ +/** @var \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType */ $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, "eng-GB" ); $inputString = <<selection = 1; // Multiple selection @@ -40,6 +42,7 @@ The `Selection\Value` constructor accepts an array of selected element identifie ``` php // Constructor example +use Ibexa\Core\FieldType\Selection as Selection; // Instanciates a selection value with items #1 and #2 selected $selectionValue = new Selection\Value( [ 1, 2 ] ); diff --git a/docs/content_management/field_types/field_type_reference/taxonomyentryassignmentfield.md b/docs/content_management/field_types/field_type_reference/taxonomyentryassignmentfield.md index 476c043d1f..e6539d9789 100644 --- a/docs/content_management/field_types/field_type_reference/taxonomyentryassignmentfield.md +++ b/docs/content_management/field_types/field_type_reference/taxonomyentryassignmentfield.md @@ -24,6 +24,9 @@ To be able to assign tags to the content, first, you need to add a `TaxonomyEntr Example using an `Ibexa\Taxonomy\FieldType\TaxonomyEntryAssignment\Value` object: ``` php +use Ibexa\Contracts\Taxonomy\Service\TaxonomyServiceInterface; + +/** @var object{taxonomyService: TaxonomyServiceInterface} $this */ $taxonomyEntry1 = $this->taxonomyService->loadEntryByIdentifier('example_entry', 'tags'); $taxonomyEntry2 = $this->taxonomyService->loadEntryByIdentifier('example_entry_2', 'tags'); new \Ibexa\Taxonomy\FieldType\TaxonomyEntryAssignment\Value( @@ -38,10 +41,14 @@ new \Ibexa\Taxonomy\FieldType\TaxonomyEntryAssignment\Value( Example using array: ``` php -[ +use Ibexa\Contracts\Taxonomy\Value\TaxonomyEntry; + +/** @var TaxonomyEntry $taxonomyEntry */ +/** @var TaxonomyEntry $taxonomyEntry2 */ +return [ 'taxonomy_entries' => [$taxonomyEntry, $taxonomyEntry2], // load entries using TaxonomyService 'taxonomy' => 'tags', -] +]; ``` ### Value object diff --git a/docs/content_management/field_types/field_type_reference/taxonomyentryfield.md b/docs/content_management/field_types/field_type_reference/taxonomyentryfield.md index 1fdbb9ec8b..42bdebc72e 100644 --- a/docs/content_management/field_types/field_type_reference/taxonomyentryfield.md +++ b/docs/content_management/field_types/field_type_reference/taxonomyentryfield.md @@ -18,18 +18,20 @@ A `TaxonomyEntry` field accepts an array with an `Ibexa\Contracts\Taxonomy\Value Example using an `Ibexa\Taxonomy\FieldType\TaxonomyEntry\Value` object: ``` php +use Ibexa\Contracts\Taxonomy\Service\TaxonomyServiceInterface; + +/** @var object{taxonomyService: TaxonomyServiceInterface} $this */ $taxonomyEntry = $this->taxonomyService->loadEntryByIdentifier('example_entry', 'tags'); -new \Ibexa\Taxonomy\FieldType\TaxonomyEntry\Value( - new \Ibexa\Contracts\Taxonomy\Value\TaxonomyEntry( - $taxonomyEntry - ) -); +$taxonomyEntryField = new \Ibexa\Taxonomy\FieldType\TaxonomyEntry\Value($taxonomyEntry); ``` Example using array: ``` php -[ +use Ibexa\Contracts\Taxonomy\Value\TaxonomyEntry; + +/** @var TaxonomyEntry $taxonomyEntry */ +return [ 'taxonomy_entry' => $taxonomyEntry, // load Entry using TaxonomyService -] +]; ``` ### Value object @@ -46,14 +48,17 @@ The constructor accepts an `Ibexa\Contracts\Taxonomy\Value\TaxonomyEntry` object ``` php // Constructor example +use Ibexa\Contracts\Taxonomy\Service\TaxonomyServiceInterface; use Ibexa\Taxonomy\FieldType\TaxonomyEntry; // Fetches TaxonomyEntry from TaxonomyService -$taxonomyEntry = $this->taxonomyService->loadEntryByIdentifier('example_entry', 'tags'); -  +/** @var TaxonomyServiceInterface $taxonomyService */ +$taxonomyEntry = $taxonomyService->loadEntryByIdentifier('example_entry', 'tags'); + // Instantiates a checkbox value with a checked state $taxonomyEntryFieldTypeValue = new TaxonomyEntry\Value($taxonomyEntry); ``` + #### String representation `taxonomyEntry` string identifier or empty string if no Taxonomy Entry is selected. diff --git a/docs/content_management/field_types/field_type_reference/textlinefield.md b/docs/content_management/field_types/field_type_reference/textlinefield.md index 7867869265..5a94443f6e 100644 --- a/docs/content_management/field_types/field_type_reference/textlinefield.md +++ b/docs/content_management/field_types/field_type_reference/textlinefield.md @@ -36,10 +36,10 @@ The default value for both properties is 0, which means that the validation is d To set the validation properties, the `validateValidatorConfiguration()` method needs to be inspected, which receives an array with `minStringLength` and `maxStringLength` like in the following representation: ```php -[ +return [ 'StringLengthValidator' => [ - 'maxStringLength' => 60 + 'maxStringLength' => 60, 'minStringLength' => 1 ] -] +]; ``` diff --git a/docs/content_management/field_types/field_type_reference/timefield.md b/docs/content_management/field_types/field_type_reference/timefield.md index 8fc0bd7916..71e6448425 100644 --- a/docs/content_management/field_types/field_type_reference/timefield.md +++ b/docs/content_management/field_types/field_type_reference/timefield.md @@ -75,7 +75,7 @@ The Field definition of this field type can be configured with several options: use Ibexa\Core\FieldType\Time\Type; $settings = [ - "defaultType" => DateAndTime::DEFAULT_EMPTY + "defaultType" => Type::DEFAULT_EMPTY ]; ``` diff --git a/docs/content_management/field_types/field_type_reference/urlfield.md b/docs/content_management/field_types/field_type_reference/urlfield.md index 5a29baa0e2..1caac1b7e0 100644 --- a/docs/content_management/field_types/field_type_reference/urlfield.md +++ b/docs/content_management/field_types/field_type_reference/urlfield.md @@ -30,6 +30,7 @@ The Value class of this field type contains the following properties: ``` php // Value object content example +/** @var \Ibexa\Core\FieldType\Url\Value $url */ $url->link = "https://www.ibexa.co"; $url->text = "Ibexa"; ``` @@ -41,6 +42,7 @@ It expects two comma-separated strings, corresponding to the link and text. ``` php // Constructor example +use Ibexa\Core\FieldType\Url as Url; // Instantiates an Url Value object $UrlValue = new Url\Value( "https://www.ibexa.co/", "Ibexa" ); diff --git a/docs/content_management/field_types/field_type_search.md b/docs/content_management/field_types/field_type_search.md index 55f8559d12..d1d2fc7fc6 100644 --- a/docs/content_management/field_types/field_type_search.md +++ b/docs/content_management/field_types/field_type_search.md @@ -22,10 +22,12 @@ They're described below in further detail. To be able to query data properly an indexable field type also is required to return search specification. You must return an associative array of `Ibexa\Contracts\Core\Search\FieldType` instances from this method, which could look like: ```php -[ +use Ibexa\Contracts\Core\Search; + +return [ 'url' => new Search\FieldType\StringField(), 'text' => new Search\FieldType\StringField(), -] +]; ``` This example from the `Url` field type shows that the field type always returns two indexable values, both strings. diff --git a/docs/content_management/field_types/field_type_validation.md b/docs/content_management/field_types/field_type_validation.md index d2f9a5553a..a8bc9735a2 100644 --- a/docs/content_management/field_types/field_type_validation.md +++ b/docs/content_management/field_types/field_type_validation.md @@ -18,14 +18,14 @@ except it has an additional level, to group settings for a certain validation me For example, for the `ibexa_string` type, the validator schema could be: ``` php -[ +return [ 'stringLength' => [ 'minStringLength' => [ 'type' => 'int', 'default' => 0, ], 'maxStringLength' => [ - 'type' => 'int' + 'type' => 'int', 'default' => null, ] ], diff --git a/docs/content_management/field_types/form_and_template.md b/docs/content_management/field_types/form_and_template.md index 9babd387cc..bf5958d20e 100644 --- a/docs/content_management/field_types/form_and_template.md +++ b/docs/content_management/field_types/form_and_template.md @@ -25,30 +25,35 @@ You have to add your form type to the content editing form. The example shows ho ``` php use Ibexa\Contracts\ContentForms\Data\Content\FieldData; +use Ibexa\Contracts\ContentForms\FieldType\FieldValueFormMapperInterface; use Ibexa\ContentForms\Form\Type\FieldType\CheckboxFieldType; use Symfony\Component\Form\FormInterface; -public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) +class MyMapper implements FieldValueFormMapperInterface { - $fieldDefinition = $data->fieldDefinition; - $formConfig = $fieldForm->getConfig(); - - $fieldForm - ->add( - $formConfig->getFormFactory()->createBuilder() - ->create( - 'value', - CheckboxFieldType::class, - [ - 'required' => $fieldDefinition->isRequired, - 'label' => $fieldDefinition->getName( - $formConfig->getOption('languageCode') - ), - ] - ) - ->setAutoInitialize(false) - ->getForm() - ); + /** @param FormInterface $fieldForm */ + public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void + { + $fieldDefinition = $data->getFieldDefinition(); + $formConfig = $fieldForm->getConfig(); + + $fieldForm + ->add( + $formConfig->getFormFactory()->createBuilder() + ->create( + 'value', + CheckboxFieldType::class, + [ + 'required' => $fieldDefinition->isRequired, + 'label' => $fieldDefinition->getName( + $formConfig->getOption('languageCode') + ), + ] + ) + ->setAutoInitialize(false) + ->getForm() + ); + } } ``` @@ -64,37 +69,43 @@ You can use a [`DataTransformer`]([[= symfony_doc =]]/form/data_transformers.htm Providing definition editing support is almost identical to creating content editing support. The only difference are field names: ``` php +use Ibexa\AdminUi\FieldType\FieldDefinitionFormMapperInterface; use Ibexa\AdminUi\Form\Data\FieldDefinitionData; use Ibexa\ContentForms\Form\Type\FieldType\CountryFieldType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\FormInterface; -public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data) + +class MyMapper implements FieldDefinitionFormMapperInterface { - $fieldDefinitionForm - ->add( - 'isMultiple', - CheckboxType::class, [ - 'required' => false, - 'property_path' => 'fieldSettings[isMultiple]', - 'label' => 'field_definition.ibexa_country.is_multiple', - ] - ) - ->add( - $fieldDefinitionForm->getConfig()->getFormFactory()->createBuilder() - ->create( - 'defaultValue', - CountryFieldType::class, [ - 'choices_as_values' => true, - 'multiple' => true, - 'expanded' => false, - 'required' => false, - 'label' => 'field_definition.ibexa_country.default_value', - ] - ) - // Deactivate auto-initialize as you're not on the root form. - ->setAutoInitialize(false)->getForm() - ); + /** @param FormInterface $fieldDefinitionForm */ + public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data): void + { + $fieldDefinitionForm + ->add( + 'isMultiple', + CheckboxType::class, [ + 'required' => false, + 'property_path' => 'fieldSettings[isMultiple]', + 'label' => 'field_definition.ibexa_country.is_multiple', + ] + ) + ->add( + $fieldDefinitionForm->getConfig()->getFormFactory()->createBuilder() + ->create( + 'defaultValue', + CountryFieldType::class, [ + 'choices_as_values' => true, + 'multiple' => true, + 'expanded' => false, + 'required' => false, + 'label' => 'field_definition.ibexa_country.default_value', + ] + ) + // Deactivate auto-initialize as you're not on the root form. + ->setAutoInitialize(false)->getForm() + ); + } } ``` diff --git a/docs/content_management/field_types/type_and_value.md b/docs/content_management/field_types/type_and_value.md index 1b03733f65..a8d4a4f5f0 100644 --- a/docs/content_management/field_types/type_and_value.md +++ b/docs/content_management/field_types/type_and_value.md @@ -169,7 +169,7 @@ It's recommended to use a simple associative array format for the settings schem An example schema could look like this: ``` php -[ +return [ 'backupData' => [ 'type' => 'bool', 'default' => false diff --git a/docs/content_management/file_management/file_management.md b/docs/content_management/file_management/file_management.md index bedce65245..948ba64762 100644 --- a/docs/content_management/file_management/file_management.md +++ b/docs/content_management/file_management/file_management.md @@ -9,8 +9,10 @@ description: Configurations and management of binary files. To access binary files from the PHP API, use the `Ibexa\Core\IO\IOServiceInterface::loadBinaryFile()` method: ```php -$file = $this->ioService->loadBinaryFile($field->value->id); -$fileContent = $this->ioService->getFileContents($file); +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Field $field */ +/** @var \Ibexa\Core\IO\IOServiceInterface $ioService */ +$file = $ioService->loadBinaryFile($field->value->id); +$fileContent = $ioService->getFileContents($file); ``` ## Handling binary files diff --git a/docs/content_management/images/configure_image_editor.md b/docs/content_management/images/configure_image_editor.md index ed37e270ec..8214f219aa 100644 --- a/docs/content_management/images/configure_image_editor.md +++ b/docs/content_management/images/configure_image_editor.md @@ -52,7 +52,9 @@ By default, additional information stores the coordinates of the [focal point]([ To modify the value of additional information programmatically, you can set a value of the `Image` field by using the PHP API, for example: ``` php -new FieldValue([ +use Ibexa\Core\FieldType\Image\Value as FieldValue; + +$value = new FieldValue([ 'data' => [ 'width' => '100', 'height' => '200', @@ -66,5 +68,5 @@ new FieldValue([ 'author' => 'John Smith', ], ], - ]), + ]); ``` diff --git a/docs/content_management/taxonomy/taxonomy_api.md b/docs/content_management/taxonomy/taxonomy_api.md index 613abecde4..98ea9ff85b 100644 --- a/docs/content_management/taxonomy/taxonomy_api.md +++ b/docs/content_management/taxonomy/taxonomy_api.md @@ -21,9 +21,11 @@ and use `TaxonomyServiceInterface::loadEntryByIdentifier()`: A taxonomy entry identifier is unique per taxonomy. If you have [several taxonomies](taxonomy.md#customize-taxonomy-structure), you can increase code readability by always passing the taxonomy identifier even when it's the default one. The default taxonomy is `tags` if it exists, else the first configured taxonomy (see `\Ibexa\Taxonomy\Service\TaxonomyConfiguration::getDefaultTaxonomyName` for details). ``` php - $springs[] = $this->taxonomyService->loadEntryByIdentifier('spring', 'tags'); - $springs[] = $this->taxonomyService->loadEntryByIdentifier('spring', 'events'); - $springs[] = $this->taxonomyService->loadEntryByIdentifier('spring', 'devices'); + /** @var array $springs */ + /** @var \Ibexa\Contracts\Taxonomy\Service\TaxonomyServiceInterface $taxonomyService */ + $springs[] = $taxonomyService->loadEntryByIdentifier('spring', 'tags'); + $springs[] = $taxonomyService->loadEntryByIdentifier('spring', 'events'); + $springs[] = $taxonomyService->loadEntryByIdentifier('spring', 'devices'); ``` You can also get a taxonomy entry from the ID of its underlying content item, by using `TaxonomyServiceInterface::loadEntryByContentId()`. diff --git a/docs/content_management/url_management/url_management.md b/docs/content_management/url_management/url_management.md index a9416514a5..18ff3513f2 100644 --- a/docs/content_management/url_management/url_management.md +++ b/docs/content_management/url_management/url_management.md @@ -119,7 +119,7 @@ interface URLHandlerInterface * * @param \Ibexa\Contracts\Core\Repository\Values\URL\URL[] $urls */ - public function validate(array $urls); + public function validate(array $urls): void; } ``` @@ -249,12 +249,13 @@ The **URL wildcards** tab contains all the information about each URL wildcard. You can create URL wildcards with the public PHP API by using the `URLWildcardService` service: ``` php +/** @var \Ibexa\Contracts\Core\Repository\Repository $repository */ $source = 'pictures/*/*'; $destination = 'media/images/{1}/{2}'; $redirect = true; $urlWildcardService = $repository->getURLWildcardService(); -$repository->sudo(function ($repository) use ($urlWildcardService, $source, $destination, $redirect) { +$repository->sudo(function ($repository) use ($urlWildcardService, $source, $destination, $redirect): void { $urlWildcardService->create($source, $destination, $redirect); }); ``` diff --git a/docs/content_management/workflow/add_custom_workflow_action.md b/docs/content_management/workflow/add_custom_workflow_action.md index fc8c8fdcf7..77df1169d2 100644 --- a/docs/content_management/workflow/add_custom_workflow_action.md +++ b/docs/content_management/workflow/add_custom_workflow_action.md @@ -81,6 +81,8 @@ You can also modify the context using the `setContext()` method. For example, you can override the message typed by the user: ``` php +/** @var array $context */ +/** @var \Symfony\Component\Workflow\Event\TransitionEvent $event */ $new_context = $context; $new_context['message'] = "This article went through proofreading"; $event->setContext($new_context); diff --git a/docs/infrastructure_and_maintenance/cache/http_cache/content_aware_cache.md b/docs/infrastructure_and_maintenance/cache/http_cache/content_aware_cache.md index ae176fac6d..be1894f3ab 100644 --- a/docs/infrastructure_and_maintenance/cache/http_cache/content_aware_cache.md +++ b/docs/infrastructure_and_maintenance/cache/http_cache/content_aware_cache.md @@ -154,6 +154,9 @@ Examples for tagging everything needed for content using the autowireable `Respo ``` php /** @var \Ibexa\Contracts\HttpCache\ResponseTagger\ResponseTagger $responseTagger */ +/** @var \Ibexa\Core\MVC\Symfony\View\ContentView $view */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */ // If you have a View object you can simply call: $responseTagger->tag($view); @@ -169,6 +172,8 @@ Examples for adding specific content tags using the autowireable `ContentTagInte ``` php /** @var \Ibexa\Contracts\HttpCache\Handler\ContentTagInterface $tagHandler */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */ // Example for tagging everything needed for Content: $tagHandler->addContentTags([$content->id]); @@ -188,6 +193,8 @@ In PHP, FOSHttpCache exposes the `fos_http_cache.http.symfony_response_tagger` s The following example adds minimal tags when ID 33 and 34 are rendered in ESI, but parent response needs these tags to get refreshed if they're deleted: ``` php +use Ibexa\Contracts\HttpCache\Handler\ContentTagInterface; + /** @var \FOS\HttpCacheBundle\Http\SymfonyResponseTagger $responseTagger */ $responseTagger->addTags([ContentTagInterface::RELATION_PREFIX . '33', ContentTagInterface::RELATION_PREFIX . '34']); ``` @@ -201,7 +208,7 @@ It supports singular and comma-separated location ID value(s): ```php /** @var \Symfony\Component\HttpFoundation\Response $response */ -$response->headers->set('X-Location-Id', 123); +$response->headers->set('X-Location-Id', '123'); // Alternatively using several Location ID values $response->headers->set('X-Location-Id', '123,212,42'); @@ -320,7 +327,10 @@ While the system purges tags whenever API is used to change data, you may need t For that you can use the built-in purge client: ```php +use Ibexa\Contracts\HttpCache\Handler\ContentTagInterface; + /** @var \Ibexa\Contracts\HttpCache\PurgeClient\PurgeClientInterface $purgeClient */ +/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */ // Example for purging by Location ID: $purgeClient->purge([ContentTagInterface::LOCATION_PREFIX . $location->id]); diff --git a/docs/infrastructure_and_maintenance/cache/http_cache/context_aware_cache.md b/docs/infrastructure_and_maintenance/cache/http_cache/context_aware_cache.md index 9d299b4f34..bdc416d416 100644 --- a/docs/infrastructure_and_maintenance/cache/http_cache/context_aware_cache.md +++ b/docs/infrastructure_and_maintenance/cache/http_cache/context_aware_cache.md @@ -92,8 +92,11 @@ This a low effort solution, and can be enough for one fragment that is reused ac Example: ```php - // Inside a custom controller action, or even a Content View controller - $response->setVary('Cookie'); +use Symfony\Component\HttpFoundation\Response; + +// Inside a custom controller action, or even a Content View controller +/** @var Response $response */ +$response->setVary('Cookie'); ``` 2\. Ajax/JS lookup to "uncached" custom Symfony controllers: @@ -140,14 +143,26 @@ To avoid overloading any application code, take advantage of Symfony's event sys 1\. Add a [Response event (`kernel.response`)]([[= symfony_doc =]]/reference/events.html#kernel-response) [listener or subscriber]([[= symfony_doc =]]/event_dispatcher.html) to add your own hash to `/_fos_user_context_hash`: ```php -public function addPreferenceHash(FilterResponseEvent $event) +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\Event\ResponseEvent; + +final class MyEventSubscriber implements EventSubscriberInterface { - $response = $event->getResponse(); - if ($response->headers->get('Content-Type') !== 'application/vnd.fos.user-context-hash') { - return; + /** @return array> */ + public static function getSubscribedEvents(): array + { + return []; } - $response->headers->set('X-User-Preference-Hash', ''); + public function addPreferenceHash(ResponseEvent $event): void + { + $response = $event->getResponse(); + if ($response->headers->get('Content-Type') !== 'application/vnd.fos.user-context-hash') { + return; + } + + $response->headers->set('X-User-Preference-Hash', ''); + } } ``` @@ -187,6 +202,9 @@ public function addPreferenceHash(FilterResponseEvent $event) 3\. Add `Vary` in your custom controller or content view controller: ```php +use Symfony\Component\HttpFoundation\Response; + +/** @var Response $response */ $response->setVary('X-User-Preference-Hash'); // If you _also_ need to vary on [[= product_name =]] permissions, instead use: diff --git a/docs/infrastructure_and_maintenance/cache/http_cache/reverse_proxy.md b/docs/infrastructure_and_maintenance/cache/http_cache/reverse_proxy.md index bd8f0921b0..51a11cdf72 100644 --- a/docs/infrastructure_and_maintenance/cache/http_cache/reverse_proxy.md +++ b/docs/infrastructure_and_maintenance/cache/http_cache/reverse_proxy.md @@ -91,7 +91,10 @@ framework: For this reason, the `TRUSTED_PROXIES` env variable supports being set to value `REMOTE_ADDR`, which is equal to: ```php - Request::setTrustedProxies([$request->server->get('REMOTE_ADDR')], Request::HEADER_X_FORWARDED_ALL); + use Symfony\Component\HttpFoundation\Request; + + /** @var \Symfony\Component\HttpFoundation\Request $request */ + Request::setTrustedProxies([$request->server->get('REMOTE_ADDR')], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PREFIX); ``` When trusting remote IP like this, make sure your application is only accessible through Varnish. diff --git a/docs/infrastructure_and_maintenance/cache/persistence_cache.md b/docs/infrastructure_and_maintenance/cache/persistence_cache.md index ece1462733..82a8a11493 100644 --- a/docs/infrastructure_and_maintenance/cache/persistence_cache.md +++ b/docs/infrastructure_and_maintenance/cache/persistence_cache.md @@ -249,10 +249,14 @@ This service is an instance of `Symfony\Component\Cache\Adapter\TagAwareAdapterI Like any other service, you can also get the cache service with the [service container](php_api.md#service-container) like so: ``` php +use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + // Getting the cache service in PHP -/** @var \Symfony\Component\Cache\Adapter\TagAwareAdapterInterface */ +/** @var ContainerInterface $container */ $pool = $container->get('ibexa.cache_pool'); +/** @var TagAwareAdapterInterface $pool */ ``` ### Using the cache service @@ -260,13 +264,20 @@ $pool = $container->get('ibexa.cache_pool'); Example usage of the cache service: ``` php +use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + // Example +/** @var TagAwareAdapterInterface $pool */ +/** @var ContainerInterface $container */ +/** @var int $id */ $cacheItem = $pool->getItem("myApp-object-${id}"); if ($cacheItem->isHit()) { return $cacheItem->get(); } -$myObject = $container->get('my_app.backend_service')->loadObject($id) +// @phpstan-ignore-next-line +$myObject = $container->get('my_app.backend_service')->loadObject($id); $cacheItem->set($myObject); $cacheItem->tag(['myApp-category-' . $myObject->categoryId]); $pool->save($cacheItem); @@ -281,6 +292,10 @@ For more info on usage, see [Symfony Cache's documentation]([[= symfony_doc =]]/ Persistence cache prefixes it's cache using "ibx-". Clearing persistence cache can thus be done in the following ways: ``` php +use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; + +/** @var TagAwareAdapterInterface $pool */ +/** @var int $contentId */ // To clear all cache (not recommended without a good reason) $pool->clear(); diff --git a/docs/multisite/languages/back_office_translations.md b/docs/multisite/languages/back_office_translations.md index 2cc69f5143..fceef96cbd 100644 --- a/docs/multisite/languages/back_office_translations.md +++ b/docs/multisite/languages/back_office_translations.md @@ -59,22 +59,24 @@ The method takes as arguments: Here's an example: ``` php hl_lines="13 14 15" -use Symfony\Component\Translation\TranslatorInterface; - -private $translator; - -public function __construct(TranslatorInterface $translator) -{ - $this->translator = $translator; -} - -private function getTranslatedDescription(): string -{ - return $this->translator->trans( - 'custom.extension.description', - [], - 'custom_extension' - ); +use Symfony\Contracts\Translation\TranslatorInterface; + +final class MyService { + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function getTranslatedDescription(): string + { + return $this->translator->trans( + 'custom.extension.description', + [], + 'custom_extension' + ); + } } ``` diff --git a/docs/multisite/siteaccess/injecting_siteaccess.md b/docs/multisite/siteaccess/injecting_siteaccess.md index 66d6f862c8..dc35ae3f49 100644 --- a/docs/multisite/siteaccess/injecting_siteaccess.md +++ b/docs/multisite/siteaccess/injecting_siteaccess.md @@ -26,11 +26,11 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface; class MyService { - /** @var \Ibexa\Contracts\Core\Repository\ContentService */ - private $contentService; + /** @phpstan-ignore property.onlyWritten */ + private ContentService $contentService; - /** @var \Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface */ - private $siteAccessService; + /** @phpstan-ignore property.onlyWritten */ + private SiteAccessServiceInterface $siteAccessService; public function __construct( SiteAccessServiceInterface $siteAccessService, diff --git a/docs/multisite/siteaccess/siteaccess_aware_configuration.md b/docs/multisite/siteaccess/siteaccess_aware_configuration.md index 1d3a656ab4..b79d3c0e72 100644 --- a/docs/multisite/siteaccess/siteaccess_aware_configuration.md +++ b/docs/multisite/siteaccess/siteaccess_aware_configuration.md @@ -28,7 +28,11 @@ The example below assumes you're using an `Acme\ExampleBundle`. Remember to register the bundle by adding it to `config/bundles.php`: ``` php -Acme\ExampleBundle\AcmeExampleBundle::class => ['all' => true], +return [ + // ... + // @phpstan-ignore-next-line + Acme\ExampleBundle\AcmeExampleBundle::class => ['all' => true], +]; ``` ### Parsing semantic configuration diff --git a/docs/permissions/custom_policies.md b/docs/permissions/custom_policies.md index 927e0f868c..b86681af0c 100644 --- a/docs/permissions/custom_policies.md +++ b/docs/permissions/custom_policies.md @@ -21,7 +21,7 @@ Function value is an array of available limitations, identified by the alias dec If no limitation is provided, value can be `null` or an empty array. ``` php -[ +return [ "content" => [ "read" => ["Class", "ParentClass", "Node", "Language"], "edit" => ["Class", "ParentClass", "Language"] @@ -30,7 +30,7 @@ If no limitation is provided, value can be `null` or an empty array. "custom_function_1" => null, "custom_function_2" => ["CustomLimitation"] ], -] +]; ``` Limitations need to be implemented as *Limitation types* and declared as services identified with `ibexa.permissions.limitation_type` tag. @@ -48,7 +48,7 @@ use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\PolicyProvider class MyPolicyProvider implements PolicyProviderInterface { - public function addPolicies(ConfigBuilderInterface $configBuilder) + public function addPolicies(ConfigBuilderInterface $configBuilder): void { $configBuilder->addConfig([ "custom_module" => [ @@ -102,10 +102,12 @@ namespace App\Security; use Ibexa\Bundle\Core\DependencyInjection\Configuration\ConfigBuilderInterface; use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface; +use JMS\TranslationBundle\Model\Message; +use JMS\TranslationBundle\Translation\TranslationContainerInterface; class MyPolicyProvider implements PolicyProviderInterface, TranslationContainerInterface { - public function addPolicies(ConfigBuilderInterface $configBuilder) + public function addPolicies(ConfigBuilderInterface $configBuilder): void { $configBuilder->addConfig([ "custom_module" => [ @@ -115,6 +117,7 @@ class MyPolicyProvider implements PolicyProviderInterface, TranslationContainerI ]); } + /** @return array<\JMS\TranslationBundle\Model\Message> */ public static function getTranslationMessages(): array { return [ diff --git a/docs/permissions/permission_overview.md b/docs/permissions/permission_overview.md index 6a8b2f1dbe..dc2b4502ad 100644 --- a/docs/permissions/permission_overview.md +++ b/docs/permissions/permission_overview.md @@ -38,7 +38,7 @@ You can control access to a custom controller by implementing the `performAccess In the following example the user doesn't have access to the controller unless they have the `section/view` policy: -``` php +``` php skip-validation use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; public function performAccessCheck(): void @@ -63,7 +63,7 @@ public function performAccessCheck(): void To check if a user has access to an operation, use the `isGranted()` method. For example, to check if content can be assigned to a Section: -``` php +``` php skip-validation $hasAccess = $this->isGranted( new Attribute('section', 'assign', ['valueObject' => $contentInfo, 'targets' => [$section]]) ); @@ -79,6 +79,6 @@ checks the `content/edit` permission for the provided content item at the provid To block access to a specific action of the controller, add the following to the action's definition: -``` php +``` php skip-validation $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); ``` diff --git a/docs/personalization/enable_personalization.md b/docs/personalization/enable_personalization.md index 7d3d2b4f17..8d6f47628f 100644 --- a/docs/personalization/enable_personalization.md +++ b/docs/personalization/enable_personalization.md @@ -492,11 +492,18 @@ To modify recommendation data, subscribe to `RecommendationResponseEvent`. See [`Event/Subscriber/RecommendationEventSubscriber.php`](https://github.com/ibexa/personalization-client/blob/main/src/lib/Event/Subscriber/RecommendationEventSubscriber.php) for an example: ``` php -public static function getSubscribedEvents(): array +use Ibexa\Personalization\Event\RecommendationResponseEvent; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +final class MyRecommendationEventSubscriber implements EventSubscriberInterface { - return [ - RecommendationResponseEvent::class => ['onRecommendationResponse', -10], - ]; + /** @return array> */ + public static function getSubscribedEvents(): array + { + return [ + RecommendationResponseEvent::class => ['onRecommendationResponse', -10], + ]; + } } ``` diff --git a/docs/personalization/integrate_recommendation_service.md b/docs/personalization/integrate_recommendation_service.md index a2049f526c..bcf65031ab 100644 --- a/docs/personalization/integrate_recommendation_service.md +++ b/docs/personalization/integrate_recommendation_service.md @@ -39,7 +39,8 @@ $mandator_id = '00000'; $content_type_id = '1'; $product_id = '123'; $server = '//event.perso.ibexa.co'; -$tracking = $server.'/api/'.$mandator_id.'/click/'.urlencode(user_id()).$content_type_id.$product_id; +/** @var string $userId */ +$tracking = $server.'/api/'.$mandator_id.'/click/'.urlencode($userId).$content_type_id.$product_id; echo ""; ``` @@ -59,8 +60,13 @@ A similar tracking image can be placed on a confirmation page that ends the paym ``` php $server = '//event.perso.ibexa.co'; +/** @var array $just_bought_products */ +/** @var string $mandator_id */ +/** @var string $content_type_id */ +/** @var string $userId */ +$buyBaseUrl = $server.'/api/'.$mandator_id.'/buy/'.urlencode($userId); foreach ($just_bought_products as $product_id) { - $tracking = $server.'/api/'.$mandator_id.'/buy/'.urlencode(user_id()).$content_type_id.$product_id; + $tracking = $buyBaseUrl.$content_type_id.$product_id; echo "\n"; } ``` @@ -127,7 +133,8 @@ $mandator_id = '00000'; $license_key = '67890-1234-5678-90123-4567'; $server = "https://reco.perso.ibexa.co"; $scenario = "category_page"; -$url = $server.'/api/v2/00000/'.urlencode(user_id()).'/'.urlencode($scenario).'.json'; +/** @var string $userId */ +$url = $server.'/api/v2/00000/'.urlencode($userId).'/'.urlencode($scenario).'.json'; $curl = curl_init(); $request = array( @@ -135,7 +142,7 @@ $request = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_USERPWD => "$mandator_id:$license_key"); curl_setopt_array($curl, $request); -$body = curl_exec($curl); +$body = (string) curl_exec($curl); $recommendations = json_decode($body); if ($recommendations && isset($recommendations->recommendationResponseList)) { foreach ($recommendations->recommendationResponseList as $product) { diff --git a/docs/release_notes/ez_platform_v2.4.md b/docs/release_notes/ez_platform_v2.4.md index 16d92cbdb2..4fb51d888b 100644 --- a/docs/release_notes/ez_platform_v2.4.md +++ b/docs/release_notes/ez_platform_v2.4.md @@ -182,7 +182,7 @@ The biggest benefit of this feature is saving load time on complex landing pages 1\. Register `LexikJWTAuthenticationBundle` bundle in `/app/AppKernel.php` - ``` php + ``` php skip-validation public function registerBundles() { $bundles = array( diff --git a/docs/release_notes/ez_platform_v3.0_deprecations.md b/docs/release_notes/ez_platform_v3.0_deprecations.md index a53c0491b1..630820ee3e 100644 --- a/docs/release_notes/ez_platform_v3.0_deprecations.md +++ b/docs/release_notes/ez_platform_v3.0_deprecations.md @@ -772,7 +772,7 @@ All classes and interfaces from `eZ\Publish\Core\Persistence\Database` and `eZ\P The signature of the `\eZ\Publish\Core\Persistence\Legacy\URL\Query\CriterionHandler::handle` contract now accepts `\Doctrine\DBAL\Query\QueryBuilder` instead of `\eZ\Publish\Core\Persistence\Database\SelectQuery` and has the following form: -``` php +``` php skip-validation use \Doctrine\DBAL\Query\QueryBuilder; use \eZ\Publish\Core\Persistence\Legacy\URL\Query\CriteriaConverter; use \eZ\Publish\API\Repository\Values\URL\Query\Criterion; diff --git a/docs/release_notes/ibexa_dxp_v4.6.md b/docs/release_notes/ibexa_dxp_v4.6.md index 80854abd39..c3866beec2 100644 --- a/docs/release_notes/ibexa_dxp_v4.6.md +++ b/docs/release_notes/ibexa_dxp_v4.6.md @@ -1640,7 +1640,7 @@ Endpoints that allow you to manage prices in your platform with REST API: A signature for the `\Ibexa\Contracts\Rest\Output\Generator::startValueElement` method has been updated to the following: -```php +```php skip-validation /** * @phpstan-param scalar $value * @phpstan-param array $attributes diff --git a/docs/resources/contributing/package_structure.md b/docs/resources/contributing/package_structure.md index 05330652da..471b36ed4d 100644 --- a/docs/resources/contributing/package_structure.md +++ b/docs/resources/contributing/package_structure.md @@ -17,17 +17,17 @@ The following conventions apply to contributions to [[= product_name_base =]] co Define [[= product_name =]] core PHP code in a namespace with the following prefix: -```php +```php skip-validation namespace Ibexa; ``` A package which groups some DXP features can use an additional prefix, for example: -```php +```php skip-validation namespace Ibexa\Commerce; ``` -```php +```php skip-validation namespace Ibexa\Personalization; ``` @@ -55,11 +55,11 @@ The `src/lib` directory and its corresponding `Ibexa\` namespace ar Examples: -```php +```php skip-validation namespace Ibexa\Search; ``` -```php +```php skip-validation namespace Ibexa\Commerce\Shop; ``` @@ -67,7 +67,7 @@ namespace Ibexa\Commerce\Shop; The bundle class definition in the `src/bundle` directory must be: -```php +```php skip-validation namespace Ibexa\Bundle\; class Ibexa[ProductGroup]Bundle // ... @@ -76,13 +76,13 @@ class Ibexa[ProductGroup]Bundle // ... Examples: -```php +```php skip-validation namespace Ibexa\Bundle\Search; class IbexaSearchBundle // ... ``` -```php +```php skip-validation namespace Ibexa\Bundle\Commerce\Shop; class IbexaCommerceShopBundle // ... @@ -92,21 +92,21 @@ class IbexaCommerceShopBundle // ... A package may introduce a namespace for contracts, to be consumed by first and third party packages and projects, which must be prefixed as: -```php +```php skip-validation namespace Ibexa\Contracts; ``` Examples: -```php +```php skip-validation namespace Ibexa\Contracts\Kernel; ``` -```php +```php skip-validation namespace Ibexa\Contracts\SiteFactory; ``` -```php +```php skip-validation namespace Ibexa\Contracts\Commerce\Shop; ``` diff --git a/docs/search/aggregation_reference/authorterm_aggregation.md b/docs/search/aggregation_reference/authorterm_aggregation.md index 80d155c488..d170997b61 100644 --- a/docs/search/aggregation_reference/authorterm_aggregation.md +++ b/docs/search/aggregation_reference/authorterm_aggregation.md @@ -13,6 +13,9 @@ The field-based [AuthorTermAggregation](/api/php_api/php_api_reference/classes/I ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\AuthorTermAggregation('author', 'article', 'authors'); ``` diff --git a/docs/search/aggregation_reference/basepricestats_aggregation.md b/docs/search/aggregation_reference/basepricestats_aggregation.md index 74f3bd6a77..44903bb291 100644 --- a/docs/search/aggregation_reference/basepricestats_aggregation.md +++ b/docs/search/aggregation_reference/basepricestats_aggregation.md @@ -21,6 +21,11 @@ You can use the provided getters to access the values: ## Example ``` php +use Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\BasePriceStatsAggregation; + +/** @var CurrencyInterface $currency */ $query = new ProductQuery(); $query->setAggregations([ new BasePriceStatsAggregation('base_price_stats_aggregation', $currency), diff --git a/docs/search/aggregation_reference/checkboxterm_aggregation.md b/docs/search/aggregation_reference/checkboxterm_aggregation.md index 7a595366ff..7f503ff832 100644 --- a/docs/search/aggregation_reference/checkboxterm_aggregation.md +++ b/docs/search/aggregation_reference/checkboxterm_aggregation.md @@ -13,6 +13,9 @@ The field-based [CheckboxTermAggregation](/api/php_api/php_api_reference/classes ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\CheckboxTermAggregation('checkbox', 'article', 'enable_comments'); ``` diff --git a/docs/search/aggregation_reference/contenttypegroupterm_aggregation.md b/docs/search/aggregation_reference/contenttypegroupterm_aggregation.md index 1d42dced95..0a77afbe98 100644 --- a/docs/search/aggregation_reference/contenttypegroupterm_aggregation.md +++ b/docs/search/aggregation_reference/contenttypegroupterm_aggregation.md @@ -13,6 +13,9 @@ The [ContentTypeGroupTermAggregation](/api/php_api/php_api_reference/classes/Ibe ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\ContentTypeGroupTermAggregation('content_type_group'); ``` diff --git a/docs/search/aggregation_reference/contenttypeterm_aggregation.md b/docs/search/aggregation_reference/contenttypeterm_aggregation.md index 1d3d242f26..62d729603c 100644 --- a/docs/search/aggregation_reference/contenttypeterm_aggregation.md +++ b/docs/search/aggregation_reference/contenttypeterm_aggregation.md @@ -13,6 +13,9 @@ The [ContentTypeTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Co ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\ContentTypeTermAggregation('content_type'); ``` diff --git a/docs/search/aggregation_reference/countryterm_aggregation.md b/docs/search/aggregation_reference/countryterm_aggregation.md index 6bc909190e..81e34ddde9 100644 --- a/docs/search/aggregation_reference/countryterm_aggregation.md +++ b/docs/search/aggregation_reference/countryterm_aggregation.md @@ -13,6 +13,9 @@ The field-based [CountryTermAggregation](/api/php_api/php_api_reference/classes/ ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\CountryTermAggregation('country', 'article', 'country'); ``` diff --git a/docs/search/aggregation_reference/custompricestats_aggregation.md b/docs/search/aggregation_reference/custompricestats_aggregation.md index 08413b7888..78d7b67445 100644 --- a/docs/search/aggregation_reference/custompricestats_aggregation.md +++ b/docs/search/aggregation_reference/custompricestats_aggregation.md @@ -21,6 +21,13 @@ The CustomPriceStatsAggregation aggregates search results by the value of the cu ## Example ``` php +use Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface; +use Ibexa\Contracts\ProductCatalog\Values\CustomerGroupInterface; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\CustomPriceStatsAggregation; + +/** @var CurrencyInterface $currency */ +/** @var CustomerGroupInterface $customerGroup */ $query = new ProductQuery(); $query->setAggregations([ new CustomPriceStatsAggregation('custom_price_stats_aggregation', $currency, $customerGroup), diff --git a/docs/search/aggregation_reference/datemetadatarange_aggregation.md b/docs/search/aggregation_reference/datemetadatarange_aggregation.md index fbd1e431fb..d47dcbd4ef 100644 --- a/docs/search/aggregation_reference/datemetadatarange_aggregation.md +++ b/docs/search/aggregation_reference/datemetadatarange_aggregation.md @@ -15,11 +15,15 @@ The [DateMetadataRangeAggregation](/api/php_api/php_api_reference/classes/Ibexa- ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new Query(); $query->aggregations[] = new Aggregation\DateMetadataRangeAggregation('date_metadata', Aggregation\DateMetadataRangeAggregation::PUBLISHED, [ - new Query\Aggregation\Range(null, new DateTime('2020-06-01')), - new Query\Aggregation\Range(new DateTime('2020-06-01'), new DateTime('2020-12-31')), - new Query\Aggregation\Range(new DateTime('2020-12-31'), null), + Range::ofDateTime(null, new DateTime('2020-06-01')), + Range::ofDateTime(new DateTime('2020-06-01'), new DateTime('2020-12-31')), + Range::ofDateTime(new DateTime('2020-12-31'), null), ]); ``` diff --git a/docs/search/aggregation_reference/daterange_aggregation.md b/docs/search/aggregation_reference/daterange_aggregation.md index 518cc39b77..b8e1ac1823 100644 --- a/docs/search/aggregation_reference/daterange_aggregation.md +++ b/docs/search/aggregation_reference/daterange_aggregation.md @@ -14,11 +14,15 @@ The field-based [DateRangeAggregation](/api/php_api/php_api_reference/classes/Ib ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\DateRangeAggregation('date', 'event', 'event_date', [ - new Query\Aggregation\Range(null, new DateTime('2020-06-01')), - new Query\Aggregation\Range(new DateTime('2020-06-01'), new DateTime('2020-12-31')), - new Query\Aggregation\Range(new DateTime('2020-12-31'), null), + Range::ofDateTime(null, new DateTime('2020-06-01')), + Range::ofDateTime(new DateTime('2020-06-01'), new DateTime('2020-12-31')), + Range::ofDateTime(new DateTime('2020-12-31'), null), ]); ``` diff --git a/docs/search/aggregation_reference/datetimerange_aggregation.md b/docs/search/aggregation_reference/datetimerange_aggregation.md index 84b6c7fe62..17e8d14e0c 100644 --- a/docs/search/aggregation_reference/datetimerange_aggregation.md +++ b/docs/search/aggregation_reference/datetimerange_aggregation.md @@ -14,11 +14,15 @@ The field-based [DateTimeRangeAggregation](/api/php_api/php_api_reference/classe ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\DateTimeRangeAggregation('date', 'event', 'event_date', [ - new Query\Aggregation\Range(null, new DateTime('2020-06-01')), - new Query\Aggregation\Range(new DateTime('2020-06-01'), new DateTime('2020-12-31')), - new Query\Aggregation\Range(new DateTime('2020-12-31'), null), + Range::ofDateTime(null, new DateTime('2020-06-01')), + Range::ofDateTime(new DateTime('2020-06-01'), new DateTime('2020-12-31')), + Range::ofDateTime(new DateTime('2020-12-31'), null), ]); ``` diff --git a/docs/search/aggregation_reference/floatrange_aggregation.md b/docs/search/aggregation_reference/floatrange_aggregation.md index d94c1dedc9..8bcb0eb15c 100644 --- a/docs/search/aggregation_reference/floatrange_aggregation.md +++ b/docs/search/aggregation_reference/floatrange_aggregation.md @@ -14,11 +14,15 @@ The field-based [FloatRangeAggregation](/api/php_api/php_api_reference/classes/I ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\FloatRangeAggregation('float', 'product', 'weight', [ - new Query\Aggregation\Range(null, 0.25), - new Query\Aggregation\Range(0.25, 0.75), - new Query\Aggregation\Range(0.75, null), + Range::ofFloat(null, 0.25), + Range::ofFloat(0.25, 0.75), + Range::ofFloat(0.75, null), ]); ``` diff --git a/docs/search/aggregation_reference/floatstats_aggregation.md b/docs/search/aggregation_reference/floatstats_aggregation.md index 5d2be9bb13..5fc9445378 100644 --- a/docs/search/aggregation_reference/floatstats_aggregation.md +++ b/docs/search/aggregation_reference/floatstats_aggregation.md @@ -20,6 +20,9 @@ You can use the provided getters to access the values: ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\FloatStatsAggregation('float', 'product', 'weight'); ``` diff --git a/docs/search/aggregation_reference/integerrange_aggregation.md b/docs/search/aggregation_reference/integerrange_aggregation.md index 37c51b76a6..0a422a87d5 100644 --- a/docs/search/aggregation_reference/integerrange_aggregation.md +++ b/docs/search/aggregation_reference/integerrange_aggregation.md @@ -14,11 +14,15 @@ The field-based [IntegerRangeAggregation](/api/php_api/php_api_reference/classes ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\IntegerRangeAggregation('integer', 'product', 'amount', [ - new Query\Aggregation\Range(null, 12), - new Query\Aggregation\Range(12, 24), - new Query\Aggregation\Range(24, null), + Range::ofInt(null, 12), + Range::ofInt(12, 24), + Range::ofInt(24, null), ]); ``` diff --git a/docs/search/aggregation_reference/integerstats_aggregation.md b/docs/search/aggregation_reference/integerstats_aggregation.md index 13d65dcd3a..ff31603d22 100644 --- a/docs/search/aggregation_reference/integerstats_aggregation.md +++ b/docs/search/aggregation_reference/integerstats_aggregation.md @@ -19,6 +19,9 @@ The field-based [IntegerStatsAggregation](/api/php_api/php_api_reference/classes ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\IntegerStatsAggregation('integer', 'product', 'amount'); ``` diff --git a/docs/search/aggregation_reference/keywordterm_aggregation.md b/docs/search/aggregation_reference/keywordterm_aggregation.md index e0eff92f43..4457069e31 100644 --- a/docs/search/aggregation_reference/keywordterm_aggregation.md +++ b/docs/search/aggregation_reference/keywordterm_aggregation.md @@ -13,6 +13,9 @@ The field-based [KeywordTermAggregation](/api/php_api/php_api_reference/classes/ ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\KeywordTermAggregation('keyword', 'article', 'tags'); ``` diff --git a/docs/search/aggregation_reference/languageterm_aggregation.md b/docs/search/aggregation_reference/languageterm_aggregation.md index 6f5e6bd09f..41a7f88dbb 100644 --- a/docs/search/aggregation_reference/languageterm_aggregation.md +++ b/docs/search/aggregation_reference/languageterm_aggregation.md @@ -13,6 +13,9 @@ The [LanguageTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Contr ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\LanguageTermAggregation('language'); ``` diff --git a/docs/search/aggregation_reference/locationchildrenterm_aggregation.md b/docs/search/aggregation_reference/locationchildrenterm_aggregation.md index b530e83ab2..077bdaca94 100644 --- a/docs/search/aggregation_reference/locationchildrenterm_aggregation.md +++ b/docs/search/aggregation_reference/locationchildrenterm_aggregation.md @@ -13,6 +13,9 @@ The [LocationChildrenTermAggregation](/api/php_api/php_api_reference/classes/Ibe ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new LocationQuery(); $query->aggregations[] = new Aggregation\Location\LocationChildrenTermAggregation('location_children'); ``` diff --git a/docs/search/aggregation_reference/objectstateterm_aggregation.md b/docs/search/aggregation_reference/objectstateterm_aggregation.md index 099df6822c..cd5b1ffa13 100644 --- a/docs/search/aggregation_reference/objectstateterm_aggregation.md +++ b/docs/search/aggregation_reference/objectstateterm_aggregation.md @@ -14,8 +14,11 @@ The [ObjectStateTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Co ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); -$query->aggregations[] = new Aggregation\Location\ObjectStateTermAggregation('object_state', 'ibexa_lock'); +$query->aggregations[] = new Aggregation\ObjectStateTermAggregation('object_state', 'ibexa_lock'); ``` [[= include_file('docs/snippets/search_term_aggregation_settings.md') =]] diff --git a/docs/search/aggregation_reference/product_attribute_aggregations.md b/docs/search/aggregation_reference/product_attribute_aggregations.md index d6a533713e..845092669d 100644 --- a/docs/search/aggregation_reference/product_attribute_aggregations.md +++ b/docs/search/aggregation_reference/product_attribute_aggregations.md @@ -28,19 +28,26 @@ Range aggregations (`ProductAttributeFloatRangeAggregation` and `ProductAttribut ## Example ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\AttributeSelectionTermAggregation; + $query = new ProductQuery(); $query->setAggregations([ - new ProductAttributeSelectionAggregation('skin', 'skin_type'), + new AttributeSelectionTermAggregation('skin', 'skin_type'), ]); ``` ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\AttributeIntegerRangeAggregation; + $query = new ProductQuery(); $query->setAggregations([ - new ProductAttributeIntegerRangeAggregation('buttons', 'number_of_buttons', [ - new \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range(null, 5), - new \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range(5, 10), - new \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range(10, null), + new AttributeIntegerRangeAggregation('buttons', 'number_of_buttons', [ + Range::ofInt(null, 5), + Range::ofInt(5, 10), + Range::ofInt(10, null), ]), ]); ``` diff --git a/docs/search/aggregation_reference/productavailabilityterm_aggregation.md b/docs/search/aggregation_reference/productavailabilityterm_aggregation.md index 45058d73d6..946fb1d611 100644 --- a/docs/search/aggregation_reference/productavailabilityterm_aggregation.md +++ b/docs/search/aggregation_reference/productavailabilityterm_aggregation.md @@ -13,6 +13,9 @@ The ProductAvailabilityTermAggregation aggregates search results by product avai ## Example ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\ProductAvailabilityTermAggregation; + $query = new ProductQuery(); $query->setAggregations([ new ProductAvailabilityTermAggregation('product_availability'), diff --git a/docs/search/aggregation_reference/productpricerange_aggregation.md b/docs/search/aggregation_reference/productpricerange_aggregation.md index aa6774888c..ea1455dbc9 100644 --- a/docs/search/aggregation_reference/productpricerange_aggregation.md +++ b/docs/search/aggregation_reference/productpricerange_aggregation.md @@ -15,11 +15,15 @@ The ProductPriceRangeAggregation aggregates search results by the value of the p ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\ProductPriceRangeAggregation; + $query = new ProductQuery(); $query->setAggregations([ new ProductPriceRangeAggregation('price', 'PLN', [ - new \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range(0, 10000), - new \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range(10000, null), + Range::ofInt(0, 10000), + Range::ofInt(10000, null), ]), ]); ``` diff --git a/docs/search/aggregation_reference/productstockrange_aggregation.md b/docs/search/aggregation_reference/productstockrange_aggregation.md index 0b29292bc6..d098fe6bca 100644 --- a/docs/search/aggregation_reference/productstockrange_aggregation.md +++ b/docs/search/aggregation_reference/productstockrange_aggregation.md @@ -14,12 +14,16 @@ The ProductStockRangeAggregation aggregates search results by products' numerica ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\ProductStockRangeAggregation; + $productQuery = new ProductQuery(); $productQuery->setAggregations([ new ProductStockRangeAggregation('stock', [ - new Range(null, 10), - new Range(10, 100), - new Range(100, null), + Range::ofInt(null, 10), + Range::ofInt(10, 100), + Range::ofInt(100, null), ]), ]); ``` diff --git a/docs/search/aggregation_reference/producttypeterm_aggregation.md b/docs/search/aggregation_reference/producttypeterm_aggregation.md index aac92ab6d7..d5f5c10c26 100644 --- a/docs/search/aggregation_reference/producttypeterm_aggregation.md +++ b/docs/search/aggregation_reference/producttypeterm_aggregation.md @@ -13,6 +13,9 @@ The ProductTypeTermAggregation aggregates search results by the product type. ## Example ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Aggregation\ProductTypeTermAggregation; + $query = new ProductQuery(); $query->setAggregations([ new ProductTypeTermAggregation('product_type'), diff --git a/docs/search/aggregation_reference/rawrange_aggregation.md b/docs/search/aggregation_reference/rawrange_aggregation.md index 98b7f9c156..1e0d36e81a 100644 --- a/docs/search/aggregation_reference/rawrange_aggregation.md +++ b/docs/search/aggregation_reference/rawrange_aggregation.md @@ -22,9 +22,13 @@ The [RawRangeAggregation](/api/php_api/php_api_reference/classes/Ibexa-Contracts ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new LocationQuery(); $query->aggregations[] = new Aggregation\RawRangeAggregation('priority', 'priority_id', [ - new Query\Aggregation\Range(1, 10), - new Query\Aggregation\Range(10, 100) + Range::ofInt(1, 10), + Range::ofInt(10, 100), ]); ``` diff --git a/docs/search/aggregation_reference/rawstats_aggregation.md b/docs/search/aggregation_reference/rawstats_aggregation.md index fd8b51e0d9..67315492d6 100644 --- a/docs/search/aggregation_reference/rawstats_aggregation.md +++ b/docs/search/aggregation_reference/rawstats_aggregation.md @@ -28,6 +28,9 @@ You can use the provided getters to access the values: ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\RawStatsAggregation('location_depth', 'depth_i'); ``` diff --git a/docs/search/aggregation_reference/rawterm_aggregation.md b/docs/search/aggregation_reference/rawterm_aggregation.md index 94d629b520..a1b4aee7eb 100644 --- a/docs/search/aggregation_reference/rawterm_aggregation.md +++ b/docs/search/aggregation_reference/rawterm_aggregation.md @@ -21,6 +21,9 @@ The [RawTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Contracts- ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\RawTermAggregation('content_per_content_type', 'content_type_id_id'); ``` diff --git a/docs/search/aggregation_reference/sectionterm_aggregation.md b/docs/search/aggregation_reference/sectionterm_aggregation.md index 51980b5f76..0dc3a5ae99 100644 --- a/docs/search/aggregation_reference/sectionterm_aggregation.md +++ b/docs/search/aggregation_reference/sectionterm_aggregation.md @@ -13,6 +13,9 @@ The [SectionTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Contra ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\SectionTermAggregation('section'); ``` diff --git a/docs/search/aggregation_reference/selectionterm_aggregation.md b/docs/search/aggregation_reference/selectionterm_aggregation.md index d6b468f228..17164582ba 100644 --- a/docs/search/aggregation_reference/selectionterm_aggregation.md +++ b/docs/search/aggregation_reference/selectionterm_aggregation.md @@ -13,6 +13,9 @@ The field-based [SelectionTermAggregation](/api/php_api/php_api_reference/classe ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\SelectionTermAggregation('selection', 'article', 'select'); ``` diff --git a/docs/search/aggregation_reference/subtreeterm_aggregation.md b/docs/search/aggregation_reference/subtreeterm_aggregation.md index 780140492b..902a59f5bd 100644 --- a/docs/search/aggregation_reference/subtreeterm_aggregation.md +++ b/docs/search/aggregation_reference/subtreeterm_aggregation.md @@ -14,6 +14,9 @@ The [SubtreeTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Contra ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\Location\SubtreeTermAggregation('pathstring', '/1/2/'); ``` diff --git a/docs/search/aggregation_reference/taxonomyentryid_aggregation.md b/docs/search/aggregation_reference/taxonomyentryid_aggregation.md index cff1e2b455..ce35d66f94 100644 --- a/docs/search/aggregation_reference/taxonomyentryid_aggregation.md +++ b/docs/search/aggregation_reference/taxonomyentryid_aggregation.md @@ -14,11 +14,17 @@ The `TaxonomyEntryIdAggregation` aggregates search results by the content item's ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Taxonomy\Search\Query\Aggregation as Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\TaxonomyEntryIdAggregation('taxonomy', 'tags'); ``` ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; +use Ibexa\Contracts\Taxonomy\Search\Query\Aggregation\TaxonomyEntryIdAggregation; + $query = new ProductQuery(); -$query->aggregations[] = new Aggregation\TaxonomyEntryIdAggregation('categories', 'product_categories'); +$query->setAggregations([new TaxonomyEntryIdAggregation('categories', 'product_categories')]); ``` diff --git a/docs/search/aggregation_reference/timerange_aggregation.md b/docs/search/aggregation_reference/timerange_aggregation.md index c38920833b..91caf7161b 100644 --- a/docs/search/aggregation_reference/timerange_aggregation.md +++ b/docs/search/aggregation_reference/timerange_aggregation.md @@ -14,10 +14,14 @@ The field-based [TimeRangeAggregation](/api/php_api/php_api_reference/classes/Ib ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range; + $query = new Query(); $query->aggregations[] = new Aggregation\Field\TimeRangeAggregation('date', 'event', 'event_time', [ - new Query\Aggregation\Range(null, new DateTime('T14:00')), - new Query\Aggregation\Range(new DateTime('T14:003'), null), + Range::ofInt(null, 50400), + Range::ofInt(50400, null), ]); ``` diff --git a/docs/search/aggregation_reference/usermetadataterm_aggregation.md b/docs/search/aggregation_reference/usermetadataterm_aggregation.md index 275e2742e1..b61f72f109 100644 --- a/docs/search/aggregation_reference/usermetadataterm_aggregation.md +++ b/docs/search/aggregation_reference/usermetadataterm_aggregation.md @@ -13,6 +13,9 @@ The [UserMetadataTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-C ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\UserMetadataTermAggregation('user_metadata'); ``` diff --git a/docs/search/aggregation_reference/visibilityterm_aggregation.md b/docs/search/aggregation_reference/visibilityterm_aggregation.md index 780fa57d48..843cb5a36c 100644 --- a/docs/search/aggregation_reference/visibilityterm_aggregation.md +++ b/docs/search/aggregation_reference/visibilityterm_aggregation.md @@ -13,6 +13,9 @@ The [VisibilityTermAggregation](/api/php_api/php_api_reference/classes/Ibexa-Con ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; + $query = new Query(); $query->aggregations[] = new Aggregation\VisibilityTermAggregation('visibility'); ``` diff --git a/docs/search/criteria_reference/ancestor_criterion.md b/docs/search/criteria_reference/ancestor_criterion.md index d0853413a0..4db9811464 100644 --- a/docs/search/criteria_reference/ancestor_criterion.md +++ b/docs/search/criteria_reference/ancestor_criterion.md @@ -15,6 +15,11 @@ The [`Ancestor` Search Criterion](/api/php_api/php_api_reference/classes/Ibexa-C ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +/** @var object{locationService: \Ibexa\Contracts\Core\Repository\LocationService} $this */ $query->query = new Criterion\Ancestor([$this->locationService->loadLocation(62)->pathString]); ``` @@ -45,6 +50,12 @@ $query->query = new Criterion\Ancestor([$this->locationService->loadLocation(62) You can use the Ancestor Search Criterion to create a list of breadcrumbs leading to the Location: ``` php hl_lines="2" +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var int $locationId */ +/** @var object{locationService: \Ibexa\Contracts\Core\Repository\LocationService, searchService: \Ibexa\Contracts\Core\Repository\SearchService} $this */ $query = new LocationQuery(); $query->query = new Criterion\Ancestor([$this->locationService->loadLocation($locationId)->pathString]); @@ -54,6 +65,7 @@ foreach ($results->searchHits as $searchHit) { $breadcrumbs[] = $searchHit; } +// @phpstan-ignore-next-line return $this->render('parts/breadcrumbs.html.twig', [ 'breadcrumbs' => $breadcrumbs, ]); diff --git a/docs/search/criteria_reference/baseprice_criterion.md b/docs/search/criteria_reference/baseprice_criterion.md index bbc95e06cc..69e625c861 100644 --- a/docs/search/criteria_reference/baseprice_criterion.md +++ b/docs/search/criteria_reference/baseprice_criterion.md @@ -20,6 +20,9 @@ The `BasePrice` Criterion isn't available in the Legacy Search engine. ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\BasePrice( diff --git a/docs/search/criteria_reference/checkboxattribute_criterion.md b/docs/search/criteria_reference/checkboxattribute_criterion.md index eb72b6a723..126bc24c06 100644 --- a/docs/search/criteria_reference/checkboxattribute_criterion.md +++ b/docs/search/criteria_reference/checkboxattribute_criterion.md @@ -16,6 +16,9 @@ The `CheckboxAttribute` Search Criterion searches for products by the value of t ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\CheckboxAttribute('automatic', true) diff --git a/docs/search/criteria_reference/colorattribute_criterion.md b/docs/search/criteria_reference/colorattribute_criterion.md index e196933a1f..7e8055b36e 100644 --- a/docs/search/criteria_reference/colorattribute_criterion.md +++ b/docs/search/criteria_reference/colorattribute_criterion.md @@ -16,6 +16,9 @@ The `ColorAttribute` Search Criterion searches for products by the value of thei ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ColorAttribute('color', ['#FF0000']) diff --git a/docs/search/criteria_reference/contentid_criterion.md b/docs/search/criteria_reference/contentid_criterion.md index c468ad0fed..d8a47d61ef 100644 --- a/docs/search/criteria_reference/contentid_criterion.md +++ b/docs/search/criteria_reference/contentid_criterion.md @@ -15,6 +15,10 @@ The [`ContentId` Search Criterion](/api/php_api/php_api_reference/classes/Ibexa- ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ContentId([62, 64]); ``` diff --git a/docs/search/criteria_reference/contentname_criterion.md b/docs/search/criteria_reference/contentname_criterion.md index 4f16fd57b2..6183133485 100644 --- a/docs/search/criteria_reference/contentname_criterion.md +++ b/docs/search/criteria_reference/contentname_criterion.md @@ -15,6 +15,10 @@ The [`ContentName` Search Criterion](https://github.com/ibexa/core/blob/main/src ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ContentName('*phone'); ``` diff --git a/docs/search/criteria_reference/contenttypegroupid_criterion.md b/docs/search/criteria_reference/contenttypegroupid_criterion.md index e8395aac51..0630f074cf 100644 --- a/docs/search/criteria_reference/contenttypegroupid_criterion.md +++ b/docs/search/criteria_reference/contenttypegroupid_criterion.md @@ -15,6 +15,10 @@ The [`ContentTypeGroupId` Search Criterion](/api/php_api/php_api_reference/class ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; + +/** @var Query $query */ $query->query = new Criterion\ContentTypeGroupId([1, 2]); ``` @@ -46,6 +50,12 @@ You can use the `ContentTypeGroupId` Criterion to query all Media content items (the default ID for the Media content type group is 3): ``` php hl_lines="1" +use Ibexa\Contracts\Core\Repository\SearchService; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; + +/** @var Query $query */ +/** @var object{searchService: SearchService} $this */ $query->query = new Criterion\ContentTypeGroupId([3]); $results = $this->searchService->findContent($query); @@ -53,5 +63,4 @@ You can use the `ContentTypeGroupId` Criterion to query all Media content items foreach ($results->searchHits as $searchHit) { $media[] = $searchHit; } - } ``` diff --git a/docs/search/criteria_reference/contenttypeid_criterion.md b/docs/search/criteria_reference/contenttypeid_criterion.md index 2c8301358d..657603b89b 100644 --- a/docs/search/criteria_reference/contenttypeid_criterion.md +++ b/docs/search/criteria_reference/contenttypeid_criterion.md @@ -15,6 +15,10 @@ The [`ContentTypeId` Search Criterion](/api/php_api/php_api_reference/classes/Ib ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ContentTypeId([44]); ``` diff --git a/docs/search/criteria_reference/contenttypeidentifier_criterion.md b/docs/search/criteria_reference/contenttypeidentifier_criterion.md index 8cb8995a9e..40b63b5007 100644 --- a/docs/search/criteria_reference/contenttypeidentifier_criterion.md +++ b/docs/search/criteria_reference/contenttypeidentifier_criterion.md @@ -15,6 +15,10 @@ The [`ContentTypeIdentifier` Search Criterion](/api/php_api/php_api_reference/cl ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ContentTypeIdentifier(['article', 'blog_post']); ``` diff --git a/docs/search/criteria_reference/createdat_criterion.md b/docs/search/criteria_reference/createdat_criterion.md index 06ae3046b0..c90d0ffed0 100644 --- a/docs/search/criteria_reference/createdat_criterion.md +++ b/docs/search/criteria_reference/createdat_criterion.md @@ -16,6 +16,9 @@ The `CreatedAt` Search Criterion searches for products based on the date when th ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $criteria = new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\CreatedAt( new DateTime('2023-03-01'), \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\Operator::GTE, diff --git a/docs/search/criteria_reference/createdatrange_criterion.md b/docs/search/criteria_reference/createdatrange_criterion.md index fe6de80520..81023d7d97 100644 --- a/docs/search/criteria_reference/createdatrange_criterion.md +++ b/docs/search/criteria_reference/createdatrange_criterion.md @@ -16,6 +16,9 @@ The `CreatedAtRange` Search Criterion searches for products based on the date ra ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $criteria = new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\CreatedAtRange( new \DateTimeImmutable('2020-07-10T00:00:00+00:00'), new \DateTimeImmutable('2023-07-12T00:00:00+00:00') diff --git a/docs/search/criteria_reference/currencycode_criterion.md b/docs/search/criteria_reference/currencycode_criterion.md index c98073e693..7c6b98cbe5 100644 --- a/docs/search/criteria_reference/currencycode_criterion.md +++ b/docs/search/criteria_reference/currencycode_criterion.md @@ -19,5 +19,9 @@ The `CurrencyCodeCriterion` Criterion isn't available in Solr or Elasticsearch e ### PHP ``` php -$query->query = new \Ibexa\Contracts\ProductCatalog\Values\Currency\Query\Criterion\CurrencyCodeCriterion('EUR'); +use Ibexa\Contracts\ProductCatalog\Values\Currency\CurrencyQuery; + +$query = new CurrencyQuery( + new \Ibexa\Contracts\ProductCatalog\Values\Currency\Query\Criterion\CurrencyCodeCriterion('EUR') +); ``` diff --git a/docs/search/criteria_reference/customergroupid_criterion.md b/docs/search/criteria_reference/customergroupid_criterion.md index 4a27b612c6..dfb6fd44c6 100644 --- a/docs/search/criteria_reference/customergroupid_criterion.md +++ b/docs/search/criteria_reference/customergroupid_criterion.md @@ -15,5 +15,9 @@ The `CustomerGroupId` Search Criterion searches for content based on the ID of i ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\CustomerGroupId(1); ``` diff --git a/docs/search/criteria_reference/customprice_criterion.md b/docs/search/criteria_reference/customprice_criterion.md index b4752cf374..5b70e3ebda 100644 --- a/docs/search/criteria_reference/customprice_criterion.md +++ b/docs/search/criteria_reference/customprice_criterion.md @@ -22,6 +22,10 @@ The `CustomPrice` Criterion isn't available in the Legacy Search engine. ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + +/** @var \Ibexa\Contracts\ProductCatalog\Values\CustomerGroupInterface $customerGroup */ $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\CustomPrice( diff --git a/docs/search/criteria_reference/datemetadata_criterion.md b/docs/search/criteria_reference/datemetadata_criterion.md index 3c94a49b8a..fe4ab9fe00 100644 --- a/docs/search/criteria_reference/datemetadata_criterion.md +++ b/docs/search/criteria_reference/datemetadata_criterion.md @@ -17,6 +17,10 @@ The [`DateMetadata` Search Criterion](/api/php_api/php_api_reference/classes/Ibe ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\DateMetadata( Criterion\DateMetadata::CREATED, Criterion\Operator::BETWEEN, @@ -59,6 +63,10 @@ $query->query = new Criterion\DateMetadata( You can use the `DateMetadata` Criterion to search for blog posts that have been created within the last week: ``` php hl_lines="5" +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + $query = new LocationQuery; $date = strtotime("-1 week"); $query->query = new Criterion\LogicalAnd([ diff --git a/docs/search/criteria_reference/depth_criterion.md b/docs/search/criteria_reference/depth_criterion.md index 1389da5b42..98f75eaa83 100644 --- a/docs/search/criteria_reference/depth_criterion.md +++ b/docs/search/criteria_reference/depth_criterion.md @@ -24,5 +24,9 @@ The `value` argument requires: ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Location\Depth(Criterion\Operator::LT, 3); ``` diff --git a/docs/search/criteria_reference/field_criterion.md b/docs/search/criteria_reference/field_criterion.md index e07057ebe3..e41bf709ee 100644 --- a/docs/search/criteria_reference/field_criterion.md +++ b/docs/search/criteria_reference/field_criterion.md @@ -26,6 +26,10 @@ The `Field` Criterion isn't available in [Repository filtering](search_api.md#re ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Field('name', Criterion\Operator::CONTAINS, 'Platform'); ``` @@ -66,6 +70,10 @@ $query->query = new Criterion\Field('name', Criterion\Operator::CONTAINS, 'Platf You can use the `Field` Criterion to search for articles that contain the word "featured": ``` php hl_lines="4" +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + $query = new LocationQuery(); $query->query = new Criterion\LogicalAnd([ new Criterion\ContentTypeIdentifier('article'), diff --git a/docs/search/criteria_reference/fieldrelation_criterion.md b/docs/search/criteria_reference/fieldrelation_criterion.md index cf2103597f..c7249b9b5d 100644 --- a/docs/search/criteria_reference/fieldrelation_criterion.md +++ b/docs/search/criteria_reference/fieldrelation_criterion.md @@ -23,5 +23,9 @@ The `FieldRelation` Criterion isn't available in [Repository filtering](search_a ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\FieldRelation('relations', Criterion\Operator::CONTAINS, [55, 63]); ``` diff --git a/docs/search/criteria_reference/floatattribute_criterion.md b/docs/search/criteria_reference/floatattribute_criterion.md index 37883cc172..b5f112ed9a 100644 --- a/docs/search/criteria_reference/floatattribute_criterion.md +++ b/docs/search/criteria_reference/floatattribute_criterion.md @@ -16,6 +16,9 @@ The `FloatAttribute` Search Criterion searches for products by the value of thei ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\FloatAttribute( diff --git a/docs/search/criteria_reference/fulltext_criterion.md b/docs/search/criteria_reference/fulltext_criterion.md index 001d62c947..e6652adf24 100644 --- a/docs/search/criteria_reference/fulltext_criterion.md +++ b/docs/search/criteria_reference/fulltext_criterion.md @@ -40,18 +40,30 @@ The `FullText` Criterion isn't available in [Repository filtering](search_api.md ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\FullText('victory'); ``` Using double quotes to indicate a phrase: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\FullText('"world cup"'); ``` Using the AND operator and parenthesis to search for both words at the same time: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\FullText('baseball AND cup'); ``` @@ -82,6 +94,10 @@ $query->query = new Criterion\FullText('baseball AND cup'); Assume the following search query: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\FullText('(cup AND ba*ball) "breaking news"'); ``` diff --git a/docs/search/criteria_reference/image_criterion.md b/docs/search/criteria_reference/image_criterion.md index 2df2a0a3f7..782b72155f 100644 --- a/docs/search/criteria_reference/image_criterion.md +++ b/docs/search/criteria_reference/image_criterion.md @@ -16,6 +16,10 @@ The `Image` Search Criterion searches for image by specified image attributes. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $imageCriteriaData = [ 'mimeTypes' => [ 'image/png', diff --git a/docs/search/criteria_reference/imagedimensions_criterion.md b/docs/search/criteria_reference/imagedimensions_criterion.md index 4281fe6fb3..8fa9cd36a6 100644 --- a/docs/search/criteria_reference/imagedimensions_criterion.md +++ b/docs/search/criteria_reference/imagedimensions_criterion.md @@ -16,6 +16,10 @@ The `Dimensions` Search Criterion searches for image with specified dimensions. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $imageCriteriaData = [ 'width' => [ 'min' => 100, // (default: 0, optional) @@ -27,7 +31,7 @@ $imageCriteriaData = [ ], ]; -$query->query = new Criterion\Dimensions('image', $imageCriteriaData); +$query->query = new Criterion\Image\Dimensions('image', $imageCriteriaData); ``` ### REST API diff --git a/docs/search/criteria_reference/imagefilesize_criterion.md b/docs/search/criteria_reference/imagefilesize_criterion.md index 04b85a8024..6395b47fb7 100644 --- a/docs/search/criteria_reference/imagefilesize_criterion.md +++ b/docs/search/criteria_reference/imagefilesize_criterion.md @@ -17,7 +17,11 @@ The `FileSize` Search Criterion searches for image with specified size. ### PHP ``` php -$query->query = new Criterion\FileSize('image', 0, 1.5); +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +$query->query = new Criterion\Image\FileSize('image', 0, 1.5); ``` ### REST API diff --git a/docs/search/criteria_reference/imageheight_criterion.md b/docs/search/criteria_reference/imageheight_criterion.md index 5f1ff96c79..78ee14f4c1 100644 --- a/docs/search/criteria_reference/imageheight_criterion.md +++ b/docs/search/criteria_reference/imageheight_criterion.md @@ -17,5 +17,9 @@ The `Height` Search Criterion searches for image with specified height. ### PHP ``` php -$query->query = new Criterion\Height('image', 0, 1500); +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +$query->query = new Criterion\Image\Height('image', 0, 1500); ``` diff --git a/docs/search/criteria_reference/imagemimetype_criterion.md b/docs/search/criteria_reference/imagemimetype_criterion.md index f494232d6c..83427128a9 100644 --- a/docs/search/criteria_reference/imagemimetype_criterion.md +++ b/docs/search/criteria_reference/imagemimetype_criterion.md @@ -16,18 +16,26 @@ The `MimeType` Search Criterion searches for image with specified mime type(s). ### PHP ``` php -$query->query = new Criterion\MimeType('image', 'image/jpeg'); +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +$query->query = new Criterion\Image\MimeType('image', 'image/jpeg'); ``` or ```php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $mimeTypes = [ 'image/jpeg', 'image/png', ]; -$query->query = new Criterion\MimeType('image', $mimeTypes); +$query->query = new Criterion\Image\MimeType('image', $mimeTypes); ``` ### REST API diff --git a/docs/search/criteria_reference/imageorientation_criterion.md b/docs/search/criteria_reference/imageorientation_criterion.md index 1829d957a0..c2b637ddc5 100644 --- a/docs/search/criteria_reference/imageorientation_criterion.md +++ b/docs/search/criteria_reference/imageorientation_criterion.md @@ -17,16 +17,25 @@ Supported orientation values: landscape, portrait and square. ### PHP ``` php -$query->query = new Criterion\Orientation('image', 'landscape'); +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\Orientation; -OR +/** @var Query $query */ +$query->query = new Orientation('image', 'landscape'); +``` + +``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\Orientation; +/** @var Query $query */ $orientations = [ 'landscape', 'portrait', ]; -$query->query = new Criterion\Orientation('image', $orientations); +$query->query = new Orientation('image', $orientations); ``` ### REST API @@ -56,7 +65,7 @@ $query->query = new Criterion\Orientation('image', $orientations); } } - OR + ``` "Query": { "Filter": { diff --git a/docs/search/criteria_reference/imagewidth_criterion.md b/docs/search/criteria_reference/imagewidth_criterion.md index 34ec3293c7..c8e7fcad01 100644 --- a/docs/search/criteria_reference/imagewidth_criterion.md +++ b/docs/search/criteria_reference/imagewidth_criterion.md @@ -17,5 +17,9 @@ The `Width` Search Criterion searches for image with specified width. ### PHP ``` php -$query->query = new Criterion\Width('image', 150, 1000); +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +$query->query = new Criterion\Image\Width('image', 150, 1000); ``` diff --git a/docs/search/criteria_reference/integerattribute_criterion.md b/docs/search/criteria_reference/integerattribute_criterion.md index bb71bed820..f25dafffd8 100644 --- a/docs/search/criteria_reference/integerattribute_criterion.md +++ b/docs/search/criteria_reference/integerattribute_criterion.md @@ -16,6 +16,9 @@ The `IntegerAttribute` Search Criterion searches for products by the value of th ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\IntegerAttribute( diff --git a/docs/search/criteria_reference/iscontainer_criterion.md b/docs/search/criteria_reference/iscontainer_criterion.md index b30f2d6313..da34655059 100644 --- a/docs/search/criteria_reference/iscontainer_criterion.md +++ b/docs/search/criteria_reference/iscontainer_criterion.md @@ -16,6 +16,10 @@ The [`IsContainer` Search Criterion](/api/php_api/php_api_reference/classes/Ibex ### PHP ```php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\IsContainer(); // Finds containers $query->query = new Criterion\IsContainer(false); // Finds non-containers ``` diff --git a/docs/search/criteria_reference/iscurrencyenabled_criterion.md b/docs/search/criteria_reference/iscurrencyenabled_criterion.md index 1985d5f8e2..d470584211 100644 --- a/docs/search/criteria_reference/iscurrencyenabled_criterion.md +++ b/docs/search/criteria_reference/iscurrencyenabled_criterion.md @@ -20,5 +20,9 @@ The `IsCurrencyEnabledCriterion` Criterion isn't available in Solr or Elasticsea ### PHP ``` php -$query->query = new \Ibexa\Contracts\ProductCatalog\Values\Currency\Query\Criterion\IsCurrencyEnabledCriterion(); +use Ibexa\Contracts\ProductCatalog\Values\Currency\CurrencyQuery; + +$query = new CurrencyQuery( + new \Ibexa\Contracts\ProductCatalog\Values\Currency\Query\Criterion\IsCurrencyEnabledCriterion() +); ``` diff --git a/docs/search/criteria_reference/isfieldempty_criterion.md b/docs/search/criteria_reference/isfieldempty_criterion.md index f8598b0397..1c52fa9415 100644 --- a/docs/search/criteria_reference/isfieldempty_criterion.md +++ b/docs/search/criteria_reference/isfieldempty_criterion.md @@ -26,6 +26,10 @@ For this use case, use [`TaxonomyNoEntries`](taxonomy_no_entries.md) instead. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\IsFieldEmpty('title'); ``` @@ -34,6 +38,10 @@ $query->query = new Criterion\IsFieldEmpty('title'); You can use the `IsFieldEmpty` Criterion to search for articles that don't have an image: ``` php hl_lines="4" +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + $query = new LocationQuery; $query->query = new Criterion\LogicalAnd([ new Criterion\ContentTypeIdentifier('article'), diff --git a/docs/search/criteria_reference/ismainlocation_criterion.md b/docs/search/criteria_reference/ismainlocation_criterion.md index 8b0172d691..1399b2cebb 100644 --- a/docs/search/criteria_reference/ismainlocation_criterion.md +++ b/docs/search/criteria_reference/ismainlocation_criterion.md @@ -18,5 +18,10 @@ representing whether to search for a main or not main location ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\IsMainLocation; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Location\IsMainLocation(IsMainLocation::MAIN); ``` diff --git a/docs/search/criteria_reference/isproductbased_criterion.md b/docs/search/criteria_reference/isproductbased_criterion.md index 077682c18f..4f780973fa 100644 --- a/docs/search/criteria_reference/isproductbased_criterion.md +++ b/docs/search/criteria_reference/isproductbased_criterion.md @@ -11,5 +11,9 @@ The `IsProductBased` Search Criterion searches for content that plays the role o ### PHP ``` php -$query->query = new Ibexa\Contracts\ProductCatalog\Values\Content\Query\Criterion\IsProductBased(); +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +$query->query = new \Ibexa\Contracts\ProductCatalog\Values\Content\Query\Criterion\IsProductBased(); ``` diff --git a/docs/search/criteria_reference/isuserbased_criterion.md b/docs/search/criteria_reference/isuserbased_criterion.md index c3302d0db0..35e9d50efd 100644 --- a/docs/search/criteria_reference/isuserbased_criterion.md +++ b/docs/search/criteria_reference/isuserbased_criterion.md @@ -25,6 +25,10 @@ The `IsUserBased` Criterion isn't available in Solr or Elasticsearch engines. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\IsUserBased(); ``` diff --git a/docs/search/criteria_reference/isuserenabled_criterion.md b/docs/search/criteria_reference/isuserenabled_criterion.md index d95e3b29ad..5356828e81 100644 --- a/docs/search/criteria_reference/isuserenabled_criterion.md +++ b/docs/search/criteria_reference/isuserenabled_criterion.md @@ -16,6 +16,10 @@ The [`IsUserEnabled` Search Criterion](/api/php_api/php_api_reference/classes/Ib ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\IsUserEnabled(); ``` diff --git a/docs/search/criteria_reference/isvirtual_criterion.md b/docs/search/criteria_reference/isvirtual_criterion.md index 26be439adb..7aef8f79cd 100644 --- a/docs/search/criteria_reference/isvirtual_criterion.md +++ b/docs/search/criteria_reference/isvirtual_criterion.md @@ -15,6 +15,9 @@ The `IsVirtual` Search Criterion searches for virtual or physical products. ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\IsVirtual(true) diff --git a/docs/search/criteria_reference/languagecode_criterion.md b/docs/search/criteria_reference/languagecode_criterion.md index b4a977db2f..b783150b84 100644 --- a/docs/search/criteria_reference/languagecode_criterion.md +++ b/docs/search/criteria_reference/languagecode_criterion.md @@ -16,6 +16,10 @@ The [`LanguageCode` Search Criterion](/api/php_api/php_api_reference/classes/Ibe ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\LanguageCode('ger-DE', false); ``` @@ -47,6 +51,11 @@ You can use the `LanguageCode` Criterion to search for articles that are lacking into a specific language: ``` php hl_lines="5" +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var object{searchService: \Ibexa\Contracts\Core\Repository\SearchService} $this */ $query = new LocationQuery; $query->query = new Criterion\LogicalAnd([ new Criterion\ContentTypeIdentifier('article'), @@ -62,6 +71,7 @@ foreach ($results->searchHits as $searchHit) { $articles[] = $searchHit; } +// @phpstan-ignore-next-line return $this->render('list/articles_to_translate.html.twig', [ 'articles' => $articles, ]); diff --git a/docs/search/criteria_reference/locationid_criterion.md b/docs/search/criteria_reference/locationid_criterion.md index 63169e9c71..4c6c896bb5 100644 --- a/docs/search/criteria_reference/locationid_criterion.md +++ b/docs/search/criteria_reference/locationid_criterion.md @@ -15,6 +15,10 @@ The [`LocationId` Search Criterion](/api/php_api/php_api_reference/classes/Ibexa ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\LocationId(62); ``` diff --git a/docs/search/criteria_reference/locationremoteid_criterion.md b/docs/search/criteria_reference/locationremoteid_criterion.md index d79bfd1aec..5602f7b39a 100644 --- a/docs/search/criteria_reference/locationremoteid_criterion.md +++ b/docs/search/criteria_reference/locationremoteid_criterion.md @@ -15,6 +15,10 @@ The [`LocationRemoteId` Search Criterion](/api/php_api/php_api_reference/classes ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\LocationRemoteId(['4d1e5f216c0a7aaab7f005ffd4b6a8a8', 'b81ef3e62b514188bfddd2a80d447d34']); ``` diff --git a/docs/search/criteria_reference/logicaland_criterion.md b/docs/search/criteria_reference/logicaland_criterion.md index b4afdf3276..e5036083e7 100644 --- a/docs/search/criteria_reference/logicaland_criterion.md +++ b/docs/search/criteria_reference/logicaland_criterion.md @@ -17,9 +17,13 @@ When querying for [products](product_api.md), use [LogicalAnd](/api/php_api/php_ ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; + +/** @var Query $query */ $query->query = new Criterion\LogicalAnd([ new Criterion\ContentTypeIdentifier('article'), - new Criterion\SectionIdentifier(['sports', 'news']); + new Criterion\SectionIdentifier(['sports', 'news']), ] ); ``` diff --git a/docs/search/criteria_reference/logicalnot_criterion.md b/docs/search/criteria_reference/logicalnot_criterion.md index 444c2702fb..e639063b5e 100644 --- a/docs/search/criteria_reference/logicalnot_criterion.md +++ b/docs/search/criteria_reference/logicalnot_criterion.md @@ -15,6 +15,11 @@ It takes only one Criterion in the array parameter. ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +/** @var string $contentTypeId */ $query->filter = new Criterion\LogicalNot( new Criterion\ContentTypeIdentifier($contentTypeId) ); diff --git a/docs/search/criteria_reference/logicalor_criterion.md b/docs/search/criteria_reference/logicalor_criterion.md index 657f9c94ec..5105fb743b 100644 --- a/docs/search/criteria_reference/logicalor_criterion.md +++ b/docs/search/criteria_reference/logicalor_criterion.md @@ -17,9 +17,13 @@ When querying for [products](product_api.md), use [LogicalOr](/api/php_api/php_a ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; + +/** @var Query $query */ $query->filter = new Criterion\LogicalOr([ new Criterion\ContentTypeIdentifier('article'), - new Criterion\SectionIdentifier(['sports', 'news']); + new Criterion\SectionIdentifier(['sports', 'news']) ] ); ``` diff --git a/docs/search/criteria_reference/maplocationdistance_criterion.md b/docs/search/criteria_reference/maplocationdistance_criterion.md index 6592008687..bbebf5f92b 100644 --- a/docs/search/criteria_reference/maplocationdistance_criterion.md +++ b/docs/search/criteria_reference/maplocationdistance_criterion.md @@ -28,5 +28,9 @@ The `MapLocationDistance` Criterion isn't available in [Repository filtering](se ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\MapLocationDistance('location', Criterion\Operator::LTE, 5, 51.395973, 22.531696); ``` diff --git a/docs/search/criteria_reference/objectstateid_criterion.md b/docs/search/criteria_reference/objectstateid_criterion.md index f080cbaae9..c381dff554 100644 --- a/docs/search/criteria_reference/objectstateid_criterion.md +++ b/docs/search/criteria_reference/objectstateid_criterion.md @@ -15,6 +15,10 @@ The [`ObjectStateId` Search Criterion](/api/php_api/php_api_reference/classes/Ib ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ObjectStateId([4, 5]); ``` diff --git a/docs/search/criteria_reference/objectstateidentifier_criterion.md b/docs/search/criteria_reference/objectstateidentifier_criterion.md index 75e7153828..d583fb2068 100644 --- a/docs/search/criteria_reference/objectstateidentifier_criterion.md +++ b/docs/search/criteria_reference/objectstateidentifier_criterion.md @@ -16,10 +16,18 @@ The [`ObjectStateIdentifier` Search Criterion](/api/php_api/php_api_reference/cl ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ObjectStateIdentifier(['ready']); ``` ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ObjectStateIdentifier(['not_locked'], 'ibexa_lock'); ``` diff --git a/docs/search/criteria_reference/order_company_associated_criterion.md b/docs/search/criteria_reference/order_company_associated_criterion.md index ee55c07a30..84e9529614 100644 --- a/docs/search/criteria_reference/order_company_associated_criterion.md +++ b/docs/search/criteria_reference/order_company_associated_criterion.md @@ -16,6 +16,9 @@ The `IsCompanyAssociatedCriterion` Search Criterion searches for orders based on ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\IsCompanyAssociatedCriterion(true) ); diff --git a/docs/search/criteria_reference/order_company_name_criterion.md b/docs/search/criteria_reference/order_company_name_criterion.md index 1f65ad8494..170fd0eaaa 100644 --- a/docs/search/criteria_reference/order_company_name_criterion.md +++ b/docs/search/criteria_reference/order_company_name_criterion.md @@ -16,6 +16,9 @@ The `CompanyNameCriterion` Search Criterion searches for orders based on the nam ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CompanyNameCriterion('IBM') ); diff --git a/docs/search/criteria_reference/order_created_criterion.md b/docs/search/criteria_reference/order_created_criterion.md index aa59007fff..a263bb160c 100644 --- a/docs/search/criteria_reference/order_created_criterion.md +++ b/docs/search/criteria_reference/order_created_criterion.md @@ -17,6 +17,9 @@ The `CreatedAtCriterion` Search Criterion searches for orders based on the date ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $criteria = new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CreatedAtCriterion( new DateTime('2023-03-01'), 'GTE' diff --git a/docs/search/criteria_reference/order_currency_code_criterion.md b/docs/search/criteria_reference/order_currency_code_criterion.md index 9348a743a3..9f0b5f639c 100644 --- a/docs/search/criteria_reference/order_currency_code_criterion.md +++ b/docs/search/criteria_reference/order_currency_code_criterion.md @@ -16,6 +16,9 @@ The `CurrencyCodeCriterion` Search Criterion searches for orders based on the cu ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CurrencyCodeCriterion('USD') ); diff --git a/docs/search/criteria_reference/order_customer_name_criterion.md b/docs/search/criteria_reference/order_customer_name_criterion.md index 80b0fc08d5..6f72425cc1 100644 --- a/docs/search/criteria_reference/order_customer_name_criterion.md +++ b/docs/search/criteria_reference/order_customer_name_criterion.md @@ -16,6 +16,9 @@ The `CustomerNameCriterion` Search Criterion searches for orders based on the na ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\CustomerNameCriterion('john') ); diff --git a/docs/search/criteria_reference/order_identifier_criterion.md b/docs/search/criteria_reference/order_identifier_criterion.md index 4da72e5ab1..107c4fa62d 100644 --- a/docs/search/criteria_reference/order_identifier_criterion.md +++ b/docs/search/criteria_reference/order_identifier_criterion.md @@ -16,6 +16,9 @@ The `IdentifierCriterion` Search Criterion searches for orders based on the orde ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\IdentifierCriterion('f7578972-e7f4-4cae-85dc-a7c74610204e') ); diff --git a/docs/search/criteria_reference/order_owner_criterion.md b/docs/search/criteria_reference/order_owner_criterion.md index 320071b135..1f269f6ce2 100644 --- a/docs/search/criteria_reference/order_owner_criterion.md +++ b/docs/search/criteria_reference/order_owner_criterion.md @@ -9,14 +9,17 @@ The `OwnerCriterion` Criterion searches for orders based on the user reference. ## Arguments -- `UserReference` object - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(int $userId) +- `UserReference` object - new \Ibexa\Core\Repository\Values\User\UserReference(int $userId) ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\OwnerCriterion( - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(14) + new \Ibexa\Core\Repository\Values\User\UserReference(14) ) ); ``` @@ -24,11 +27,14 @@ $query = new OrderQuery( `OwnerCriterion` Criterion accepts also multiple values: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\OwnerCriterion( [ - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(14), - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(123), + new \Ibexa\Core\Repository\Values\User\UserReference(14), + new \Ibexa\Core\Repository\Values\User\UserReference(123), ] ) ); diff --git a/docs/search/criteria_reference/order_price_criterion.md b/docs/search/criteria_reference/order_price_criterion.md index 745ca2a126..e72f32c77b 100644 --- a/docs/search/criteria_reference/order_price_criterion.md +++ b/docs/search/criteria_reference/order_price_criterion.md @@ -17,6 +17,9 @@ The `PriceCriterion` searches for orders by their total net value. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $criteria = new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\PriceCriterion( 12900, 'GTE' diff --git a/docs/search/criteria_reference/order_source_criterion.md b/docs/search/criteria_reference/order_source_criterion.md index 53abd3a519..956fae1ec3 100644 --- a/docs/search/criteria_reference/order_source_criterion.md +++ b/docs/search/criteria_reference/order_source_criterion.md @@ -16,6 +16,9 @@ The `SourceCriterion` Search Criterion searches for orders based on the source o ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\SourceCriterion('local_shop') ); diff --git a/docs/search/criteria_reference/order_status_criterion.md b/docs/search/criteria_reference/order_status_criterion.md index e6f3f5cb48..237b202694 100644 --- a/docs/search/criteria_reference/order_status_criterion.md +++ b/docs/search/criteria_reference/order_status_criterion.md @@ -16,6 +16,9 @@ The `StatusCriterion` Search Criterion searches for orders based on order status ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\OrderManagement\Value\Order\OrderQuery; + $query = new OrderQuery( new \Ibexa\Contracts\OrderManagement\Value\Order\Query\Criterion\StatusCriterion('pending') ); diff --git a/docs/search/criteria_reference/parentlocationid_criterion.md b/docs/search/criteria_reference/parentlocationid_criterion.md index e30307eeb0..e2e1462af1 100644 --- a/docs/search/criteria_reference/parentlocationid_criterion.md +++ b/docs/search/criteria_reference/parentlocationid_criterion.md @@ -16,6 +16,10 @@ searches for content based on the Location ID of its parent. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\ParentLocationId([54, 58]); ``` @@ -46,6 +50,12 @@ $query->query = new Criterion\ParentLocationId([54, 58]); You can use the `ParentLocationId` Search Criterion to list blog posts contained in a blog: ``` php hl_lines="4" +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var int $locationId */ +/** @var object{searchService: \Ibexa\Contracts\Core\Repository\SearchService} $this */ $query = new LocationQuery(); $query->query = new Criterion\LogicalAnd([ new Criterion\Visibility(Criterion\Visibility::VISIBLE), @@ -58,6 +68,7 @@ foreach ($results->searchHits as $searchHit) { $posts[] = $searchHit; } +// @phpstan-ignore-next-line return $this->render('full/blog.html.twig', [ 'posts' => $posts, ]); diff --git a/docs/search/criteria_reference/payment_createdat_criterion.md b/docs/search/criteria_reference/payment_createdat_criterion.md index d43536e7e1..0588a4b115 100644 --- a/docs/search/criteria_reference/payment_createdat_criterion.md +++ b/docs/search/criteria_reference/payment_createdat_criterion.md @@ -17,6 +17,9 @@ The `CreatedAt` Search Criterion searches for payments based on the date when th ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + $criteria = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\CreatedAt( new DateTime('2023-03-01') ); diff --git a/docs/search/criteria_reference/payment_currency_criterion.md b/docs/search/criteria_reference/payment_currency_criterion.md index 524561faed..59829269d6 100644 --- a/docs/search/criteria_reference/payment_currency_criterion.md +++ b/docs/search/criteria_reference/payment_currency_criterion.md @@ -16,5 +16,9 @@ The `Currency` Search Criterion searches for payments based on the currency code ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Currency('EUR'); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + +$query = new PaymentQuery( + new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Currency('EUR') +); ``` diff --git a/docs/search/criteria_reference/payment_id_criterion.md b/docs/search/criteria_reference/payment_id_criterion.md index 3ccd16044d..6c1a9bfeb3 100644 --- a/docs/search/criteria_reference/payment_id_criterion.md +++ b/docs/search/criteria_reference/payment_id_criterion.md @@ -16,5 +16,9 @@ The `Id` Search Criterion searches for payments based on the payment ID. ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Id(2); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + +$query = new PaymentQuery( + new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Id(2) +); ``` diff --git a/docs/search/criteria_reference/payment_identifier_criterion.md b/docs/search/criteria_reference/payment_identifier_criterion.md index 0f6ca32dfc..7de17744f0 100644 --- a/docs/search/criteria_reference/payment_identifier_criterion.md +++ b/docs/search/criteria_reference/payment_identifier_criterion.md @@ -16,5 +16,9 @@ The `Identifier` Search Criterion searches for payments based on the payment ide ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Identifier('f7578972-e7f4-4cae-85dc-a7c74610204e'); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + +$query = new PaymentQuery( + new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Identifier('f7578972-e7f4-4cae-85dc-a7c74610204e') +); ``` diff --git a/docs/search/criteria_reference/payment_logicaland_criterion.md b/docs/search/criteria_reference/payment_logicaland_criterion.md index fc51f0ab28..1d947d8c0c 100644 --- a/docs/search/criteria_reference/payment_logicaland_criterion.md +++ b/docs/search/criteria_reference/payment_logicaland_criterion.md @@ -16,10 +16,14 @@ The `LogicalAnd` Search Criterion matches payments if all provided Criteria matc ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\LogicalAnd( - [ - new \Ibexa\Contracts\Payment\Payment\Query\Criterion\CreatedAt(new DateTime('2023-03-01')); - new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Currency('USD'); - ] -); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; +use Ibexa\Contracts\Payment\Payment\Query\Criterion\CreatedAt; +use Ibexa\Contracts\Payment\Payment\Query\Criterion\Currency; +use Ibexa\Contracts\Payment\Payment\Query\Criterion\LogicalAnd; + +$query = new PaymentQuery(); +$query->setQuery(new LogicalAnd( + new CreatedAt(new DateTime('2023-03-01')), + new Currency('USD'), +)); ``` diff --git a/docs/search/criteria_reference/payment_logicalor_criterion.md b/docs/search/criteria_reference/payment_logicalor_criterion.md index 0ab036ebc9..e20bc93559 100644 --- a/docs/search/criteria_reference/payment_logicalor_criterion.md +++ b/docs/search/criteria_reference/payment_logicalor_criterion.md @@ -16,10 +16,14 @@ The `LogicalOr` Search Criterion matches payments if at least one of the provide ### PHP ``` php -$query->query = new Criterion\LogicalOr( - [ - new \Ibexa\Contracts\Payment\Payment\Query\Criterion\CreatedAt(new DateTime('2023-03-01')); - new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Currency('USD'); - ] -); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; +use Ibexa\Contracts\Payment\Payment\Query\Criterion\CreatedAt; +use Ibexa\Contracts\Payment\Payment\Query\Criterion\Currency; +use Ibexa\Contracts\Payment\Payment\Query\Criterion\LogicalOr; + +$query = new PaymentQuery(); +$query->setQuery(new LogicalOr( + new CreatedAt(new DateTime('2023-03-01')), + new Currency('USD'), +)); ``` diff --git a/docs/search/criteria_reference/payment_method_createdat_criterion.md b/docs/search/criteria_reference/payment_method_createdat_criterion.md index eac4ce8ab2..7160d1e177 100644 --- a/docs/search/criteria_reference/payment_method_createdat_criterion.md +++ b/docs/search/criteria_reference/payment_method_createdat_criterion.md @@ -17,6 +17,9 @@ The `CreatedAt` Search Criterion searches for payment methods based on the date ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + $criteria = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\CreatedAt( new DateTime('2023-03-01') ); diff --git a/docs/search/criteria_reference/payment_method_enabled_criterion.md b/docs/search/criteria_reference/payment_method_enabled_criterion.md index b9671b987d..2447da755f 100644 --- a/docs/search/criteria_reference/payment_method_enabled_criterion.md +++ b/docs/search/criteria_reference/payment_method_enabled_criterion.md @@ -16,5 +16,9 @@ The `Enabled` Search Criterion searches for payment methods based on whether the ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Enabled(true); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + +$query = new PaymentMethodQuery( + new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Enabled(true) +); ``` diff --git a/docs/search/criteria_reference/payment_method_id_criterion.md b/docs/search/criteria_reference/payment_method_id_criterion.md index c1ca101653..2a2a7fb661 100644 --- a/docs/search/criteria_reference/payment_method_id_criterion.md +++ b/docs/search/criteria_reference/payment_method_id_criterion.md @@ -16,5 +16,9 @@ The `Id` Search Criterion searches for payment methods based on the payment meth ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Id(2); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + +$query = new PaymentMethodQuery( + new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Id(2) +); ``` diff --git a/docs/search/criteria_reference/payment_method_identifier_criterion.md b/docs/search/criteria_reference/payment_method_identifier_criterion.md index 04fdcc21a0..809cf68adc 100644 --- a/docs/search/criteria_reference/payment_method_identifier_criterion.md +++ b/docs/search/criteria_reference/payment_method_identifier_criterion.md @@ -16,5 +16,9 @@ The `Identifier` Search Criterion searches for payment methods based on the paym ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Identifier('f7578972-e7f4-4cae-85dc-a7c74610204e'); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + +$query = new PaymentMethodQuery( + new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Identifier('f7578972-e7f4-4cae-85dc-a7c74610204e') +); ``` diff --git a/docs/search/criteria_reference/payment_method_logicaland_criterion.md b/docs/search/criteria_reference/payment_method_logicaland_criterion.md index b903040e18..2ebc5e2ef5 100644 --- a/docs/search/criteria_reference/payment_method_logicaland_criterion.md +++ b/docs/search/criteria_reference/payment_method_logicaland_criterion.md @@ -16,10 +16,14 @@ The `LogicalAnd` Search Criterion matches payment methods if all provided Criter ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\LogicalAnd( - [ - new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\CreatedAt(new DateTime('2023-03-01')); - new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Enabled(true); - ] -); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; +use Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\CreatedAt; +use Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Enabled; +use Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\LogicalAnd; + +$query = new PaymentMethodQuery(); +$query->setQuery(new LogicalAnd( + new CreatedAt(new DateTime('2023-03-01')), + new Enabled(true), +)); ``` diff --git a/docs/search/criteria_reference/payment_method_logicalor_criterion.md b/docs/search/criteria_reference/payment_method_logicalor_criterion.md index 92b0992efe..3798f92745 100644 --- a/docs/search/criteria_reference/payment_method_logicalor_criterion.md +++ b/docs/search/criteria_reference/payment_method_logicalor_criterion.md @@ -16,10 +16,13 @@ The `LogicalOr` Search Criterion matches payment methods if at least one of the ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\LogicalOr( - [ - new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\CreatedAt(new DateTime('2023-03-01')); - new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\CreatedAt(new DateTime('2023-05-01')); - ] -); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; +use Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\CreatedAt; +use Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\LogicalOr; + +$query = new PaymentMethodQuery(); +$query->setQuery(new LogicalOr( + new CreatedAt(new DateTime('2023-03-01')), + new CreatedAt(new DateTime('2023-05-01')), +)); ``` diff --git a/docs/search/criteria_reference/payment_method_name_criterion.md b/docs/search/criteria_reference/payment_method_name_criterion.md index 0131233c5c..95499b72c6 100644 --- a/docs/search/criteria_reference/payment_method_name_criterion.md +++ b/docs/search/criteria_reference/payment_method_name_criterion.md @@ -16,5 +16,9 @@ The `Name` Search Criterion searches for payment methods based on the existing p ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Name('Credit Card'); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + +$query = new PaymentMethodQuery( + new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Name('Credit Card') +); ``` diff --git a/docs/search/criteria_reference/payment_method_type_criterion.md b/docs/search/criteria_reference/payment_method_type_criterion.md index db7e4be3c9..f414d52aad 100644 --- a/docs/search/criteria_reference/payment_method_type_criterion.md +++ b/docs/search/criteria_reference/payment_method_type_criterion.md @@ -16,5 +16,10 @@ The `Type` Search Criterion searches for payment methods based on payment method ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Type('offline'); +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + +/** @var \Ibexa\Contracts\Payment\PaymentMethod\Type\TypeInterface $paymentMethodType */ +$query = new PaymentMethodQuery( + new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Type($paymentMethodType) +); ``` diff --git a/docs/search/criteria_reference/payment_method_updatedat_criterion.md b/docs/search/criteria_reference/payment_method_updatedat_criterion.md index be34b4d8d6..13a04438f6 100644 --- a/docs/search/criteria_reference/payment_method_updatedat_criterion.md +++ b/docs/search/criteria_reference/payment_method_updatedat_criterion.md @@ -17,6 +17,9 @@ The `UpdatedAt` Search Criterion searches for payment methods based on the date ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodQuery; + $criteria = new \Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\UpdatedAt( new DateTime('2023-03-01') ); diff --git a/docs/search/criteria_reference/payment_order_criterion.md b/docs/search/criteria_reference/payment_order_criterion.md index 05b8eacc1a..e014a783b7 100644 --- a/docs/search/criteria_reference/payment_order_criterion.md +++ b/docs/search/criteria_reference/payment_order_criterion.md @@ -16,5 +16,10 @@ The `Order` Search Criterion searches for payments based on an ID of an associat ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Order(4); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + +/** @var \Ibexa\Contracts\OrderManagement\Value\Order\OrderInterface $order */ +$query = new PaymentQuery( + new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Order($order) +); ``` diff --git a/docs/search/criteria_reference/payment_payment_method_criterion.md b/docs/search/criteria_reference/payment_payment_method_criterion.md index 1b9bba10b2..e72e6565ef 100644 --- a/docs/search/criteria_reference/payment_payment_method_criterion.md +++ b/docs/search/criteria_reference/payment_payment_method_criterion.md @@ -16,5 +16,10 @@ The `PaymentMethod` Search Criterion searches for payments based on a payment me ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\PaymentMethod(2); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + +/** @var \Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodInterface $paymentMethod */ +$query = new PaymentQuery( + new \Ibexa\Contracts\Payment\Payment\Query\Criterion\PaymentMethod($paymentMethod) +); ``` diff --git a/docs/search/criteria_reference/payment_status_criterion.md b/docs/search/criteria_reference/payment_status_criterion.md index c0a037e994..deb1d6d8f2 100644 --- a/docs/search/criteria_reference/payment_status_criterion.md +++ b/docs/search/criteria_reference/payment_status_criterion.md @@ -16,5 +16,9 @@ The `Status` Search Criterion searches for payments based on payment status. ### PHP ``` php -$query->query = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Status('failed'); +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + +$query = new PaymentQuery( + new \Ibexa\Contracts\Payment\Payment\Query\Criterion\Status('failed') +); ``` diff --git a/docs/search/criteria_reference/payment_updatedat_criterion.md b/docs/search/criteria_reference/payment_updatedat_criterion.md index ec947465a8..8257b614ac 100644 --- a/docs/search/criteria_reference/payment_updatedat_criterion.md +++ b/docs/search/criteria_reference/payment_updatedat_criterion.md @@ -17,6 +17,9 @@ The `UpdatedAt` Search Criterion searches for payments based on the date when th ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Payment\Payment\PaymentQuery; + $criteria = new \Ibexa\Contracts\Payment\Payment\Query\Criterion\UpdatedAt( new DateTime('2023-03-01') ); diff --git a/docs/search/criteria_reference/price_currency_criterion.md b/docs/search/criteria_reference/price_currency_criterion.md index 8d3dd0a10b..c96105d174 100644 --- a/docs/search/criteria_reference/price_currency_criterion.md +++ b/docs/search/criteria_reference/price_currency_criterion.md @@ -15,7 +15,11 @@ The `Currency` Search Criterion searches for prices based on the given currency. ### PHP ``` php -$currency = $priceService->getPriceById('EUR'); +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + +/** @var \Ibexa\Contracts\ProductCatalog\CurrencyServiceInterface $currencyService */ +$currency = $currencyService->getCurrencyByCode('EUR'); $query = new PriceQuery( new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency($currency) diff --git a/docs/search/criteria_reference/price_customergroup_criterion.md b/docs/search/criteria_reference/price_customergroup_criterion.md index a23aa07446..2c33e1bd64 100644 --- a/docs/search/criteria_reference/price_customergroup_criterion.md +++ b/docs/search/criteria_reference/price_customergroup_criterion.md @@ -15,6 +15,10 @@ The `CustomerGroup` Search Criterion searches for prices based on the customer g ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + +/** @var \Ibexa\Contracts\ProductCatalog\CustomerGroupServiceInterface $customerGroupService */ $customerGroup = $customerGroupService->getCustomerGroup(123); $query = new PriceQuery( diff --git a/docs/search/criteria_reference/price_isbaseprice_criterion.md b/docs/search/criteria_reference/price_isbaseprice_criterion.md index 28e8cd2478..5c46728084 100644 --- a/docs/search/criteria_reference/price_isbaseprice_criterion.md +++ b/docs/search/criteria_reference/price_isbaseprice_criterion.md @@ -19,6 +19,9 @@ The `IsBasePrice` Criterion isn't available in Solr or Elasticsearch engines. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + $query = new PriceQuery( new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\IsBasePrice() ); diff --git a/docs/search/criteria_reference/price_iscustomprice_criterion.md b/docs/search/criteria_reference/price_iscustomprice_criterion.md index 9793e76b44..c407f1bec0 100644 --- a/docs/search/criteria_reference/price_iscustomprice_criterion.md +++ b/docs/search/criteria_reference/price_iscustomprice_criterion.md @@ -19,6 +19,9 @@ The `IsCustomPrice` Criterion isn't available in Solr or Elasticsearch engines. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + $query = new PriceQuery( new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\IsCustomPrice() ); diff --git a/docs/search/criteria_reference/price_logicaland_criterion.md b/docs/search/criteria_reference/price_logicaland_criterion.md index ee9ab7c48b..7693f7a8e5 100644 --- a/docs/search/criteria_reference/price_logicaland_criterion.md +++ b/docs/search/criteria_reference/price_logicaland_criterion.md @@ -16,10 +16,13 @@ The `LogicalAnd` Search Criterion matches prices if all provided Criteria match. ### PHP ``` php -$query->query = new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\LogicalAnd( - [ - new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency('USD'), +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + +/** @var \Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface $currencyUSD */ +$query = new PriceQuery( + new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\LogicalAnd( + new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency($currencyUSD), new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\IsCustomPrice() - ] + ) ); ``` diff --git a/docs/search/criteria_reference/price_logicalor_criterion.md b/docs/search/criteria_reference/price_logicalor_criterion.md index d3e93a6dc9..5151e271d4 100644 --- a/docs/search/criteria_reference/price_logicalor_criterion.md +++ b/docs/search/criteria_reference/price_logicalor_criterion.md @@ -16,10 +16,14 @@ The `LogicalOr` Search Criterion matches prices if at least one of the provided ### PHP ``` php -$query->query = new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\LogicalOr( - [ - new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency('USD'), - new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency('EUR') - ] +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + +/** @var \Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface $currencyUSD */ +/** @var \Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface $currencyEUR */ +$query = new PriceQuery( + new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\LogicalOr( + new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency($currencyUSD), + new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Currency($currencyEUR) + ) ); ``` diff --git a/docs/search/criteria_reference/price_product_criterion.md b/docs/search/criteria_reference/price_product_criterion.md index 6aaf93a57d..ff213b6a05 100644 --- a/docs/search/criteria_reference/price_product_criterion.md +++ b/docs/search/criteria_reference/price_product_criterion.md @@ -15,6 +15,9 @@ The `Product` Search Criterion searches for prices based on product codes. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Price\PriceQuery; + $query = new PriceQuery( new \Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Product('ergo_desk') ); diff --git a/docs/search/criteria_reference/priority_criterion.md b/docs/search/criteria_reference/priority_criterion.md index 34975939d0..5698045d99 100644 --- a/docs/search/criteria_reference/priority_criterion.md +++ b/docs/search/criteria_reference/priority_criterion.md @@ -23,5 +23,9 @@ The `value` argument requires: ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Location\Priority(Criterion\Operator::GTE, 50); ``` diff --git a/docs/search/criteria_reference/productavailability_criterion.md b/docs/search/criteria_reference/productavailability_criterion.md index 21d0455641..50b9e010c4 100644 --- a/docs/search/criteria_reference/productavailability_criterion.md +++ b/docs/search/criteria_reference/productavailability_criterion.md @@ -15,6 +15,9 @@ The `ProductAvailability` Search Criterion searches for products by their availa ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ProductAvailability(true) diff --git a/docs/search/criteria_reference/productcategory_criterion.md b/docs/search/criteria_reference/productcategory_criterion.md index 76d5fa0002..ebf36ff1fe 100644 --- a/docs/search/criteria_reference/productcategory_criterion.md +++ b/docs/search/criteria_reference/productcategory_criterion.md @@ -15,6 +15,9 @@ The `ProductCategory` Search Criterion searches for products by the category the ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ProductCategory([2, 3]) diff --git a/docs/search/criteria_reference/productcode_criterion.md b/docs/search/criteria_reference/productcode_criterion.md index 78655b834d..4e1735921a 100644 --- a/docs/search/criteria_reference/productcode_criterion.md +++ b/docs/search/criteria_reference/productcode_criterion.md @@ -15,6 +15,9 @@ The `ProductCode` Search Criterion searches for products by their codes. ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ProductCode(['ergo_desk', 'alter_desk']) diff --git a/docs/search/criteria_reference/productname_criterion.md b/docs/search/criteria_reference/productname_criterion.md index b19a270ae8..d99b499ae7 100644 --- a/docs/search/criteria_reference/productname_criterion.md +++ b/docs/search/criteria_reference/productname_criterion.md @@ -15,6 +15,9 @@ The `ProductName` Search Criterion searches for products by their names. ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ProductName('sofa*') diff --git a/docs/search/criteria_reference/productstock_criterion.md b/docs/search/criteria_reference/productstock_criterion.md index ed88bc178c..34e3d1a45f 100644 --- a/docs/search/criteria_reference/productstock_criterion.md +++ b/docs/search/criteria_reference/productstock_criterion.md @@ -16,6 +16,9 @@ The `ProductStock` Search Criterion searches for products by their numerical sto ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $productQuery = new ProductQuery( null, new Criterion\ProductStock(10) @@ -23,6 +26,9 @@ $productQuery = new ProductQuery( ``` ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $productQuery = new ProductQuery( null, new Criterion\ProductStock(50, '>=') diff --git a/docs/search/criteria_reference/productstockrange_criterion.md b/docs/search/criteria_reference/productstockrange_criterion.md index f71c7f5adc..040d0cf677 100644 --- a/docs/search/criteria_reference/productstockrange_criterion.md +++ b/docs/search/criteria_reference/productstockrange_criterion.md @@ -16,6 +16,9 @@ The `ProductStockRange` Search Criterion searches for products by their numerica ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $productQuery = new ProductQuery( null, new Criterion\ProductStockRange(10, 120) diff --git a/docs/search/criteria_reference/producttype_criterion.md b/docs/search/criteria_reference/producttype_criterion.md index aab290dcc7..e59678c751 100644 --- a/docs/search/criteria_reference/producttype_criterion.md +++ b/docs/search/criteria_reference/producttype_criterion.md @@ -15,6 +15,9 @@ The `ProductType` Search Criterion searches for products by their codes. ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\ProductType(['dress']) diff --git a/docs/search/criteria_reference/rangemeasurementattributemaximum_criterion.md b/docs/search/criteria_reference/rangemeasurementattributemaximum_criterion.md index c28be6ffd8..ee33b0fbaf 100644 --- a/docs/search/criteria_reference/rangemeasurementattributemaximum_criterion.md +++ b/docs/search/criteria_reference/rangemeasurementattributemaximum_criterion.md @@ -16,11 +16,15 @@ The `RangeMeasurementAttributeMaximum` Search Criterion searches for products by ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + +/** @var object{measurementService: \Ibexa\Contracts\Measurement\MeasurementServiceInterface} $this */ $value = $this->measurementService->buildSimpleValue('length', 150, 'centimeter'); $query = new ProductQuery( null, - new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\RangeMeasurementAttributeMaximum( + new \Ibexa\Contracts\Measurement\Product\Query\Criterion\RangeMeasurementAttributeMaximum( 'length', $value ) diff --git a/docs/search/criteria_reference/rangemeasurementattributeminimum_criterion.md b/docs/search/criteria_reference/rangemeasurementattributeminimum_criterion.md index fb5d54dbad..daf99f1f8e 100644 --- a/docs/search/criteria_reference/rangemeasurementattributeminimum_criterion.md +++ b/docs/search/criteria_reference/rangemeasurementattributeminimum_criterion.md @@ -16,11 +16,15 @@ The `RangeMeasurementAttributeMinimum` Search Criterion searches for products by ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + +/** @var object{measurementService: \Ibexa\Contracts\Measurement\MeasurementServiceInterface} $this */ $value = $this->measurementService->buildSimpleValue('length', 100, 'centimeter'); $query = new ProductQuery( null, - new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\RangeMeasurementAttributeMinimum( + new \Ibexa\Contracts\Measurement\Product\Query\Criterion\RangeMeasurementAttributeMinimum( 'length', $value ) diff --git a/docs/search/criteria_reference/remoteid_criterion.md b/docs/search/criteria_reference/remoteid_criterion.md index 6677715cda..bd18615da9 100644 --- a/docs/search/criteria_reference/remoteid_criterion.md +++ b/docs/search/criteria_reference/remoteid_criterion.md @@ -16,6 +16,10 @@ searches for content based on its remote content ID. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\RemoteId('abab615dcf26699a4291657152da4337'); ``` diff --git a/docs/search/criteria_reference/sectionid_criterion.md b/docs/search/criteria_reference/sectionid_criterion.md index cfdc257ccb..22cbe407e2 100644 --- a/docs/search/criteria_reference/sectionid_criterion.md +++ b/docs/search/criteria_reference/sectionid_criterion.md @@ -15,6 +15,10 @@ The [`SectionId` Search Criterion](/api/php_api/php_api_reference/classes/Ibexa- ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\SectionId(3); ``` diff --git a/docs/search/criteria_reference/sectionidentifier_criterion.md b/docs/search/criteria_reference/sectionidentifier_criterion.md index dea856b606..afaec0204c 100644 --- a/docs/search/criteria_reference/sectionidentifier_criterion.md +++ b/docs/search/criteria_reference/sectionidentifier_criterion.md @@ -15,6 +15,10 @@ The [`SectionIdentifier` Search Criterion](/api/php_api/php_api_reference/classe ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\SectionIdentifier(['sports', 'news']); ``` diff --git a/docs/search/criteria_reference/selectionattribute_criterion.md b/docs/search/criteria_reference/selectionattribute_criterion.md index f8eeeed167..bd9c9bb956 100644 --- a/docs/search/criteria_reference/selectionattribute_criterion.md +++ b/docs/search/criteria_reference/selectionattribute_criterion.md @@ -16,6 +16,9 @@ The `SelectionAttribute` Search Criterion searches for products by the value of ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + $query = new ProductQuery( null, new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\SelectionAttribute( diff --git a/docs/search/criteria_reference/shipment_createdat_criterion.md b/docs/search/criteria_reference/shipment_createdat_criterion.md index be1ed48ff6..e0574ebb9a 100644 --- a/docs/search/criteria_reference/shipment_createdat_criterion.md +++ b/docs/search/criteria_reference/shipment_createdat_criterion.md @@ -17,6 +17,9 @@ The `CreatedAt` Search Criterion searches for shipments based on the date when t ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $criteria = new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\CreatedAt( new DateTime('2023-03-01 14:07:02'), 'GTE' diff --git a/docs/search/criteria_reference/shipment_currency_criterion.md b/docs/search/criteria_reference/shipment_currency_criterion.md index eeb2e7e9b2..3081565e85 100644 --- a/docs/search/criteria_reference/shipment_currency_criterion.md +++ b/docs/search/criteria_reference/shipment_currency_criterion.md @@ -16,7 +16,10 @@ The `Currency` Search Criterion searches for shipments based on the currency cod ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $query = new ShipmentQuery( - new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Currency('USD', 'CZK') + new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Currency(['USD', 'CZK']) ); ``` diff --git a/docs/search/criteria_reference/shipment_id_criterion.md b/docs/search/criteria_reference/shipment_id_criterion.md index 782150cccd..36a7fb0479 100644 --- a/docs/search/criteria_reference/shipment_id_criterion.md +++ b/docs/search/criteria_reference/shipment_id_criterion.md @@ -16,6 +16,9 @@ The `Id` Search Criterion searches for shipments based on the shipment ID. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $query = new ShipmentQuery( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Id(2) ); diff --git a/docs/search/criteria_reference/shipment_identifier_criterion.md b/docs/search/criteria_reference/shipment_identifier_criterion.md index df67826223..db55e3c658 100644 --- a/docs/search/criteria_reference/shipment_identifier_criterion.md +++ b/docs/search/criteria_reference/shipment_identifier_criterion.md @@ -16,6 +16,9 @@ The `Identifier` Search Criterion searches for shipments based on the shipment i ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $query = new ShipmentQuery( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Identifier('f1t7z-3rb3rt') ); diff --git a/docs/search/criteria_reference/shipment_logicaland_criterion.md b/docs/search/criteria_reference/shipment_logicaland_criterion.md index c77c345282..387e4c3bcf 100644 --- a/docs/search/criteria_reference/shipment_logicaland_criterion.md +++ b/docs/search/criteria_reference/shipment_logicaland_criterion.md @@ -16,10 +16,13 @@ The `LogicalAnd` Search Criterion matches shipments if all provided Criteria mat ### PHP ``` php -$query->query = new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\LogicalAnd( - [ +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + +/** @var \Ibexa\Contracts\Shipping\Value\ShippingMethod\ShippingMethodInterface $shippingMethod */ +$query = new ShipmentQuery( + new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\LogicalAnd( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\CreatedAt(new DateTime('2023-03-01')), new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\ShippingMethod($shippingMethod) - ] + ) ); ``` diff --git a/docs/search/criteria_reference/shipment_logicalor_criterion.md b/docs/search/criteria_reference/shipment_logicalor_criterion.md index 2903abb758..16a07037ff 100644 --- a/docs/search/criteria_reference/shipment_logicalor_criterion.md +++ b/docs/search/criteria_reference/shipment_logicalor_criterion.md @@ -16,10 +16,13 @@ The `LogicalOr` Search Criterion matches shipments if at least one of the provid ### PHP ``` php -$query->query = new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\LogicalOr( - [ +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + +/** @var \Ibexa\Contracts\Shipping\Value\ShippingMethod\ShippingMethodInterface $shippingMethod */ +$query = new ShipmentQuery( + new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\LogicalOr( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\CreatedAt(new DateTime('2023-03-01')), new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\ShippingMethod($shippingMethod) - ] + ) ); ``` diff --git a/docs/search/criteria_reference/shipment_owner_criterion.md b/docs/search/criteria_reference/shipment_owner_criterion.md index 79c9e81c3c..8ae4b07574 100644 --- a/docs/search/criteria_reference/shipment_owner_criterion.md +++ b/docs/search/criteria_reference/shipment_owner_criterion.md @@ -9,14 +9,17 @@ The `Owner` Criterion searches for shipments based on the user reference. ## Arguments -- `UserReference` object - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(int $userId) +- `UserReference` object - new \Ibexa\Core\Repository\Values\User\UserReference(int $userId) ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $query = new ShipmentQuery( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Owner( - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(14) + new \Ibexa\Core\Repository\Values\User\UserReference(14) ) ); ``` @@ -24,11 +27,14 @@ $query = new ShipmentQuery( `Owner` Criterion accepts also multiple values: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $query = new ShipmentQuery( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Owner( [ - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(14), - \Ibexa\Contracts\Core\Repository\Values\User\UserReference(123), + new \Ibexa\Core\Repository\Values\User\UserReference(14), + new \Ibexa\Core\Repository\Values\User\UserReference(123), ] ) ); diff --git a/docs/search/criteria_reference/shipment_shipping_method_criterion.md b/docs/search/criteria_reference/shipment_shipping_method_criterion.md index 2a503ead43..447b71602b 100644 --- a/docs/search/criteria_reference/shipment_shipping_method_criterion.md +++ b/docs/search/criteria_reference/shipment_shipping_method_criterion.md @@ -16,6 +16,10 @@ The `ShippingMethod` Search Criterion searches for shipments based on a shipping ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + +/** @var \Ibexa\Contracts\Shipping\Value\ShippingMethod\ShippingMethodInterface $shippingMethod */ $query = new ShipmentQuery( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\ShippingMethod($shippingMethod) ); diff --git a/docs/search/criteria_reference/shipment_status_criterion.md b/docs/search/criteria_reference/shipment_status_criterion.md index 3e2c0d40bc..05b0ec1a51 100644 --- a/docs/search/criteria_reference/shipment_status_criterion.md +++ b/docs/search/criteria_reference/shipment_status_criterion.md @@ -16,6 +16,9 @@ The `Status` Search Criterion searches for shipments based on shipment status. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $query = new ShipmentQuery( new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\Status('pending') ); diff --git a/docs/search/criteria_reference/shipment_updatedat_criterion.md b/docs/search/criteria_reference/shipment_updatedat_criterion.md index e7e84e13b7..72763c3c48 100644 --- a/docs/search/criteria_reference/shipment_updatedat_criterion.md +++ b/docs/search/criteria_reference/shipment_updatedat_criterion.md @@ -17,6 +17,9 @@ The `UpdatedAt` Search Criterion searches for shipments based on the date when t ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Shipping\Shipment\ShipmentQuery; + $criteria = new \Ibexa\Contracts\Shipping\Shipment\Query\Criterion\UpdatedAt( new DateTime('2023-03-01'), 'GTE' diff --git a/docs/search/criteria_reference/sibling_criterion.md b/docs/search/criteria_reference/sibling_criterion.md index 0a3780c3c7..a6b9f8515d 100644 --- a/docs/search/criteria_reference/sibling_criterion.md +++ b/docs/search/criteria_reference/sibling_criterion.md @@ -16,12 +16,21 @@ The [`Sibling` Search Criterion](/api/php_api/php_api_reference/classes/Ibexa-Co ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Sibling(59, 2); ``` You can also use the named constructor `Criterion\Sibling::fromLocation` and provide it with the location object: ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ +/** @var \Ibexa\Contracts\Core\Repository\LocationService $locationService */ $location = $locationService->loadLocation(59); $query->query = Criterion\Sibling::fromLocation($location); ``` diff --git a/docs/search/criteria_reference/simplemeasurementattribute_criterion.md b/docs/search/criteria_reference/simplemeasurementattribute_criterion.md index 034a221ed7..1997a54213 100644 --- a/docs/search/criteria_reference/simplemeasurementattribute_criterion.md +++ b/docs/search/criteria_reference/simplemeasurementattribute_criterion.md @@ -16,11 +16,15 @@ The `SimpleMeasurementAttribute` Search Criterion searches for products by the v ### PHP ``` php +use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; +use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; + +/** @var object{measurementService: \Ibexa\Contracts\Measurement\MeasurementServiceInterface} $this */ $value = $this->measurementService->buildSimpleValue('length', 120, 'centimeter'); $query = new ProductQuery( null, - new \Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion\SimpleMeasurementAttribute( + new \Ibexa\Contracts\Measurement\Product\Query\Criterion\SimpleMeasurementAttribute( 'width', $value ) diff --git a/docs/search/criteria_reference/subtree_criterion.md b/docs/search/criteria_reference/subtree_criterion.md index a814f314fa..eb489cf735 100644 --- a/docs/search/criteria_reference/subtree_criterion.md +++ b/docs/search/criteria_reference/subtree_criterion.md @@ -16,6 +16,10 @@ It returns the content item and all the content items below it in the subtree. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Subtree('/1/2/71/72/'); ``` diff --git a/docs/search/criteria_reference/taxonomy_entry_id.md b/docs/search/criteria_reference/taxonomy_entry_id.md index 1cceaeccc2..314a5cd63f 100644 --- a/docs/search/criteria_reference/taxonomy_entry_id.md +++ b/docs/search/criteria_reference/taxonomy_entry_id.md @@ -15,11 +15,19 @@ The [`TaxonomyEntryId` Search Criterion](/api/php_api/php_api_reference/classes/ ### PHP ``` php +use Ibexa\Contracts\Taxonomy\Search\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\TaxonomyEntryId(1); ``` Add an array of ID's to find Content tagged with at least one of the tags (OR). ```php +use Ibexa\Contracts\Taxonomy\Search\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\TaxonomyEntryId([1, 2, 3]); ``` diff --git a/docs/search/criteria_reference/useremail_criterion.md b/docs/search/criteria_reference/useremail_criterion.md index 7cc730e21f..9884a4f375 100644 --- a/docs/search/criteria_reference/useremail_criterion.md +++ b/docs/search/criteria_reference/useremail_criterion.md @@ -20,10 +20,18 @@ Solr search engine and Elasticsearch support IN and EQ operators only. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\UserEmail(['johndoe']); ``` ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\UserEmail('nospam*', Criterion\Operator::LIKE); ``` diff --git a/docs/search/criteria_reference/userid_criterion.md b/docs/search/criteria_reference/userid_criterion.md index 0468cffdbc..d7e634d4e5 100644 --- a/docs/search/criteria_reference/userid_criterion.md +++ b/docs/search/criteria_reference/userid_criterion.md @@ -15,6 +15,10 @@ The [`UserId` Search Criterion](/api/php_api/php_api_reference/classes/Ibexa-Con ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\UserId([14]); ``` diff --git a/docs/search/criteria_reference/userlogin_criterion.md b/docs/search/criteria_reference/userlogin_criterion.md index a3c6f048b4..2b4231a2bc 100644 --- a/docs/search/criteria_reference/userlogin_criterion.md +++ b/docs/search/criteria_reference/userlogin_criterion.md @@ -20,10 +20,18 @@ Solr search engine and Elasticsearch support IN and EQ operators only. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\UserLogin(['johndoe']); ``` ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\UserLogin('adm*', Criterion\Operator::LIKE); ``` diff --git a/docs/search/criteria_reference/usermetadata_criterion.md b/docs/search/criteria_reference/usermetadata_criterion.md index 54a9d0725b..d2588dccc8 100644 --- a/docs/search/criteria_reference/usermetadata_criterion.md +++ b/docs/search/criteria_reference/usermetadata_criterion.md @@ -17,6 +17,10 @@ The [`UserMetadata` Search Criterion](/api/php_api/php_api_reference/classes/Ibe ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\UserMetadata(Criterion\UserMetadata::GROUP, Criterion\Operator::EQ, 12); ``` @@ -58,6 +62,10 @@ You can use the `UserMetadata` Criterion to search for blog posts created by the ``` php hl_lines="7" // ID of your custom Contributor User Group +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + $contributorGroupId = 32; $query = new LocationQuery; diff --git a/docs/search/criteria_reference/visibility_criterion.md b/docs/search/criteria_reference/visibility_criterion.md index 50ba1f4c47..303694eb6e 100644 --- a/docs/search/criteria_reference/visibility_criterion.md +++ b/docs/search/criteria_reference/visibility_criterion.md @@ -21,6 +21,10 @@ Use Location Search to avoid this. ### PHP ``` php +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; + +/** @var Query $query */ $query->query = new Criterion\Visibility(Criterion\Visibility::HIDDEN); ``` diff --git a/docs/search/search_engines/solr_search_engine/configure_solr.md b/docs/search/search_engines/solr_search_engine/configure_solr.md index e38c5c5db9..b3cd3ad7a5 100644 --- a/docs/search/search_engines/solr_search_engine/configure_solr.md +++ b/docs/search/search_engines/solr_search_engine/configure_solr.md @@ -99,6 +99,7 @@ The configuration above results in the following boosting (content type / Field) $queryString = $request->get('query'); $query = new Query(); + // @phpstan-ignore-next-line $query->query = new \Novactive\EzSolrSearchExtra\Query\Content\Criterion\MultipleFieldsFullText( $queryString, [ @@ -111,7 +112,8 @@ The configuration above results in the following boosting (content type / Field) $searchResult = $this->searchService->findContent($query); - ... + // ... + return new Response(); } } ``` diff --git a/docs/search/shopping_list_search_reference/shopping_list_criteria.md b/docs/search/shopping_list_search_reference/shopping_list_criteria.md index 1429b9d20e..b268d56b5f 100644 --- a/docs/search/shopping_list_search_reference/shopping_list_criteria.md +++ b/docs/search/shopping_list_search_reference/shopping_list_criteria.md @@ -24,6 +24,8 @@ If the user’s permissions include the [`ShoppingListOwner` `self` limitation]( Otherwise, it returns all shopping lists in the system. ```php +use Ibexa\Contracts\ShoppingList\Value\ShoppingListQuery; + $query = new ShoppingListQuery(); ``` diff --git a/docs/search/url_search_reference/logicaland_url_criterion.md b/docs/search/url_search_reference/logicaland_url_criterion.md index f7b77a1649..89eaccc563 100644 --- a/docs/search/url_search_reference/logicaland_url_criterion.md +++ b/docs/search/url_search_reference/logicaland_url_criterion.md @@ -13,6 +13,10 @@ The [`LogicalAnd` URL Criterion](/api/php_api/php_api_reference/classes/Ibexa-Co ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ $query->filter = new Criterion\LogicalAnd( [ new Criterion\Validity(true), diff --git a/docs/search/url_search_reference/logicalnot_url_criterion.md b/docs/search/url_search_reference/logicalnot_url_criterion.md index 6222fad435..95c2c95e95 100644 --- a/docs/search/url_search_reference/logicalnot_url_criterion.md +++ b/docs/search/url_search_reference/logicalnot_url_criterion.md @@ -15,6 +15,10 @@ It takes only one Criterion in the array parameter. ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ $query->filter = new Criterion\LogicalNot( new Criterion\Pattern('ibexa.co') ); diff --git a/docs/search/url_search_reference/logicalor_url_criterion.md b/docs/search/url_search_reference/logicalor_url_criterion.md index 7e79da7f1f..9ba9eaeb2a 100644 --- a/docs/search/url_search_reference/logicalor_url_criterion.md +++ b/docs/search/url_search_reference/logicalor_url_criterion.md @@ -13,6 +13,10 @@ The [`LogicalOr` URL Criterion](/api/php_api/php_api_reference/classes/Ibexa-Con ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ $query->filter = new Criterion\LogicalOr( [ new Criterion\SectionIdentifier(['sports', 'news']), diff --git a/docs/search/url_search_reference/pattern_url_criterion.md b/docs/search/url_search_reference/pattern_url_criterion.md index 34ed0afb67..d2355c360b 100644 --- a/docs/search/url_search_reference/pattern_url_criterion.md +++ b/docs/search/url_search_reference/pattern_url_criterion.md @@ -13,5 +13,9 @@ The [`Pattern` URL Criterion](/api/php_api/php_api_reference/classes/Ibexa-Contr ## Example ``` php +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ $query->filter = new Criterion\Pattern('ibexa.co'); ``` diff --git a/docs/search/url_search_reference/sectionid_url_criterion.md b/docs/search/url_search_reference/sectionid_url_criterion.md index 8c0a67f03b..e33395b173 100644 --- a/docs/search/url_search_reference/sectionid_url_criterion.md +++ b/docs/search/url_search_reference/sectionid_url_criterion.md @@ -13,5 +13,9 @@ The [`SectionId` URL Criterion](/api/php_api/php_api_reference/classes/Ibexa-Con ## Example ``` php -$query->filter = new Criterion\SectionId(['1', '3']); +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ +$query->filter = new Criterion\SectionId([1, 3]); ``` diff --git a/docs/search/url_search_reference/sectionidentifier_url_criterion.md b/docs/search/url_search_reference/sectionidentifier_url_criterion.md index e0069e6287..5d99a26dac 100644 --- a/docs/search/url_search_reference/sectionidentifier_url_criterion.md +++ b/docs/search/url_search_reference/sectionidentifier_url_criterion.md @@ -13,5 +13,9 @@ The [SectionIdentifier URL Criterion](/api/php_api/php_api_reference/classes/Ibe ## Example ```php +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ $query->filter = new Criterion\SectionIdentifier(['standard', 'media']); ``` diff --git a/docs/search/url_search_reference/validity_url_criterion.md b/docs/search/url_search_reference/validity_url_criterion.md index 89b637d604..22528d89ee 100644 --- a/docs/search/url_search_reference/validity_url_criterion.md +++ b/docs/search/url_search_reference/validity_url_criterion.md @@ -13,5 +13,9 @@ The [Validity URL Criterion](/api/php_api/php_api_reference/classes/Ibexa-Contra ## Example ```php +use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; + +/** @var URLQuery $query */ $query->filter = new Criterion\Validity(true); ``` diff --git a/docs/snippets/search_term_aggregation_settings.md b/docs/snippets/search_term_aggregation_settings.md index e67da0f71d..a277d60645 100644 --- a/docs/snippets/search_term_aggregation_settings.md +++ b/docs/snippets/search_term_aggregation_settings.md @@ -4,7 +4,9 @@ You can define additional limits to the results using the `setLimit()` and `setM The following example limits the number of terms returned to 5 and only considers terms that have 10 or more results: ``` php -$aggregation = new //... +use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\ContentTypeTermAggregation; + +$aggregation = new ContentTypeTermAggregation('example'); // replace with the desired aggregation class $aggregation->setLimit(5); $aggregation->setMinCount(10); ``` diff --git a/docs/templating/urls_and_routes/custom_breadcrumbs.md b/docs/templating/urls_and_routes/custom_breadcrumbs.md index 3da8df6e42..690d60df47 100644 --- a/docs/templating/urls_and_routes/custom_breadcrumbs.md +++ b/docs/templating/urls_and_routes/custom_breadcrumbs.md @@ -47,7 +47,11 @@ custom_blog_index: To see the correct breadcrumb, you have to check the method in the controller itself: ``` php - if ($request->getMethod() != REQUEST::METHOD_POST) { + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + + /** @var \Symfony\Component\HttpFoundation\Request $request */ + if ($request->getMethod() != Request::METHOD_POST) { throw new NotFoundHttpException(); } ``` diff --git a/docs/tutorials/beginner_tutorial/5_display_a_list_of_content_items.md b/docs/tutorials/beginner_tutorial/5_display_a_list_of_content_items.md index c9ce080a97..3b9ccce713 100644 --- a/docs/tutorials/beginner_tutorial/5_display_a_list_of_content_items.md +++ b/docs/tutorials/beginner_tutorial/5_display_a_list_of_content_items.md @@ -66,12 +66,13 @@ use Ibexa\Core\QueryType\QueryType; class RideQueryType implements QueryType { - public static function getName() + public static function getName(): string { return 'Ride'; } - public function getQuery(array $parameters = []) + /** @param array $parameters */ + public function getQuery(array $parameters = []): \Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery { return new LocationQuery([ 'filter' => new Criterion\LogicalAnd( @@ -83,8 +84,10 @@ class RideQueryType implements QueryType ]); } - public function getSupportedParameters() + /** @return array */ + public function getSupportedParameters(): array { + return []; } } ``` diff --git a/docs/tutorials/beginner_tutorial/7_embed_content.md b/docs/tutorials/beginner_tutorial/7_embed_content.md index 6443e95eee..e57ff5b8d2 100644 --- a/docs/tutorials/beginner_tutorial/7_embed_content.md +++ b/docs/tutorials/beginner_tutorial/7_embed_content.md @@ -134,19 +134,20 @@ use Ibexa\Contracts\Core\Repository\ContentService; class RideController extends Controller { - private $contentService; + private ContentService $contentService; public function __construct(ContentService $contentService) { $this->contentService = $contentService; } - public function viewRideWithLandmarksAction(ContentView $view) + public function viewRideWithLandmarksAction(ContentView $view): ContentView { $currentContent = $view->getContent(); $landmarksListId = $currentContent->getFieldValue('landmarks'); $landmarksList = []; + /** @phpstan-ignore-next-line */ foreach ($landmarksListId->destinationContentIds as $landmarkId) { $landmarksList[$landmarkId] = $this->contentService->loadContent($landmarkId); } diff --git a/docs/update_and_migration/from_1.x_2.x/update_db_to_2.5.md b/docs/update_and_migration/from_1.x_2.x/update_db_to_2.5.md index d4009bacf0..6767fbee13 100644 --- a/docs/update_and_migration/from_1.x_2.x/update_db_to_2.5.md +++ b/docs/update_and_migration/from_1.x_2.x/update_db_to_2.5.md @@ -146,7 +146,7 @@ defined in the [Enterprise Beginner tutorial](page_and_form_tutorial.md) `app/Resources/views/layouts/sidebar.html.twig`: - ```php + ```html+twig
{% if zones[0].blocks %} @@ -197,7 +197,7 @@ defined in the [Enterprise Beginner tutorial](page_and_form_tutorial.md) `src/AppBundle/Block/RandomBlock.php`: - ``` php + ``` php skip-validation
{% if zones[0].blocks %} @@ -456,7 +456,7 @@ defined in the [Enterprise Beginner tutorial](page_and_form_tutorial.md) `src/AppBundle/Block/Event/Listener/RandomBlockListener.php` in place of `src/AppBundle/Block/RandomBlock.php`: - ``` php + ``` php skip-validation 'onCreateBookmark', - ] + ]; } public function onCreateBookmark(CreateBookmarkEvent $event): void @@ -27,13 +27,13 @@ public function onCreateBookmark(CreateBookmarkEvent $event): void **instead of:** -``` php +``` php skip-validation public function receive(Signal $signal) { if (!($signal instanceof CreateBookmarkSignal)) { return; } -} -// your code + // your code +} ``` diff --git a/docs/update_and_migration/from_2.5/update_code/8_update_rest.md b/docs/update_and_migration/from_2.5/update_code/8_update_rest.md index a35a5d0e12..0366979d91 100644 --- a/docs/update_and_migration/from_2.5/update_code/8_update_rest.md +++ b/docs/update_and_migration/from_2.5/update_code/8_update_rest.md @@ -21,7 +21,7 @@ you need to switch to Core Installer. **Use:** -``` php +``` yaml services: Acme\App\Installer\MyCustomInstaller: parent: EzSystems\PlatformInstallerBundle\Installer\CoreInstaller @@ -29,7 +29,7 @@ services: **instead of**: -``` php +``` yaml services: Acme\App\Installer\MyCustomInstaller: parent: ezplatform.installer.clean_installer @@ -42,7 +42,7 @@ Custom schema can be installed defining Symfony Event Subscriber subscribing to **Use:** -``` php +``` yaml services: Acme\App\Installer\MyCustomInstaller: parent: EzSystems\PlatformInstallerBundle\Installer\DbBasedInstaller @@ -50,7 +50,7 @@ services: **instead of:** -``` php +``` yaml services: Acme\App\Installer\MyCustomInstaller: parent: ezplatform.installer.db_based_installer diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md index 0ff9511bb9..35571127d7 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_new_commerce.md @@ -150,7 +150,7 @@ You don't have to remove third-party bundles (`FOS\` to `JMS\`) if they're used === "[[= product_name_content =]]" - ``` php + ``` text FOS\CommentBundle\FOSCommentBundle Tedivm\StashBundle\TedivmStashBundle WhiteOctober\BreadcrumbsBundle\WhiteOctoberBreadcrumbsBundle @@ -177,7 +177,7 @@ You don't have to remove third-party bundles (`FOS\` to `JMS\`) if they're used === "[[= product_name_exp =]]" - ``` php + ``` text FOS\CommentBundle\FOSCommentBundle Tedivm\StashBundle\TedivmStashBundle WhiteOctober\BreadcrumbsBundle\WhiteOctoberBreadcrumbsBundle @@ -204,7 +204,7 @@ You don't have to remove third-party bundles (`FOS\` to `JMS\`) if they're used === "[[= product_name_com =]]" - ``` php + ``` text FOS\CommentBundle\FOSCommentBundle Tedivm\StashBundle\TedivmStashBundle WhiteOctober\BreadcrumbsBundle\WhiteOctoberBreadcrumbsBundle diff --git a/docs/update_and_migration/from_4.3/update_from_4.3_old_commerce.md b/docs/update_and_migration/from_4.3/update_from_4.3_old_commerce.md index b3e5d5a6d8..6283d2f6a2 100644 --- a/docs/update_and_migration/from_4.3/update_from_4.3_old_commerce.md +++ b/docs/update_and_migration/from_4.3/update_from_4.3_old_commerce.md @@ -156,7 +156,7 @@ Add the following dependencies in the `require` section in `composer.json`: Next, remove the entries with new packages alongside with routing and configuration in `config/routes/ibexa_cart.yaml`, `config/routes/ibexa_checkout.yaml` and `config/routes/ibexa_storefront.yaml`: -```php +```php skip-validation Ibexa\Bundle\Cart\IbexaCartBundle::class => ['all' => true], Ibexa\Bundle\Checkout\IbexaCheckoutBundle::class => ['all' => true], Ibexa\Bundle\Storefront\IbexaStorefrontBundle::class => ['all' => true], diff --git a/docs/update_and_migration/from_4.6/update_from_4.6.md b/docs/update_and_migration/from_4.6/update_from_4.6.md index 21c396d5ef..3864988399 100644 --- a/docs/update_and_migration/from_4.6/update_from_4.6.md +++ b/docs/update_and_migration/from_4.6/update_from_4.6.md @@ -162,7 +162,10 @@ merge with your custom settings if needed, and commit them to Git. If the new bundle `ibexa/core-search` has not been added by the recipes, enable it by adding the following line in `config/bundles.php`: ```php +return [ + // ... Ibexa\Bundle\CoreSearch\IbexaCoreSearchBundle::class => ['all' => true], +]; ``` ## v4.6.13 diff --git a/docs/update_and_migration/from_4.6/update_to_5.0.md b/docs/update_and_migration/from_4.6/update_to_5.0.md index 0b9c561ce6..6a1d17066e 100644 --- a/docs/update_and_migration/from_4.6/update_to_5.0.md +++ b/docs/update_and_migration/from_4.6/update_to_5.0.md @@ -51,6 +51,9 @@ It's recommended to activate one rule set at a time and preview the output by ru Your configuration could look like the following example: ```php +use Rector\Config\RectorConfig; +use Ibexa\Contracts\Rector\Sets\IbexaSetList; + return RectorConfig::configure() ->withPaths( [ @@ -463,9 +466,12 @@ As this update spans across a broad range of versions, multiple rules can be con ```php //… +use Ibexa\Contracts\Rector\Sets\IbexaSetList; +use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonySetList; use Rector\Symfony\Set\SensiolabsSetList; -//… +return RectorConfig::configure() + // ... ->withSets( [ IbexaSetList::IBEXA_50->value, @@ -480,6 +486,7 @@ use Rector\Symfony\Set\SensiolabsSetList; SymfonySetList::SYMFONY_72, // https://getrector.com/find-rule?activeRectorSetGroup=symfony&rectorSet=symfony-symfonysymfony-72 SymfonySetList::SYMFONY_73, // https://getrector.com/find-rule?activeRectorSetGroup=symfony&rectorSet=symfony-symfonysymfony-73 SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, + /** @phpstan-ignore-next-line */ SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES, ] ) diff --git a/docs/update_and_migration/migrate_to_ibexa_dxp/migrating_from_ez_publish_platform.md b/docs/update_and_migration/migrate_to_ibexa_dxp/migrating_from_ez_publish_platform.md index f8a242158c..cba337396c 100644 --- a/docs/update_and_migration/migrate_to_ibexa_dxp/migrating_from_ez_publish_platform.md +++ b/docs/update_and_migration/migrate_to_ibexa_dxp/migrating_from_ez_publish_platform.md @@ -568,7 +568,7 @@ To use the script, do the following: **2.** Add `ezflow-migration-toolkit` to `AppKernel.php`. -``` php +``` php skip-validation // AppKernel.php new EzSystems\EzFlowMigrationToolkitBundle\EzSystemsEzFlowMigrationToolkitBundle() ``` @@ -604,7 +604,7 @@ You can see a report summarizing the results of the migration. **6.** Add `MigrationBundle` to `AppKernel.php`. -``` php +``` php skip-validation // AppKernel.php new MigrationBundle\MigrationBundle() ``` diff --git a/docs/users/segment_api.md b/docs/users/segment_api.md index 2a49d8833e..480161347d 100644 --- a/docs/users/segment_api.md +++ b/docs/users/segment_api.md @@ -65,5 +65,7 @@ To update a segment or a segment group, use `SegmentationService::updateSegment( To delete a segment or a segment group, use `SegmentationService::removeSegment()` or `SegmentationService::removeSegmentGroup()`: ``` php -$this->segmentationService->removeSegmentGroup($group); +/** @var \Ibexa\Segmentation\Value\SegmentGroup $group */ +/** @var \Ibexa\Contracts\Segmentation\SegmentationServiceInterface $segmentationService */ +$segmentationService->removeSegmentGroup($group); ``` diff --git a/docs/users/user_authentication.md b/docs/users/user_authentication.md index 9ec9e79c5d..ef48d6f542 100644 --- a/docs/users/user_authentication.md +++ b/docs/users/user_authentication.md @@ -77,9 +77,9 @@ Don't mix `MVCEvents::INTERACTIVE_LOGIN` event (specific to [[= product_name =]] namespace App\EventListener; use Ibexa\Contracts\Core\Repository\UserService; -use eIbexa\Core\MVC\Symfony\Event\InteractiveLoginEvent; -use Ibexa\Core\MVC\Symfony\MVCEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; +use Symfony\Component\Security\Http\SecurityEvents; class InteractiveLoginListener implements EventSubscriberInterface { @@ -93,18 +93,19 @@ class InteractiveLoginListener implements EventSubscriberInterface $this->userService = $userService; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ - MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin' + SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin' ]; } - public function onInteractiveLogin(InteractiveLoginEvent $event) + public function onInteractiveLogin(InteractiveLoginEvent $event): void { // This loads a generic User and assigns it back to the event. // You may want to create Users here, or even load predefined Users depending on your own rules. - $event->setApiUser($this->userService->loadUserByLogin( 'lolautruche' )); + $user = $this->userService->loadUserByLogin('lolautruche'); + // Use $user as needed (e.g., store in session or token) } -}  +} ``` diff --git a/tests/Markdown/MarkdownPhpExtractor.php b/tests/Markdown/MarkdownPhpExtractor.php new file mode 100644 index 0000000000..125f7eff4f --- /dev/null +++ b/tests/Markdown/MarkdownPhpExtractor.php @@ -0,0 +1,91 @@ +[^\n]*) captures the rest of the opening line (hl_lines, custom markers…) + * - (.*?) captures the block body (non-greedy) + * - \n\1``` requires the closing fence to match the same indentation + */ + private const string FENCE_PATTERN = '/^(?P *)```\s*php(?P[^\n]*)\n(?P.*?)\n(?P=indent)```/ms'; + + private const string SKIP_PATTERN = '/include_file\s*\(|--8<--/'; + + private const string SKIP_VALIDATION_MARKER = 'skip-validation'; + + /** + * @return iterable + */ + public function extract(string $content): iterable + { + if (!preg_match_all(self::FENCE_PATTERN, $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { + return; + } + + foreach ($matches as $match) { + $info = $match['info'][0]; + $body = $match['body'][0]; + $offset = $match['body'][1]; + + if (str_contains($info, self::SKIP_VALIDATION_MARKER)) { + continue; + } + + if (preg_match(self::SKIP_PATTERN, $body)) { + continue; + } + + $indent = $match['indent'][0]; + if ($indent !== '') { + $body = $this->stripIndentation($body, strlen($indent)); + } + + $line = substr_count(substr($content, 0, $offset), "\n") + 1; + + yield ['body' => $body, 'line' => $line]; + } + } + + private function stripIndentation(string $body, int $spaces): string + { + $prefix = str_repeat(' ', $spaces); + $lines = explode("\n", $body); + $stripped = array_map( + static fn (string $line): string => str_starts_with($line, $prefix) + ? substr($line, $spaces) + : $line, + $lines + ); + + return implode("\n", $stripped); + } +} diff --git a/tests/Markdown/MarkdownYamlExtractor.php b/tests/Markdown/MarkdownYamlExtractor.php index a78f95385d..5fe42970dc 100644 --- a/tests/Markdown/MarkdownYamlExtractor.php +++ b/tests/Markdown/MarkdownYamlExtractor.php @@ -19,6 +19,10 @@ * * Blocks containing [[= include_file(...) =]] or --8<-- are skipped because * they reference code_samples/ files that are validated separately. + * + * Blocks whose opening fence contains the marker "skip-validation" are also + * skipped, e.g.: ```yaml skip-validation + * The marker has no effect on MkDocs rendering. */ final class MarkdownYamlExtractor { @@ -26,14 +30,16 @@ final class MarkdownYamlExtractor * Pattern components: * - ^( *) captures optional leading indentation (admonitions indent by 4 spaces) * - ```\s*yaml matches the opening fence with optional space before language tag - * - [^\n]* allows trailing annotations like hl_lines="1 2" + * - (?P[^\n]*) captures the rest of the opening line (hl_lines, custom markers…) * - (.*?) captures the block body (non-greedy) * - \n\1``` requires the closing fence to match the same indentation */ - private const string FENCE_PATTERN = '/^(?P *)```\s*yaml[^\n]*\n(?P.*?)\n(?P=indent)```/ms'; + private const string FENCE_PATTERN = '/^(?P *)```\s*yaml(?P[^\n]*)\n(?P.*?)\n(?P=indent)```/ms'; private const string SKIP_PATTERN = '/include_file\s*\(|--8<--/'; + private const string SKIP_VALIDATION_MARKER = 'skip-validation'; + /** * @return iterable */ @@ -44,9 +50,14 @@ public function extract(string $content): iterable } foreach ($matches as $match) { + $info = $match['info'][0]; $body = $match['body'][0]; $offset = $match['body'][1]; + if (str_contains($info, self::SKIP_VALIDATION_MARKER)) { + continue; + } + if (preg_match(self::SKIP_PATTERN, $body)) { continue; } diff --git a/tools/extract-inline-php.php b/tools/extract-inline-php.php new file mode 100644 index 0000000000..8774ec45d1 --- /dev/null +++ b/tools/extract-inline-php.php @@ -0,0 +1,138 @@ +#!/usr/bin/env php +isDir()) { + rmdir($item->getRealPath()); + } else { + unlink($item->getRealPath()); + } + } + + rmdir($dir); +} + +// Clean up the output directory from the previous run to avoid stale files +// (e.g. from docs that were renamed, moved, or had snippets removed). +removeDirectory(OUTPUT_DIR); + +$extractor = new MarkdownPhpExtractor(); + +$iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator(DOCS_DIR, RecursiveDirectoryIterator::SKIP_DOTS), +); + +$fileCount = 0; +$snippetCount = 0; + +/** @var SplFileInfo $file */ +foreach ($iterator as $file) { + if (!$file->isFile() || $file->getExtension() !== 'md') { + continue; + } + + $mdPath = $file->getRealPath(); + $content = file_get_contents($mdPath); + + if ($content === false) { + continue; + } + + $blocks = iterator_to_array($extractor->extract($content)); + + if (empty($blocks)) { + continue; + } + + // Relative path from docs/ root, e.g. "commerce/cart/cart_api.md" + $relativeFromDocs = ltrim(substr($mdPath, strlen(realpath(DOCS_DIR))), DIRECTORY_SEPARATOR); + + // Strip .md extension and use as subdirectory name + $subDir = OUTPUT_DIR . DIRECTORY_SEPARATOR . substr($relativeFromDocs, 0, -3); + + if (!is_dir($subDir) && !mkdir($subDir, 0755, true) && !is_dir($subDir)) { + fwrite(STDERR, "ERROR: Could not create directory: $subDir\n"); + exit(1); + } + + // Relative path used in the source comment, e.g. "docs/commerce/cart/cart_api.md" + $sourceRelPath = 'docs/' . str_replace(DIRECTORY_SEPARATOR, '/', $relativeFromDocs); + + foreach ($blocks as $block) { + $line = $block['line']; + $body = $block['body']; + + $outputFile = $subDir . DIRECTORY_SEPARATOR . "line_{$line}.php"; + + // Strip any existing