From 5232cf7ed65058e8010592980815c7e85507fe62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 21 May 2025 16:56:13 +0200 Subject: [PATCH 01/26] [CI] Added job running Rector --- .github/workflows/code_samples.yaml | 25 +++++++++++++++++++++++++ rector.php | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 rector.php diff --git a/.github/workflows/code_samples.yaml b/.github/workflows/code_samples.yaml index 4721bce9f9..6986a9bbea 100644 --- a/.github/workflows/code_samples.yaml +++ b/.github/workflows/code_samples.yaml @@ -143,3 +143,28 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body-path: code_samples_usage.diff.md edit-mode: replace + + rector: + name: Run rector + runs-on: "ubuntu-22.04" + strategy: + matrix: + php: + - '8.3' + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP Action + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + extensions: 'pdo_sqlite, gd' + tools: cs2pr + + - uses: ramsey/composer-install@v3 + with: + dependency-versions: highest + + - name: Run rector + run: vendor/bin/rector process --dry-run --ansi diff --git a/rector.php b/rector.php new file mode 100644 index 0000000000..669d153f8b --- /dev/null +++ b/rector.php @@ -0,0 +1,27 @@ +withPaths([ + __DIR__ . '/code_samples', + ]) + ->withSets([ + IbexaSetList::IBEXA_50->value, + SymfonySetList::SYMFONY_60, + SymfonySetList::SYMFONY_61, + SymfonySetList::SYMFONY_62, + SymfonySetList::SYMFONY_63, + SymfonySetList::SYMFONY_64, + SymfonySetList::SYMFONY_70, + SymfonySetList::SYMFONY_71, + SymfonySetList::SYMFONY_72, + ]); From 7c5c88c40e13813c6f2b9e7a3c8e9c8d5a842f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 21 May 2025 17:03:13 +0200 Subject: [PATCH 02/26] Run Rector and Code Style --- .../src/Command/AddLanguageCommand.php | 5 +- .../Command/AddLocationToContentCommand.php | 5 +- .../src/Command/BrowseLocationsCommand.php | 5 +- .../src/Command/CalendarCommand.php | 5 +- .../src/Command/FilterCommand.php | 5 +- .../src/Command/FilterLocationCommand.php | 5 +- .../src/Command/FindComplexCommand.php | 5 +- .../src/Command/FindContentCommand.php | 5 +- .../src/Command/FindInTrashCommand.php | 5 +- .../src/Command/FindUrlCommand.php | 6 +- .../Command/FindWithAggregationCommand.php | 6 +- .../src/Command/HideLocationCommand.php | 5 +- .../src/Command/MoveContentCommand.php | 5 +- .../src/Command/ObjectStateCommand.php | 5 +- .../src/Command/SectionCommand.php | 5 +- .../src/Command/SetMainLocationCommand.php | 5 +- .../src/Command/UpdateContentCommand.php | 5 +- .../src/Command/ViewContentCommand.php | 5 +- .../Command/ViewContentMetaDataCommand.php | 5 +- .../src/Command/WorkflowCommand.php | 5 +- .../src/Command/DashboardCommand.php | 6 +- .../back_office/images/src/SvgExtension.php | 5 +- .../Controller/AllContentListController.php | 2 +- .../src/EventSubscriber/MyMenuSubscriber.php | 2 +- .../ContentPublishEventListener.php | 2 +- .../Storage/PercentStorageDefinition.php | 1 + .../CheckboxWithRichtextDescriptionType.php | 4 +- .../AttributeRichtextDescriptionType.php | 4 +- .../src/Command/ViewCommand.php | 6 +- .../Controller/Checkout/OnePageCheckout.php | 2 +- .../Step/SelectSeatStepController.php | 2 +- .../BreadcrumbsMenuSubscriber.php | 2 +- .../Block/Attribute/MyStringAttributeType.php | 4 +- .../src/Block/Listener/MyBlockListener.php | 2 +- .../src/Event/RandomBlockListener.php | 2 +- .../src/OAuth/GoogleResourceOwnerMapper.php | 4 +- output.txt | 895 ++++++++++++++++++ .../step4/RandomBlockListener.php | 1 + tests/src/ConfigurationEditor.php | 1 + tests/src/ContentDataCreator.php | 1 + tests/src/Context/ConfigurationContext.php | 1 + tests/src/Context/ContentContext.php | 1 + tests/src/Context/FileContext.php | 1 + .../Context/TutorialContentTypeContext.php | 1 + 44 files changed, 944 insertions(+), 110 deletions(-) create mode 100644 output.txt diff --git a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php index 3025e68e4f..8902f0cbe6 100644 --- a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php @@ -10,9 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:add_language' -)] +#[AsCommand(name: 'doc:add_language', description: 'Lists available languages and add Polish.')] class AddLanguageCommand extends Command { private LanguageService $languageService; @@ -32,7 +30,6 @@ public function __construct(LanguageService $languageService, UserService $userS protected function configure(): void { - $this->setDescription('Lists available languages and add Polish.'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php index 6d7d99c498..16277a58a0 100644 --- a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php @@ -12,9 +12,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:add_location' -)] +#[AsCommand(name: 'doc:add_location', description: 'Add a Location to content item and hides it.')] class AddLocationToContentCommand extends Command { private ContentService $contentService; @@ -38,7 +36,6 @@ public function __construct(ContentService $contentService, LocationService $loc protected function configure(): void { $this - ->setDescription('Add a Location to content item and hides it.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), new InputArgument('parentLocationId', InputArgument::REQUIRED, 'Parent Location ID'), diff --git a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php index b3a39049a3..d7da5b02ac 100644 --- a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php +++ b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php @@ -10,9 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:browse_locations' -)] +#[AsCommand(name: 'doc:browse_locations', description: 'Lists all descendants of the Location')] class BrowseLocationsCommand extends Command { private LocationService $locationService; @@ -27,7 +25,6 @@ public function __construct(LocationService $locationService) protected function configure(): void { $this - ->setDescription('Lists all descendants of the Location') ->setDefinition([ new InputArgument('locationId', InputArgument::REQUIRED, 'Location ID to browse from'), ]); diff --git a/code_samples/api/public_php_api/src/Command/CalendarCommand.php b/code_samples/api/public_php_api/src/Command/CalendarCommand.php index ea46cf7088..ae35627449 100644 --- a/code_samples/api/public_php_api/src/Command/CalendarCommand.php +++ b/code_samples/api/public_php_api/src/Command/CalendarCommand.php @@ -12,9 +12,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:calendar' -)] +#[AsCommand(name: 'doc:calendar', description: 'Lists Calendar event in the provided time range and reschedules them.')] class CalendarCommand extends Command { private PermissionResolver $permissionResolver; @@ -34,7 +32,6 @@ public function __construct(PermissionResolver $permissionResolver, UserService public function configure(): void { - $this->setDescription('Lists Calendar event in the provided time range and reschedules them.'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/code_samples/api/public_php_api/src/Command/FilterCommand.php b/code_samples/api/public_php_api/src/Command/FilterCommand.php index c4f6b26515..9fea5c5210 100644 --- a/code_samples/api/public_php_api/src/Command/FilterCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterCommand.php @@ -13,9 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:filter' -)] +#[AsCommand(name: 'doc:filter', description: 'Returns children of the provided Location, sorted by name in descending order.')] class FilterCommand extends Command { private ContentService $contentService; @@ -29,7 +27,6 @@ public function __construct(ContentService $contentService) public function configure(): void { - $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); $this->setDefinition([ new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php index e7f68046fa..eca95826ad 100644 --- a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php @@ -13,9 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:filter_location' -)] +#[AsCommand(name: 'doc:filter_location', description: 'Returns children of the provided Location, sorted by name in descending order.')] class FilterLocationCommand extends Command { private LocationService $locationService; @@ -29,7 +27,6 @@ public function __construct(LocationService $locationService) public function configure(): void { - $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); $this->setDefinition([ new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php index fdf2d72cb1..9416b28f35 100644 --- a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php @@ -13,9 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:find_complex' -)] +#[AsCommand(name: 'doc:find_complex', description: 'Lists content belonging to the provided content type.')] class FindComplexCommand extends Command { private SearchService $searchService; @@ -33,7 +31,6 @@ public function __construct(SearchService $searchService, LocationService $locat protected function configure(): void { $this - ->setDescription('Lists content belonging to the provided content type.') ->setDefinition([ new InputArgument('locationId', InputArgument::REQUIRED, ''), new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), diff --git a/code_samples/api/public_php_api/src/Command/FindContentCommand.php b/code_samples/api/public_php_api/src/Command/FindContentCommand.php index 881a10d87a..41d988bafa 100644 --- a/code_samples/api/public_php_api/src/Command/FindContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindContentCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:find_content' -)] +#[AsCommand(name: 'doc:find_content', description: 'Lists content belonging to the provided content type.')] class FindContentCommand extends Command { private SearchService $searchService; @@ -28,7 +26,6 @@ public function __construct(SearchService $searchService) protected function configure(): void { $this - ->setDescription('Lists content belonging to the provided content type.') ->setDefinition([ new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php index 0910cf7a01..aaf6c01d1b 100644 --- a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php @@ -10,9 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:find_in_trash' -)] +#[AsCommand(name: 'doc:find_in_trash', description: 'Lists content in Trash belonging to the provided content type.')] class FindInTrashCommand extends Command { private TrashService $trashService; @@ -27,7 +25,6 @@ public function __construct(TrashService $trashService) protected function configure(): void { $this - ->setDescription('Lists content in Trash belonging to the provided content type.') ->setDefinition([ new InputArgument('contentTypeId', InputArgument::REQUIRED, 'Content type ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php index c5b1b13aa7..403e3cd1b0 100644 --- a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php @@ -13,9 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:find_url' -)] +#[AsCommand(name: 'doc:find_url', description: 'Finds all valid URLs in the provided Section.')] class FindUrlCommand extends Command { private URLService $urlService; @@ -35,8 +33,6 @@ public function __construct(URLService $URLService, UserService $userService, Pe protected function configure(): void { - $this - ->setDescription('Finds all valid URLs in the provided Section.'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php index b8de4edf94..60a2dacc98 100644 --- a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php @@ -12,9 +12,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:find_with_aggregation' -)] +#[AsCommand(name: 'doc:find_with_aggregation', description: 'Counts content per content type and the value of Selection Field.')] class FindWithAggregationCommand extends Command { private SearchService $searchService; @@ -28,8 +26,6 @@ public function __construct(SearchService $searchService) protected function configure(): void { - $this - ->setDescription('Counts content per content type and the value of Selection Field.'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php index 86ba8dc96a..4dce2720e1 100644 --- a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:hide' -)] +#[AsCommand(name: 'doc:hide', description: 'Hides and reveals again selected Location.')] class HideLocationCommand extends Command { private LocationService $locationService; @@ -34,7 +32,6 @@ public function __construct(LocationService $locationService, UserService $userS protected function configure(): void { $this - ->setDescription('Hides and reveals again selected Location.') ->setDefinition([ new InputArgument('location_id', InputArgument::REQUIRED, 'Location ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php index 12b9f3e95f..f1443d3a5a 100644 --- a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:move_content' -)] +#[AsCommand(name: 'doc:move_content', description: 'Moves the selected Location with its subtree.')] class MoveContentCommand extends Command { private LocationService $locationService; @@ -34,7 +32,6 @@ public function __construct(LocationService $locationService, UserService $userS protected function configure(): void { $this - ->setDescription('Moves the selected Location with its subtree.') ->setDefinition([ new InputArgument('locationId', InputArgument::REQUIRED, 'Location to copy'), new InputArgument('targetLocationId', InputArgument::REQUIRED, 'Target to copy or move to'), diff --git a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php index a7da6a3ffc..711f5cec02 100644 --- a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php +++ b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php @@ -12,9 +12,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:object_state' -)] +#[AsCommand(name: 'doc:object_state', description: 'Creates OS group with provided States and assigned the Lock OS to provided content item')] class ObjectStateCommand extends Command { private ContentService $contentService; @@ -38,7 +36,6 @@ public function __construct(ContentService $contentService, UserService $userSer protected function configure(): void { $this - ->setDescription('Creates OS group with provided States and assigned the Lock OS to provided content item') ->setDefinition([ new InputArgument('objectStateGroupIdentifier', InputArgument::REQUIRED, 'Identifier of new OG group to create'), new InputArgument('objectStateIdentifier', InputArgument::REQUIRED, 'Identifier(s) of a new Object State'), diff --git a/code_samples/api/public_php_api/src/Command/SectionCommand.php b/code_samples/api/public_php_api/src/Command/SectionCommand.php index 1f06cf1152..fea19f5b04 100644 --- a/code_samples/api/public_php_api/src/Command/SectionCommand.php +++ b/code_samples/api/public_php_api/src/Command/SectionCommand.php @@ -15,9 +15,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:section' -)] +#[AsCommand(name: 'doc:section', description: 'Creates new section and adds selected content item to it.')] class SectionCommand extends Command { private SectionService $sectionService; @@ -44,7 +42,6 @@ public function __construct(SectionService $sectionService, UserService $userSer protected function configure(): void { $this - ->setDescription('Creates new section and adds selected content item to it.') ->setDefinition([ new InputArgument('sectionName', InputArgument::REQUIRED, 'Name of the new Section'), new InputArgument('sectionIdentifier', InputArgument::REQUIRED, 'Identifier of the new Section'), diff --git a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php index 1d75a60d5d..dd665062c7 100644 --- a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:set_main_location' -)] +#[AsCommand(name: 'doc:set_main_location', description: 'Set a Location as content item\'s main')] class SetMainLocationCommand extends Command { private ContentService $contentService; @@ -34,7 +32,6 @@ public function __construct(ContentService $contentService, UserService $userSer protected function configure(): void { $this - ->setDescription('Set a Location as content item\'s main') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'The Content ID'), new InputArgument('locationId', InputArgument::REQUIRED, 'One of the Locations of the Content'), diff --git a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php index 4bd45f5569..f807bdf759 100644 --- a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:update_content' -)] +#[AsCommand(name: 'doc:update_content', description: 'Update provided content item with a new name')] class UpdateContentCommand extends Command { private ContentService $contentService; @@ -34,7 +32,6 @@ public function __construct(ContentService $contentService, UserService $userSer protected function configure(): void { $this - ->setDescription('Update provided content item with a new name') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), new InputArgument('newName', InputArgument::REQUIRED, 'New name for the updated content item'), diff --git a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php index 02ca0536e3..bdfb99ed62 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:view_content' -)] +#[AsCommand(name: 'doc:view_content', description: 'Output Field values on provided content item.')] class ViewContentCommand extends Command { private ContentService $contentService; @@ -34,7 +32,6 @@ public function __construct(ContentService $contentService, ContentTypeService $ protected function configure(): void { $this - ->setDescription('Output Field values on provided content item.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Location ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php index 35d37c56b8..1ac31f8dcd 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php @@ -15,9 +15,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:view_metadata' -)] +#[AsCommand(name: 'doc:view_metadata', description: 'Output various metadata about a content item.')] class ViewContentMetaDataCommand extends Command { private ContentService $contentService; @@ -47,7 +45,6 @@ public function __construct(ContentService $contentService, LocationService $loc protected function configure(): void { $this - ->setDescription('Output various metadata about a content item.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'An existing content ID'), ]); diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index 60cf29d89a..362ca64322 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:workflow' -)] +#[AsCommand(name: 'doc:workflow', description: 'Starts content in the selected workflow and makes the provided transition.')] class WorkflowCommand extends Command { private WorkflowServiceInterface $workflowService; @@ -34,7 +32,6 @@ public function __construct(WorkflowServiceInterface $workflowService, WorkflowR protected function configure(): void { $this - ->setDescription('Starts content in the selected workflow and makes the provided transition.') ->setDefinition([ new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), new InputArgument('workflowName', InputArgument::REQUIRED, 'Workflow identifier'), diff --git a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php index 512441effc..57a57ed107 100644 --- a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php +++ b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php @@ -14,9 +14,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'doc:dashboard' -)] +#[AsCommand(name: 'doc:dashboard', description: 'Set a custom dashboard to user group.')] class DashboardCommand extends Command { private DashboardServiceInterface $dashboardService; @@ -44,7 +42,7 @@ public function __construct( public function configure(): void { - $this->setDescription('Set a custom dashboard to user group.') + $this ->addArgument('dashboard', InputArgument::REQUIRED, 'Location ID of the dashboard model') ->addArgument('group', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'User Group Content ID(s)'); } diff --git a/code_samples/back_office/images/src/SvgExtension.php b/code_samples/back_office/images/src/SvgExtension.php index 48ef14c583..821d6250e6 100644 --- a/code_samples/back_office/images/src/SvgExtension.php +++ b/code_samples/back_office/images/src/SvgExtension.php @@ -26,10 +26,7 @@ public function __construct(RouterInterface $router) public function getFunctions(): array { return [ - new TwigFunction('ibexa_svg_link', [ - $this, - 'generateLink', - ]), + new TwigFunction('ibexa_svg_link', $this->generateLink(...)), ]; } diff --git a/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php b/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php index 4feca732a4..01aa512d68 100644 --- a/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php +++ b/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php @@ -39,7 +39,7 @@ public function listAction(int $page = 1): Response return $this->render('@ibexadesign/all_content_list.html.twig', [ 'totalCount' => $paginator->getNbResults(), 'articles' => $paginator, - 'form_edit' => $editForm->createView(), + 'form_edit' => $editForm, ]); } } diff --git a/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php b/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php index 4b2d2e545a..be803e3d9d 100644 --- a/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php +++ b/code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php @@ -8,7 +8,7 @@ class MyMenuSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConfigureMenuEvent::MAIN_MENU => ['onMainMenuConfigure', 0], diff --git a/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php b/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php index e89a5c7d81..3c2a651a32 100644 --- a/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php +++ b/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php @@ -16,7 +16,7 @@ public function __construct(NotificationService $notificationService) $this->notificationService = $notificationService; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [PublishVersionEvent::class => 'onPublishVersion']; } diff --git a/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php b/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php index 415c784344..7fc8fe59e0 100644 --- a/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php +++ b/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa AS. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ declare(strict_types=1); diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php index ab4060a679..d0b801a0a0 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php @@ -13,7 +13,7 @@ class CheckboxWithRichtextDescriptionType extends AbstractType /** * @return string|null */ - public function getParent() + public function getParent(): ?string { return CheckboxType::class; } @@ -21,7 +21,7 @@ public function getParent() /** * @return string */ - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'checkbox_with_richtext_description'; } diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php index bb5101a2fd..27728d1688 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php @@ -10,7 +10,7 @@ class AttributeRichtextDescriptionType extends AbstractType /** * @return string|null */ - public function getParent() + public function getParent(): ?string { return RichTextType::class; } @@ -18,7 +18,7 @@ public function getParent() /** * @return string */ - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'field_configuration_attribute_richtext'; } diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index 7c8222d0d0..d7b2d79f8f 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -10,9 +10,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand( - name: 'app:view' -)] +#[AsCommand(name: 'app:view', description: 'Render the view of a content item')] class ViewCommand extends Command { private ContentViewBuilder $contentViewBuilder; @@ -31,7 +29,7 @@ public function __construct( protected function configure(): void { - $this->setDescription('Render the view of a content item') + $this ->addOption('content-id', 'c', InputOption::VALUE_OPTIONAL, 'Content ID') ->addOption('location-id', 'l', InputOption::VALUE_OPTIONAL, 'Location ID') ->addOption('view-type', 't', InputOption::VALUE_OPTIONAL, 'View Type', 'line'); diff --git a/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php b/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php index f52d8d355b..3bc1896bb3 100644 --- a/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php +++ b/code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php @@ -44,7 +44,7 @@ public function __invoke( return $this->render( '@storefront/checkout/checkout.html.twig', [ - 'form' => $form->createView(), + 'form' => $form, 'checkout' => $checkout, ] ); diff --git a/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php b/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php index bc36d0fdce..b2479c371a 100644 --- a/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php +++ b/code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php @@ -30,7 +30,7 @@ public function __invoke( 'layout' => $this->getSeatsLayout(), 'current_step' => $step, 'checkout' => $checkout, - 'form' => $form->createView(), + 'form' => $form, ] ); } diff --git a/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php b/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php index 5aa1e016f4..5bd8acf1b0 100644 --- a/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php +++ b/code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php @@ -10,7 +10,7 @@ class BreadcrumbsMenuSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ BreadcrumbsMenuBuilder::PRODUCT_MENU => ['onBreadcrumbsMenuConfigure', 0], diff --git a/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php b/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php index 9a9fe33d03..22e65e7f7b 100644 --- a/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php +++ b/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php @@ -7,12 +7,12 @@ class MyStringAttributeType extends AbstractType { - public function getParent() + public function getParent(): ?string { return TextType::class; } - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'my_string_attribute'; } diff --git a/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php b/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php index 25aa71cc3e..716cba8645 100644 --- a/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php +++ b/code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php @@ -8,7 +8,7 @@ class MyBlockListener implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ BlockRenderEvents::getBlockPreRenderEventName('event') => 'onBlockPreRender', diff --git a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php index 69d412a9b0..6415335e83 100644 --- a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php +++ b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php @@ -32,7 +32,7 @@ public function __construct( $this->searchService = $searchService; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ BlockRenderEvents::getBlockPreRenderEventName('random') => 'onBlockPreRender', diff --git a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php index 33128465fb..b34bb9e854 100644 --- a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php +++ b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php @@ -55,7 +55,7 @@ protected function loadUser( ResourceOwnerInterface $resourceOwner, UserProviderInterface $userProvider ): ?UserInterface { - return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); + return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); } /** @@ -82,7 +82,7 @@ protected function createUser( $this->userService->createUser($userCreateStruct, $parentGroups); - return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); + return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); } private function getOAuth2UserContentType(Repository $repository): ?ContentType diff --git a/output.txt b/output.txt new file mode 100644 index 0000000000..77682737eb --- /dev/null +++ b/output.txt @@ -0,0 +1,895 @@ + +35 files with changes +===================== + +1) code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php:8 + + ---------- begin diff ---------- +@@ @@ + + class MyBlockListener implements EventSubscriberInterface + { +- public static function getSubscribedEvents() ++ public static function getSubscribedEvents(): array + { + return [ + BlockRenderEvents::getBlockPreRenderEventName('event') => 'onBlockPreRender', + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +2) code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php:32 + + ---------- begin diff ---------- +@@ @@ + $this->searchService = $searchService; + } + +- public static function getSubscribedEvents() ++ public static function getSubscribedEvents(): array + { + return [ + BlockRenderEvents::getBlockPreRenderEventName('random') => 'onBlockPreRender', + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +3) code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php:55 + + ---------- begin diff ---------- +@@ @@ + ResourceOwnerInterface $resourceOwner, + UserProviderInterface $userProvider + ): ?UserInterface { +- return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); ++ return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); + } + + /** +@@ @@ + + $this->userService->createUser($userCreateStruct, $parentGroups); + +- return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); ++ return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); + } + + private function getOAuth2UserContentType(Repository $repository): ?ContentType + ----------- end diff ----------- + +Applied rules: + * RenameMethodRector + + +4) code_samples/api/public_php_api/src/Command/UpdateContentCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:update_content' +-)] ++#[AsCommand(name: 'doc:update_content', description: 'Update provided content item with a new name')] + class UpdateContentCommand extends Command + { + private ContentService $contentService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Update provided content item with a new name') + ->setDefinition([ + new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), + new InputArgument('newName', InputArgument::REQUIRED, 'New name for the updated content item'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +5) code_samples/api/public_php_api/src/Command/ViewContentCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:view_content' +-)] ++#[AsCommand(name: 'doc:view_content', description: 'Output Field values on provided content item.')] + class ViewContentCommand extends Command + { + private ContentService $contentService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Output Field values on provided content item.') + ->setDefinition([ + new InputArgument('contentId', InputArgument::REQUIRED, 'Location ID'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +6) code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php:15 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:view_metadata' +-)] ++#[AsCommand(name: 'doc:view_metadata', description: 'Output various metadata about a content item.')] + class ViewContentMetaDataCommand extends Command + { + private ContentService $contentService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Output various metadata about a content item.') + ->setDefinition([ + new InputArgument('contentId', InputArgument::REQUIRED, 'An existing content ID'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +7) code_samples/api/public_php_api/src/Command/WorkflowCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:workflow' +-)] ++#[AsCommand(name: 'doc:workflow', description: 'Starts content in the selected workflow and makes the provided transition.')] + class WorkflowCommand extends Command + { + private WorkflowServiceInterface $workflowService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Starts content in the selected workflow and makes the provided transition.') + ->setDefinition([ + new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), + new InputArgument('workflowName', InputArgument::REQUIRED, 'Workflow identifier'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +8) code_samples/back_office/dashboard/src/Command/DashboardCommand.php:14 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:dashboard' +-)] ++#[AsCommand(name: 'doc:dashboard', description: 'Set a custom dashboard to user group.')] + class DashboardCommand extends Command + { + private DashboardServiceInterface $dashboardService; +@@ @@ + + public function configure(): void + { +- $this->setDescription('Set a custom dashboard to user group.') ++ $this + ->addArgument('dashboard', InputArgument::REQUIRED, 'Location ID of the dashboard model') + ->addArgument('group', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'User Group Content ID(s)'); + } + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +9) code_samples/back_office/images/src/SvgExtension.php:26 + + ---------- begin diff ---------- +@@ @@ + public function getFunctions(): array + { + return [ +- new TwigFunction('ibexa_svg_link', [ +- $this, +- 'generateLink', +- ]), ++ new TwigFunction('ibexa_svg_link', $this->generateLink(...)), + ]; + } + ----------- end diff ----------- + +Applied rules: + * MagicClosureTwigExtensionToNativeMethodsRector + + +10) code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php:39 + + ---------- begin diff ---------- +@@ @@ + return $this->render('@ibexadesign/all_content_list.html.twig', [ + 'totalCount' => $paginator->getNbResults(), + 'articles' => $paginator, +- 'form_edit' => $editForm->createView(), ++ 'form_edit' => $editForm, + ]); + } + } + ----------- end diff ----------- + +Applied rules: + * SimplifyFormRenderingRector + + +11) code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php:8 + + ---------- begin diff ---------- +@@ @@ + + class MyMenuSubscriber implements EventSubscriberInterface + { +- public static function getSubscribedEvents() ++ public static function getSubscribedEvents(): array + { + return [ + ConfigureMenuEvent::MAIN_MENU => ['onMainMenuConfigure', 0], + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +12) code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php:16 + + ---------- begin diff ---------- +@@ @@ + $this->notificationService = $notificationService; + } + +- public static function getSubscribedEvents() ++ public static function getSubscribedEvents(): array + { + return [PublishVersionEvent::class => 'onPublishVersion']; + } + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +13) code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php:13 + + ---------- begin diff ---------- +@@ @@ + /** + * @return string|null + */ +- public function getParent() ++ public function getParent(): ?string + { + return CheckboxType::class; + } +@@ @@ + /** + * @return string + */ +- public function getBlockPrefix() ++ public function getBlockPrefix(): string + { + return 'checkbox_with_richtext_description'; + } + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +14) code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php:10 + + ---------- begin diff ---------- +@@ @@ + /** + * @return string|null + */ +- public function getParent() ++ public function getParent(): ?string + { + return RichTextType::class; + } +@@ @@ + /** + * @return string + */ +- public function getBlockPrefix() ++ public function getBlockPrefix(): string + { + return 'field_configuration_attribute_richtext'; + } + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +15) code_samples/front/render_content_in_php/src/Command/ViewCommand.php:10 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'app:view' +-)] ++#[AsCommand(name: 'app:view', description: 'Render the view of a content item')] + class ViewCommand extends Command + { + private ContentViewBuilder $contentViewBuilder; +@@ @@ + + protected function configure(): void + { +- $this->setDescription('Render the view of a content item') ++ $this + ->addOption('content-id', 'c', InputOption::VALUE_OPTIONAL, 'Content ID') + ->addOption('location-id', 'l', InputOption::VALUE_OPTIONAL, 'Location ID') + ->addOption('view-type', 't', InputOption::VALUE_OPTIONAL, 'View Type', 'line'); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +16) code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php:44 + + ---------- begin diff ---------- +@@ @@ + return $this->render( + '@storefront/checkout/checkout.html.twig', + [ +- 'form' => $form->createView(), ++ 'form' => $form, + 'checkout' => $checkout, + ] + ); + ----------- end diff ----------- + +Applied rules: + * SimplifyFormRenderingRector + + +17) code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php:30 + + ---------- begin diff ---------- +@@ @@ + 'layout' => $this->getSeatsLayout(), + 'current_step' => $step, + 'checkout' => $checkout, +- 'form' => $form->createView(), ++ 'form' => $form, + ] + ); + } + ----------- end diff ----------- + +Applied rules: + * SimplifyFormRenderingRector + + +18) code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php:10 + + ---------- begin diff ---------- +@@ @@ + + class BreadcrumbsMenuSubscriber implements EventSubscriberInterface + { +- public static function getSubscribedEvents() ++ public static function getSubscribedEvents(): array + { + return [ + BreadcrumbsMenuBuilder::PRODUCT_MENU => ['onBreadcrumbsMenuConfigure', 0], + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +19) code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php:7 + + ---------- begin diff ---------- +@@ @@ + + class MyStringAttributeType extends AbstractType + { +- public function getParent() ++ public function getParent(): ?string + { + return TextType::class; + } + +- public function getBlockPrefix() ++ public function getBlockPrefix(): string + { + return 'my_string_attribute'; + } + ----------- end diff ----------- + +Applied rules: + * AddReturnTypeDeclarationRector + + +20) code_samples/api/public_php_api/src/Command/AddLanguageCommand.php:10 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:add_language' +-)] ++#[AsCommand(name: 'doc:add_language', description: 'Lists available languages and add Polish.')] + class AddLanguageCommand extends Command + { + private LanguageService $languageService; +@@ @@ + + protected function configure(): void + { +- $this->setDescription('Lists available languages and add Polish.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +21) code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php:12 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:add_location' +-)] ++#[AsCommand(name: 'doc:add_location', description: 'Add a Location to content item and hides it.')] + class AddLocationToContentCommand extends Command + { + private ContentService $contentService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Add a Location to content item and hides it.') + ->setDefinition([ + new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), + new InputArgument('parentLocationId', InputArgument::REQUIRED, 'Parent Location ID'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +22) code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php:10 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:browse_locations' +-)] ++#[AsCommand(name: 'doc:browse_locations', description: 'Lists all descendants of the Location')] + class BrowseLocationsCommand extends Command + { + private LocationService $locationService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Lists all descendants of the Location') + ->setDefinition([ + new InputArgument('locationId', InputArgument::REQUIRED, 'Location ID to browse from'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +23) code_samples/api/public_php_api/src/Command/CalendarCommand.php:12 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:calendar' +-)] ++#[AsCommand(name: 'doc:calendar', description: 'Lists Calendar event in the provided time range and reschedules them.')] + class CalendarCommand extends Command + { + private PermissionResolver $permissionResolver; +@@ @@ + + public function configure(): void + { +- $this->setDescription('Lists Calendar event in the provided time range and reschedules them.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +24) code_samples/api/public_php_api/src/Command/FilterCommand.php:13 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:filter' +-)] ++#[AsCommand(name: 'doc:filter', description: 'Returns children of the provided Location, sorted by name in descending order.')] + class FilterCommand extends Command + { + private ContentService $contentService; +@@ @@ + + public function configure(): void + { +- $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); + $this->setDefinition([ + new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +25) code_samples/api/public_php_api/src/Command/FilterLocationCommand.php:13 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:filter_location' +-)] ++#[AsCommand(name: 'doc:filter_location', description: 'Returns children of the provided Location, sorted by name in descending order.')] + class FilterLocationCommand extends Command + { + private LocationService $locationService; +@@ @@ + + public function configure(): void + { +- $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); + $this->setDefinition([ + new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +26) code_samples/api/public_php_api/src/Command/FindComplexCommand.php:13 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:find_complex' +-)] ++#[AsCommand(name: 'doc:find_complex', description: 'Lists content belonging to the provided content type.')] + class FindComplexCommand extends Command + { + private SearchService $searchService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Lists content belonging to the provided content type.') + ->setDefinition([ + new InputArgument('locationId', InputArgument::REQUIRED, ''), + new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +27) code_samples/api/public_php_api/src/Command/FindContentCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:find_content' +-)] ++#[AsCommand(name: 'doc:find_content', description: 'Lists content belonging to the provided content type.')] + class FindContentCommand extends Command + { + private SearchService $searchService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Lists content belonging to the provided content type.') + ->setDefinition([ + new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +28) code_samples/api/public_php_api/src/Command/FindInTrashCommand.php:10 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:find_in_trash' +-)] ++#[AsCommand(name: 'doc:find_in_trash', description: 'Lists content in Trash belonging to the provided content type.')] + class FindInTrashCommand extends Command + { + private TrashService $trashService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Lists content in Trash belonging to the provided content type.') + ->setDefinition([ + new InputArgument('contentTypeId', InputArgument::REQUIRED, 'Content type ID'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +29) code_samples/api/public_php_api/src/Command/FindUrlCommand.php:13 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:find_url' +-)] ++#[AsCommand(name: 'doc:find_url', description: 'Finds all valid URLs in the provided Section.')] + class FindUrlCommand extends Command + { + private URLService $urlService; +@@ @@ + + protected function configure(): void + { +- $this +- ->setDescription('Finds all valid URLs in the provided Section.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +30) code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php:12 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:find_with_aggregation' +-)] ++#[AsCommand(name: 'doc:find_with_aggregation', description: 'Counts content per content type and the value of Selection Field.')] + class FindWithAggregationCommand extends Command + { + private SearchService $searchService; +@@ @@ + + protected function configure(): void + { +- $this +- ->setDescription('Counts content per content type and the value of Selection Field.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +31) code_samples/api/public_php_api/src/Command/HideLocationCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:hide' +-)] ++#[AsCommand(name: 'doc:hide', description: 'Hides and reveals again selected Location.')] + class HideLocationCommand extends Command + { + private LocationService $locationService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Hides and reveals again selected Location.') + ->setDefinition([ + new InputArgument('location_id', InputArgument::REQUIRED, 'Location ID'), + ]); + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +32) code_samples/api/public_php_api/src/Command/MoveContentCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:move_content' +-)] ++#[AsCommand(name: 'doc:move_content', description: 'Moves the selected Location with its subtree.')] + class MoveContentCommand extends Command + { + private LocationService $locationService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Moves the selected Location with its subtree.') + ->setDefinition([ + new InputArgument('locationId', InputArgument::REQUIRED, 'Location to copy'), + new InputArgument('targetLocationId', InputArgument::REQUIRED, 'Target to copy or move to'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +33) code_samples/api/public_php_api/src/Command/ObjectStateCommand.php:12 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:object_state' +-)] ++#[AsCommand(name: 'doc:object_state', description: 'Creates OS group with provided States and assigned the Lock OS to provided content item')] + class ObjectStateCommand extends Command + { + private ContentService $contentService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Creates OS group with provided States and assigned the Lock OS to provided content item') + ->setDefinition([ + new InputArgument('objectStateGroupIdentifier', InputArgument::REQUIRED, 'Identifier of new OG group to create'), + new InputArgument('objectStateIdentifier', InputArgument::REQUIRED, 'Identifier(s) of a new Object State'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +34) code_samples/api/public_php_api/src/Command/SectionCommand.php:15 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:section' +-)] ++#[AsCommand(name: 'doc:section', description: 'Creates new section and adds selected content item to it.')] + class SectionCommand extends Command + { + private SectionService $sectionService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Creates new section and adds selected content item to it.') + ->setDefinition([ + new InputArgument('sectionName', InputArgument::REQUIRED, 'Name of the new Section'), + new InputArgument('sectionIdentifier', InputArgument::REQUIRED, 'Identifier of the new Section'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + +35) code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php:11 + + ---------- begin diff ---------- +@@ @@ + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + +-#[AsCommand( +- name: 'doc:set_main_location' +-)] ++#[AsCommand(name: 'doc:set_main_location', description: 'Set a Location as content item\'s main')] + class SetMainLocationCommand extends Command + { + private ContentService $contentService; +@@ @@ + protected function configure(): void + { + $this +- ->setDescription('Set a Location as content item\'s main') + ->setDefinition([ + new InputArgument('contentId', InputArgument::REQUIRED, 'The Content ID'), + new InputArgument('locationId', InputArgument::REQUIRED, 'One of the Locations of the Content'), + ----------- end diff ----------- + +Applied rules: + * CommandConfigureToAttributeRector + + + [OK] 35 files have been changed by Rector + diff --git a/tests/source_files/step4/RandomBlockListener.php b/tests/source_files/step4/RandomBlockListener.php index 5151296c84..ecee0740b1 100644 --- a/tests/source_files/step4/RandomBlockListener.php +++ b/tests/source_files/step4/RandomBlockListener.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ declare(strict_types=1); diff --git a/tests/src/ConfigurationEditor.php b/tests/src/ConfigurationEditor.php index da1221107a..ee2552b098 100644 --- a/tests/src/ConfigurationEditor.php +++ b/tests/src/ConfigurationEditor.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/ContentDataCreator.php b/tests/src/ContentDataCreator.php index c0ac4cc7b6..754ab71cdb 100644 --- a/tests/src/ContentDataCreator.php +++ b/tests/src/ContentDataCreator.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/ConfigurationContext.php b/tests/src/Context/ConfigurationContext.php index 5f6e5143a1..5a390128b8 100644 --- a/tests/src/Context/ConfigurationContext.php +++ b/tests/src/Context/ConfigurationContext.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/ContentContext.php b/tests/src/Context/ContentContext.php index 071596f73d..d0a3a7f732 100644 --- a/tests/src/Context/ContentContext.php +++ b/tests/src/Context/ContentContext.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/FileContext.php b/tests/src/Context/FileContext.php index 34e8525cfe..fb340da512 100644 --- a/tests/src/Context/FileContext.php +++ b/tests/src/Context/FileContext.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/TutorialContentTypeContext.php b/tests/src/Context/TutorialContentTypeContext.php index f4ca29f347..a5d3c5b5ea 100644 --- a/tests/src/Context/TutorialContentTypeContext.php +++ b/tests/src/Context/TutorialContentTypeContext.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. + * * @license For full copyright and license information view LICENSE file distributed with this source code. */ From 7e99f3f31c3f1261270043b479008c413eaf501f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 21 May 2025 17:04:19 +0200 Subject: [PATCH 03/26] Removed output.txt --- output.txt | 895 ----------------------------------------------------- 1 file changed, 895 deletions(-) delete mode 100644 output.txt diff --git a/output.txt b/output.txt deleted file mode 100644 index 77682737eb..0000000000 --- a/output.txt +++ /dev/null @@ -1,895 +0,0 @@ - -35 files with changes -===================== - -1) code_samples/page/page_listener/src/Block/Listener/MyBlockListener.php:8 - - ---------- begin diff ---------- -@@ @@ - - class MyBlockListener implements EventSubscriberInterface - { -- public static function getSubscribedEvents() -+ public static function getSubscribedEvents(): array - { - return [ - BlockRenderEvents::getBlockPreRenderEventName('event') => 'onBlockPreRender', - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -2) code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php:32 - - ---------- begin diff ---------- -@@ @@ - $this->searchService = $searchService; - } - -- public static function getSubscribedEvents() -+ public static function getSubscribedEvents(): array - { - return [ - BlockRenderEvents::getBlockPreRenderEventName('random') => 'onBlockPreRender', - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -3) code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php:55 - - ---------- begin diff ---------- -@@ @@ - ResourceOwnerInterface $resourceOwner, - UserProviderInterface $userProvider - ): ?UserInterface { -- return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); -+ return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); - } - - /** -@@ @@ - - $this->userService->createUser($userCreateStruct, $parentGroups); - -- return $userProvider->loadUserByUsername($this->getUsername($resourceOwner)); -+ return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); - } - - private function getOAuth2UserContentType(Repository $repository): ?ContentType - ----------- end diff ----------- - -Applied rules: - * RenameMethodRector - - -4) code_samples/api/public_php_api/src/Command/UpdateContentCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:update_content' --)] -+#[AsCommand(name: 'doc:update_content', description: 'Update provided content item with a new name')] - class UpdateContentCommand extends Command - { - private ContentService $contentService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Update provided content item with a new name') - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), - new InputArgument('newName', InputArgument::REQUIRED, 'New name for the updated content item'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -5) code_samples/api/public_php_api/src/Command/ViewContentCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:view_content' --)] -+#[AsCommand(name: 'doc:view_content', description: 'Output Field values on provided content item.')] - class ViewContentCommand extends Command - { - private ContentService $contentService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Output Field values on provided content item.') - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Location ID'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -6) code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php:15 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:view_metadata' --)] -+#[AsCommand(name: 'doc:view_metadata', description: 'Output various metadata about a content item.')] - class ViewContentMetaDataCommand extends Command - { - private ContentService $contentService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Output various metadata about a content item.') - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'An existing content ID'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -7) code_samples/api/public_php_api/src/Command/WorkflowCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:workflow' --)] -+#[AsCommand(name: 'doc:workflow', description: 'Starts content in the selected workflow and makes the provided transition.')] - class WorkflowCommand extends Command - { - private WorkflowServiceInterface $workflowService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Starts content in the selected workflow and makes the provided transition.') - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), - new InputArgument('workflowName', InputArgument::REQUIRED, 'Workflow identifier'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -8) code_samples/back_office/dashboard/src/Command/DashboardCommand.php:14 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:dashboard' --)] -+#[AsCommand(name: 'doc:dashboard', description: 'Set a custom dashboard to user group.')] - class DashboardCommand extends Command - { - private DashboardServiceInterface $dashboardService; -@@ @@ - - public function configure(): void - { -- $this->setDescription('Set a custom dashboard to user group.') -+ $this - ->addArgument('dashboard', InputArgument::REQUIRED, 'Location ID of the dashboard model') - ->addArgument('group', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'User Group Content ID(s)'); - } - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -9) code_samples/back_office/images/src/SvgExtension.php:26 - - ---------- begin diff ---------- -@@ @@ - public function getFunctions(): array - { - return [ -- new TwigFunction('ibexa_svg_link', [ -- $this, -- 'generateLink', -- ]), -+ new TwigFunction('ibexa_svg_link', $this->generateLink(...)), - ]; - } - ----------- end diff ----------- - -Applied rules: - * MagicClosureTwigExtensionToNativeMethodsRector - - -10) code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php:39 - - ---------- begin diff ---------- -@@ @@ - return $this->render('@ibexadesign/all_content_list.html.twig', [ - 'totalCount' => $paginator->getNbResults(), - 'articles' => $paginator, -- 'form_edit' => $editForm->createView(), -+ 'form_edit' => $editForm, - ]); - } - } - ----------- end diff ----------- - -Applied rules: - * SimplifyFormRenderingRector - - -11) code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php:8 - - ---------- begin diff ---------- -@@ @@ - - class MyMenuSubscriber implements EventSubscriberInterface - { -- public static function getSubscribedEvents() -+ public static function getSubscribedEvents(): array - { - return [ - ConfigureMenuEvent::MAIN_MENU => ['onMainMenuConfigure', 0], - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -12) code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php:16 - - ---------- begin diff ---------- -@@ @@ - $this->notificationService = $notificationService; - } - -- public static function getSubscribedEvents() -+ public static function getSubscribedEvents(): array - { - return [PublishVersionEvent::class => 'onPublishVersion']; - } - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -13) code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php:13 - - ---------- begin diff ---------- -@@ @@ - /** - * @return string|null - */ -- public function getParent() -+ public function getParent(): ?string - { - return CheckboxType::class; - } -@@ @@ - /** - * @return string - */ -- public function getBlockPrefix() -+ public function getBlockPrefix(): string - { - return 'checkbox_with_richtext_description'; - } - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -14) code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php:10 - - ---------- begin diff ---------- -@@ @@ - /** - * @return string|null - */ -- public function getParent() -+ public function getParent(): ?string - { - return RichTextType::class; - } -@@ @@ - /** - * @return string - */ -- public function getBlockPrefix() -+ public function getBlockPrefix(): string - { - return 'field_configuration_attribute_richtext'; - } - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -15) code_samples/front/render_content_in_php/src/Command/ViewCommand.php:10 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputOption; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'app:view' --)] -+#[AsCommand(name: 'app:view', description: 'Render the view of a content item')] - class ViewCommand extends Command - { - private ContentViewBuilder $contentViewBuilder; -@@ @@ - - protected function configure(): void - { -- $this->setDescription('Render the view of a content item') -+ $this - ->addOption('content-id', 'c', InputOption::VALUE_OPTIONAL, 'Content ID') - ->addOption('location-id', 'l', InputOption::VALUE_OPTIONAL, 'Location ID') - ->addOption('view-type', 't', InputOption::VALUE_OPTIONAL, 'View Type', 'line'); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -16) code_samples/front/shop/checkout/src/Controller/Checkout/OnePageCheckout.php:44 - - ---------- begin diff ---------- -@@ @@ - return $this->render( - '@storefront/checkout/checkout.html.twig', - [ -- 'form' => $form->createView(), -+ 'form' => $form, - 'checkout' => $checkout, - ] - ); - ----------- end diff ----------- - -Applied rules: - * SimplifyFormRenderingRector - - -17) code_samples/front/shop/checkout/src/Controller/Checkout/Step/SelectSeatStepController.php:30 - - ---------- begin diff ---------- -@@ @@ - 'layout' => $this->getSeatsLayout(), - 'current_step' => $step, - 'checkout' => $checkout, -- 'form' => $form->createView(), -+ 'form' => $form, - ] - ); - } - ----------- end diff ----------- - -Applied rules: - * SimplifyFormRenderingRector - - -18) code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php:10 - - ---------- begin diff ---------- -@@ @@ - - class BreadcrumbsMenuSubscriber implements EventSubscriberInterface - { -- public static function getSubscribedEvents() -+ public static function getSubscribedEvents(): array - { - return [ - BreadcrumbsMenuBuilder::PRODUCT_MENU => ['onBreadcrumbsMenuConfigure', 0], - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -19) code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php:7 - - ---------- begin diff ---------- -@@ @@ - - class MyStringAttributeType extends AbstractType - { -- public function getParent() -+ public function getParent(): ?string - { - return TextType::class; - } - -- public function getBlockPrefix() -+ public function getBlockPrefix(): string - { - return 'my_string_attribute'; - } - ----------- end diff ----------- - -Applied rules: - * AddReturnTypeDeclarationRector - - -20) code_samples/api/public_php_api/src/Command/AddLanguageCommand.php:10 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:add_language' --)] -+#[AsCommand(name: 'doc:add_language', description: 'Lists available languages and add Polish.')] - class AddLanguageCommand extends Command - { - private LanguageService $languageService; -@@ @@ - - protected function configure(): void - { -- $this->setDescription('Lists available languages and add Polish.'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -21) code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php:12 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:add_location' --)] -+#[AsCommand(name: 'doc:add_location', description: 'Add a Location to content item and hides it.')] - class AddLocationToContentCommand extends Command - { - private ContentService $contentService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Add a Location to content item and hides it.') - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'Parent Location ID'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -22) code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php:10 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:browse_locations' --)] -+#[AsCommand(name: 'doc:browse_locations', description: 'Lists all descendants of the Location')] - class BrowseLocationsCommand extends Command - { - private LocationService $locationService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Lists all descendants of the Location') - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location ID to browse from'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -23) code_samples/api/public_php_api/src/Command/CalendarCommand.php:12 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:calendar' --)] -+#[AsCommand(name: 'doc:calendar', description: 'Lists Calendar event in the provided time range and reschedules them.')] - class CalendarCommand extends Command - { - private PermissionResolver $permissionResolver; -@@ @@ - - public function configure(): void - { -- $this->setDescription('Lists Calendar event in the provided time range and reschedules them.'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -24) code_samples/api/public_php_api/src/Command/FilterCommand.php:13 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:filter' --)] -+#[AsCommand(name: 'doc:filter', description: 'Returns children of the provided Location, sorted by name in descending order.')] - class FilterCommand extends Command - { - private ContentService $contentService; -@@ @@ - - public function configure(): void - { -- $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); - $this->setDefinition([ - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -25) code_samples/api/public_php_api/src/Command/FilterLocationCommand.php:13 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:filter_location' --)] -+#[AsCommand(name: 'doc:filter_location', description: 'Returns children of the provided Location, sorted by name in descending order.')] - class FilterLocationCommand extends Command - { - private LocationService $locationService; -@@ @@ - - public function configure(): void - { -- $this->setDescription('Returns children of the provided Location, sorted by name in descending order.'); - $this->setDefinition([ - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -26) code_samples/api/public_php_api/src/Command/FindComplexCommand.php:13 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:find_complex' --)] -+#[AsCommand(name: 'doc:find_complex', description: 'Lists content belonging to the provided content type.')] - class FindComplexCommand extends Command - { - private SearchService $searchService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Lists content belonging to the provided content type.') - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, ''), - new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -27) code_samples/api/public_php_api/src/Command/FindContentCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:find_content' --)] -+#[AsCommand(name: 'doc:find_content', description: 'Lists content belonging to the provided content type.')] - class FindContentCommand extends Command - { - private SearchService $searchService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Lists content belonging to the provided content type.') - ->setDefinition([ - new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -28) code_samples/api/public_php_api/src/Command/FindInTrashCommand.php:10 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:find_in_trash' --)] -+#[AsCommand(name: 'doc:find_in_trash', description: 'Lists content in Trash belonging to the provided content type.')] - class FindInTrashCommand extends Command - { - private TrashService $trashService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Lists content in Trash belonging to the provided content type.') - ->setDefinition([ - new InputArgument('contentTypeId', InputArgument::REQUIRED, 'Content type ID'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -29) code_samples/api/public_php_api/src/Command/FindUrlCommand.php:13 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:find_url' --)] -+#[AsCommand(name: 'doc:find_url', description: 'Finds all valid URLs in the provided Section.')] - class FindUrlCommand extends Command - { - private URLService $urlService; -@@ @@ - - protected function configure(): void - { -- $this -- ->setDescription('Finds all valid URLs in the provided Section.'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -30) code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php:12 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:find_with_aggregation' --)] -+#[AsCommand(name: 'doc:find_with_aggregation', description: 'Counts content per content type and the value of Selection Field.')] - class FindWithAggregationCommand extends Command - { - private SearchService $searchService; -@@ @@ - - protected function configure(): void - { -- $this -- ->setDescription('Counts content per content type and the value of Selection Field.'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -31) code_samples/api/public_php_api/src/Command/HideLocationCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:hide' --)] -+#[AsCommand(name: 'doc:hide', description: 'Hides and reveals again selected Location.')] - class HideLocationCommand extends Command - { - private LocationService $locationService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Hides and reveals again selected Location.') - ->setDefinition([ - new InputArgument('location_id', InputArgument::REQUIRED, 'Location ID'), - ]); - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -32) code_samples/api/public_php_api/src/Command/MoveContentCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:move_content' --)] -+#[AsCommand(name: 'doc:move_content', description: 'Moves the selected Location with its subtree.')] - class MoveContentCommand extends Command - { - private LocationService $locationService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Moves the selected Location with its subtree.') - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location to copy'), - new InputArgument('targetLocationId', InputArgument::REQUIRED, 'Target to copy or move to'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -33) code_samples/api/public_php_api/src/Command/ObjectStateCommand.php:12 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:object_state' --)] -+#[AsCommand(name: 'doc:object_state', description: 'Creates OS group with provided States and assigned the Lock OS to provided content item')] - class ObjectStateCommand extends Command - { - private ContentService $contentService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Creates OS group with provided States and assigned the Lock OS to provided content item') - ->setDefinition([ - new InputArgument('objectStateGroupIdentifier', InputArgument::REQUIRED, 'Identifier of new OG group to create'), - new InputArgument('objectStateIdentifier', InputArgument::REQUIRED, 'Identifier(s) of a new Object State'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -34) code_samples/api/public_php_api/src/Command/SectionCommand.php:15 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:section' --)] -+#[AsCommand(name: 'doc:section', description: 'Creates new section and adds selected content item to it.')] - class SectionCommand extends Command - { - private SectionService $sectionService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Creates new section and adds selected content item to it.') - ->setDefinition([ - new InputArgument('sectionName', InputArgument::REQUIRED, 'Name of the new Section'), - new InputArgument('sectionIdentifier', InputArgument::REQUIRED, 'Identifier of the new Section'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - -35) code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php:11 - - ---------- begin diff ---------- -@@ @@ - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Output\OutputInterface; - --#[AsCommand( -- name: 'doc:set_main_location' --)] -+#[AsCommand(name: 'doc:set_main_location', description: 'Set a Location as content item\'s main')] - class SetMainLocationCommand extends Command - { - private ContentService $contentService; -@@ @@ - protected function configure(): void - { - $this -- ->setDescription('Set a Location as content item\'s main') - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'The Content ID'), - new InputArgument('locationId', InputArgument::REQUIRED, 'One of the Locations of the Content'), - ----------- end diff ----------- - -Applied rules: - * CommandConfigureToAttributeRector - - - [OK] 35 files have been changed by Rector - From a093214c3235a55a35b5a5b09fe264cc986a8950 Mon Sep 17 00:00:00 2001 From: mnocon Date: Wed, 21 May 2025 15:14:15 +0000 Subject: [PATCH 04/26] PHP & JS CS Fixes --- .../src/Attribute/Percent/Storage/PercentStorageDefinition.php | 1 - tests/source_files/step4/RandomBlockListener.php | 1 - tests/src/ConfigurationEditor.php | 1 - tests/src/ContentDataCreator.php | 1 - tests/src/Context/ConfigurationContext.php | 1 - tests/src/Context/ContentContext.php | 1 - tests/src/Context/FileContext.php | 1 - tests/src/Context/TutorialContentTypeContext.php | 1 - 8 files changed, 8 deletions(-) diff --git a/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php b/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php index 7fc8fe59e0..415c784344 100644 --- a/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php +++ b/code_samples/catalog/custom_attribute_type/src/Attribute/Percent/Storage/PercentStorageDefinition.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa AS. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ declare(strict_types=1); diff --git a/tests/source_files/step4/RandomBlockListener.php b/tests/source_files/step4/RandomBlockListener.php index ecee0740b1..5151296c84 100644 --- a/tests/source_files/step4/RandomBlockListener.php +++ b/tests/source_files/step4/RandomBlockListener.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ declare(strict_types=1); diff --git a/tests/src/ConfigurationEditor.php b/tests/src/ConfigurationEditor.php index ee2552b098..da1221107a 100644 --- a/tests/src/ConfigurationEditor.php +++ b/tests/src/ConfigurationEditor.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/ContentDataCreator.php b/tests/src/ContentDataCreator.php index 754ab71cdb..c0ac4cc7b6 100644 --- a/tests/src/ContentDataCreator.php +++ b/tests/src/ContentDataCreator.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/ConfigurationContext.php b/tests/src/Context/ConfigurationContext.php index 5a390128b8..5f6e5143a1 100644 --- a/tests/src/Context/ConfigurationContext.php +++ b/tests/src/Context/ConfigurationContext.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/ContentContext.php b/tests/src/Context/ContentContext.php index d0a3a7f732..071596f73d 100644 --- a/tests/src/Context/ContentContext.php +++ b/tests/src/Context/ContentContext.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/FileContext.php b/tests/src/Context/FileContext.php index fb340da512..34e8525cfe 100644 --- a/tests/src/Context/FileContext.php +++ b/tests/src/Context/FileContext.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ diff --git a/tests/src/Context/TutorialContentTypeContext.php b/tests/src/Context/TutorialContentTypeContext.php index a5d3c5b5ea..f4ca29f347 100644 --- a/tests/src/Context/TutorialContentTypeContext.php +++ b/tests/src/Context/TutorialContentTypeContext.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (C) Ibexa. All rights reserved. - * * @license For full copyright and license information view LICENSE file distributed with this source code. */ From db33ed109e2ac907cf1cde74b4a54fe62e3f942e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 22 May 2025 09:22:17 +0200 Subject: [PATCH 05/26] Removed empty configure methods --- .../api/public_php_api/src/Command/AddLanguageCommand.php | 4 ---- .../api/public_php_api/src/Command/FindUrlCommand.php | 4 ---- .../public_php_api/src/Command/FindWithAggregationCommand.php | 4 ---- .../api/public_php_api/src/Command/SegmentCommand.php | 4 ---- 4 files changed, 16 deletions(-) diff --git a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php index 8902f0cbe6..ce2826cc84 100644 --- a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php @@ -28,10 +28,6 @@ public function __construct(LanguageService $languageService, UserService $userS parent::__construct(); } - protected function configure(): void - { - } - protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); diff --git a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php index 403e3cd1b0..952022c96c 100644 --- a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php @@ -31,10 +31,6 @@ public function __construct(URLService $URLService, UserService $userService, Pe parent::__construct(); } - protected function configure(): void - { - } - protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); diff --git a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php index 60a2dacc98..9f6c672b99 100644 --- a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php @@ -24,10 +24,6 @@ public function __construct(SearchService $searchService) parent::__construct(); } - protected function configure(): void - { - } - protected function execute(InputInterface $input, OutputInterface $output): int { $query = new LocationQuery(); diff --git a/code_samples/api/public_php_api/src/Command/SegmentCommand.php b/code_samples/api/public_php_api/src/Command/SegmentCommand.php index 84d29650fb..7fbbf8a4f7 100644 --- a/code_samples/api/public_php_api/src/Command/SegmentCommand.php +++ b/code_samples/api/public_php_api/src/Command/SegmentCommand.php @@ -32,10 +32,6 @@ public function __construct(SegmentationService $segmentationService, UserServic parent::__construct(); } - protected function configure(): void - { - } - protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); From 87333e9072b1b2514bdb2c52f4b83c4ca9b5c919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 22 May 2025 09:22:53 +0200 Subject: [PATCH 06/26] [Composer] Bumped code-style version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b24e245968..ed8a71e403 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require-dev": { "ibexa/automated-translation": "5.0.x-dev", - "ibexa/code-style": "^1.0", + "ibexa/code-style": "~2.0.0", "friendsofphp/php-cs-fixer": "^3.30", "phpstan/phpstan": "^2.0", "phpstan/phpstan-symfony": "^2.0", From bfdfa2cbdf7b5a8ef72c48426bdcaf004c4c64d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 22 May 2025 10:50:20 +0200 Subject: [PATCH 07/26] Rebuild From c851ca970f9462a82b8a503dc371e43e06e0b8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 22 May 2025 11:12:05 +0200 Subject: [PATCH 08/26] Fixed workflow --- .github/workflows/code_samples.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code_samples.yaml b/.github/workflows/code_samples.yaml index 6986a9bbea..d39211cceb 100644 --- a/.github/workflows/code_samples.yaml +++ b/.github/workflows/code_samples.yaml @@ -148,9 +148,9 @@ jobs: name: Run rector runs-on: "ubuntu-22.04" strategy: - matrix: - php: - - '8.3' + matrix: + php: + - '8.3' steps: - uses: actions/checkout@v4 From 4cb16695587df161bab6e7fee455bacaa8c9cf91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 22 May 2025 11:21:36 +0200 Subject: [PATCH 09/26] Run rector withing the same job --- .github/workflows/code_samples.yaml | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/.github/workflows/code_samples.yaml b/.github/workflows/code_samples.yaml index d39211cceb..138326cc59 100644 --- a/.github/workflows/code_samples.yaml +++ b/.github/workflows/code_samples.yaml @@ -38,6 +38,9 @@ jobs: - name: Run PHPStan analysis run: composer phpstan + - name: Run rector + run: vendor/bin/rector process --dry-run --ansi + code-samples-inclusion-check: name: Check code samples inclusion runs-on: ubuntu-latest @@ -143,28 +146,3 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body-path: code_samples_usage.diff.md edit-mode: replace - - rector: - name: Run rector - runs-on: "ubuntu-22.04" - strategy: - matrix: - php: - - '8.3' - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP Action - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - extensions: 'pdo_sqlite, gd' - tools: cs2pr - - - uses: ramsey/composer-install@v3 - with: - dependency-versions: highest - - - name: Run rector - run: vendor/bin/rector process --dry-run --ansi From 11525d1b314b64c59ee287e9b298a2ce5b84c41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 22 May 2025 11:22:20 +0200 Subject: [PATCH 10/26] Adjusted PHPStan --- .../oauth_google/src/OAuth/GoogleResourceOwnerMapper.php | 4 ++-- phpstan-baseline.neon | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php index b34bb9e854..0b05b8d101 100644 --- a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php +++ b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php @@ -54,7 +54,7 @@ public function __construct( protected function loadUser( ResourceOwnerInterface $resourceOwner, UserProviderInterface $userProvider - ): ?UserInterface { + ): UserInterface { return $userProvider->loadUserByIdentifier($this->getUsername($resourceOwner)); } @@ -64,7 +64,7 @@ protected function loadUser( protected function createUser( ResourceOwnerInterface $resourceOwner, UserProviderInterface $userProvider - ): ?UserInterface { + ): UserInterface { $userCreateStruct = $this->oauthUserService->newOAuth2UserCreateStruct( $this->getUsername($resourceOwner), $resourceOwner->getEmail(), diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c19c052141..ad39090a7d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -738,12 +738,6 @@ parameters: count: 1 path: code_samples/tutorials/page_tutorial_starting_point/src/QueryType/MenuQueryType.php - - - message: '#^Call to an undefined method Symfony\\Component\\Security\\Core\\User\\UserProviderInterface\\:\:loadUserByUsername\(\)\.$#' - identifier: method.notFound - count: 2 - path: code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php - - message: '#^Parameter \#2 \$email of method Ibexa\\Contracts\\OAuth2Client\\Repository\\OAuth2UserService\:\:newOAuth2UserCreateStruct\(\) expects string, string\|null given\.$#' identifier: argument.type From 946d09f023c7b044b4bb7251b9f23bed86d0ef5a Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:45:11 +0200 Subject: [PATCH 11/26] Format AsCommand attributes (#2786) --- .../api/public_php_api/src/Command/AddLanguageCommand.php | 5 ++++- .../src/Command/AddLocationToContentCommand.php | 5 ++++- .../public_php_api/src/Command/BrowseLocationsCommand.php | 5 ++++- .../api/public_php_api/src/Command/CalendarCommand.php | 5 ++++- .../api/public_php_api/src/Command/FilterCommand.php | 5 ++++- .../api/public_php_api/src/Command/FilterLocationCommand.php | 5 ++++- .../api/public_php_api/src/Command/FindComplexCommand.php | 5 ++++- .../api/public_php_api/src/Command/FindContentCommand.php | 5 ++++- .../api/public_php_api/src/Command/FindInTrashCommand.php | 5 ++++- .../api/public_php_api/src/Command/FindUrlCommand.php | 5 ++++- .../src/Command/FindWithAggregationCommand.php | 5 ++++- .../api/public_php_api/src/Command/HideLocationCommand.php | 5 ++++- .../api/public_php_api/src/Command/MoveContentCommand.php | 5 ++++- .../api/public_php_api/src/Command/ObjectStateCommand.php | 5 ++++- .../api/public_php_api/src/Command/SectionCommand.php | 5 ++++- .../public_php_api/src/Command/SetMainLocationCommand.php | 5 ++++- .../api/public_php_api/src/Command/UpdateContentCommand.php | 5 ++++- .../api/public_php_api/src/Command/ViewContentCommand.php | 5 ++++- .../src/Command/ViewContentMetaDataCommand.php | 5 ++++- .../api/public_php_api/src/Command/WorkflowCommand.php | 5 ++++- .../back_office/dashboard/src/Command/DashboardCommand.php | 5 ++++- .../front/render_content_in_php/src/Command/ViewCommand.php | 5 ++++- 22 files changed, 88 insertions(+), 22 deletions(-) diff --git a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php index ce2826cc84..d734fa9841 100644 --- a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php @@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:add_language', description: 'Lists available languages and add Polish.')] +#[AsCommand( + name: 'doc:add_language', + description: 'Lists available languages and add Polish.' +)] class AddLanguageCommand extends Command { private LanguageService $languageService; diff --git a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php index 16277a58a0..79cf794d03 100644 --- a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php @@ -12,7 +12,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:add_location', description: 'Add a Location to content item and hides it.')] +#[AsCommand( + name: 'doc:add_location', + description: 'Add a Location to content item and hides it.' +)] class AddLocationToContentCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php index d7da5b02ac..b6d7641184 100644 --- a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php +++ b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php @@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:browse_locations', description: 'Lists all descendants of the Location')] +#[AsCommand( + name: 'doc:browse_locations', + description: 'Lists all descendants of the Location' +)] class BrowseLocationsCommand extends Command { private LocationService $locationService; diff --git a/code_samples/api/public_php_api/src/Command/CalendarCommand.php b/code_samples/api/public_php_api/src/Command/CalendarCommand.php index ae35627449..7bcaefea8d 100644 --- a/code_samples/api/public_php_api/src/Command/CalendarCommand.php +++ b/code_samples/api/public_php_api/src/Command/CalendarCommand.php @@ -12,7 +12,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:calendar', description: 'Lists Calendar event in the provided time range and reschedules them.')] +#[AsCommand( + name: 'doc:calendar', + description: 'Lists Calendar event in the provided time range and reschedules them.' +)] class CalendarCommand extends Command { private PermissionResolver $permissionResolver; diff --git a/code_samples/api/public_php_api/src/Command/FilterCommand.php b/code_samples/api/public_php_api/src/Command/FilterCommand.php index 9fea5c5210..a3abce7933 100644 --- a/code_samples/api/public_php_api/src/Command/FilterCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterCommand.php @@ -13,7 +13,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:filter', description: 'Returns children of the provided Location, sorted by name in descending order.')] +#[AsCommand( + name: 'doc:filter', + description: 'Returns children of the provided Location, sorted by name in descending order.' +)] class FilterCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php index eca95826ad..3143fdcaad 100644 --- a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php @@ -13,7 +13,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:filter_location', description: 'Returns children of the provided Location, sorted by name in descending order.')] +#[AsCommand( + name: 'doc:filter_location', + description: 'Returns children of the provided Location, sorted by name in descending order.' +)] class FilterLocationCommand extends Command { private LocationService $locationService; diff --git a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php index 9416b28f35..748c8d50c8 100644 --- a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php @@ -13,7 +13,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:find_complex', description: 'Lists content belonging to the provided content type.')] +#[AsCommand( + name: 'doc:find_complex', + description: 'Lists content belonging to the provided content type.' +)] class FindComplexCommand extends Command { private SearchService $searchService; diff --git a/code_samples/api/public_php_api/src/Command/FindContentCommand.php b/code_samples/api/public_php_api/src/Command/FindContentCommand.php index 41d988bafa..972bd1b295 100644 --- a/code_samples/api/public_php_api/src/Command/FindContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindContentCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:find_content', description: 'Lists content belonging to the provided content type.')] +#[AsCommand( + name: 'doc:find_content', + description: 'Lists content belonging to the provided content type.' +)] class FindContentCommand extends Command { private SearchService $searchService; diff --git a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php index aaf6c01d1b..883b11e65d 100644 --- a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php @@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:find_in_trash', description: 'Lists content in Trash belonging to the provided content type.')] +#[AsCommand( + name: 'doc:find_in_trash', + description: 'Lists content in Trash belonging to the provided content type.' +)] class FindInTrashCommand extends Command { private TrashService $trashService; diff --git a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php index 952022c96c..b896f3acbe 100644 --- a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php @@ -13,7 +13,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:find_url', description: 'Finds all valid URLs in the provided Section.')] +#[AsCommand( + name: 'doc:find_url', + description: 'Finds all valid URLs in the provided Section.' +)] class FindUrlCommand extends Command { private URLService $urlService; diff --git a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php index 9f6c672b99..f972de32a1 100644 --- a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php @@ -12,7 +12,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:find_with_aggregation', description: 'Counts content per content type and the value of Selection Field.')] +#[AsCommand( + name: 'doc:find_with_aggregation', + description: 'Counts content per content type and the value of Selection Field.' +)] class FindWithAggregationCommand extends Command { private SearchService $searchService; diff --git a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php index 4dce2720e1..06cfae6ec6 100644 --- a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:hide', description: 'Hides and reveals again selected Location.')] +#[AsCommand( + name: 'doc:hide', + description: 'Hides and reveals again selected Location.' +)] class HideLocationCommand extends Command { private LocationService $locationService; diff --git a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php index f1443d3a5a..bdb5563aa2 100644 --- a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:move_content', description: 'Moves the selected Location with its subtree.')] +#[AsCommand( + name: 'doc:move_content', + description: 'Moves the selected Location with its subtree.' +)] class MoveContentCommand extends Command { private LocationService $locationService; diff --git a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php index 711f5cec02..2b264dda53 100644 --- a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php +++ b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php @@ -12,7 +12,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:object_state', description: 'Creates OS group with provided States and assigned the Lock OS to provided content item')] +#[AsCommand( + name: 'doc:object_state', + description: 'Creates OS group with provided States and assigned the Lock OS to provided content item' +)] class ObjectStateCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/SectionCommand.php b/code_samples/api/public_php_api/src/Command/SectionCommand.php index fea19f5b04..9845064b76 100644 --- a/code_samples/api/public_php_api/src/Command/SectionCommand.php +++ b/code_samples/api/public_php_api/src/Command/SectionCommand.php @@ -15,7 +15,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:section', description: 'Creates new section and adds selected content item to it.')] +#[AsCommand( + name: 'doc:section', + description: 'Creates new section and adds selected content item to it.' +)] class SectionCommand extends Command { private SectionService $sectionService; diff --git a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php index dd665062c7..af022123e3 100644 --- a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:set_main_location', description: 'Set a Location as content item\'s main')] +#[AsCommand( + name: 'doc:set_main_location', + description: 'Set a Location as content item\'s main' +)] class SetMainLocationCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php index f807bdf759..cfc3f1acc3 100644 --- a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:update_content', description: 'Update provided content item with a new name')] +#[AsCommand( + name: 'doc:update_content', + description: 'Update provided content item with a new name' +)] class UpdateContentCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php index bdfb99ed62..8e3673316b 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:view_content', description: 'Output Field values on provided content item.')] +#[AsCommand( + name: 'doc:view_content', + description: 'Output Field values on provided content item.' +)] class ViewContentCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php index 1ac31f8dcd..09d4cb1295 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php @@ -15,7 +15,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:view_metadata', description: 'Output various metadata about a content item.')] +#[AsCommand( + name: 'doc:view_metadata', + description: 'Output various metadata about a content item.' +)] class ViewContentMetaDataCommand extends Command { private ContentService $contentService; diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index 362ca64322..1a1c021fb7 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -11,7 +11,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:workflow', description: 'Starts content in the selected workflow and makes the provided transition.')] +#[AsCommand( + name: 'doc:workflow', + description: 'Starts content in the selected workflow and makes the provided transition.' +)] class WorkflowCommand extends Command { private WorkflowServiceInterface $workflowService; diff --git a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php index 57a57ed107..e6cc95ba7b 100644 --- a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php +++ b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php @@ -14,7 +14,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'doc:dashboard', description: 'Set a custom dashboard to user group.')] +#[AsCommand( + name: 'doc:dashboard', + description: 'Set a custom dashboard to user group.' +)] class DashboardCommand extends Command { private DashboardServiceInterface $dashboardService; diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index d7b2d79f8f..4c1bf39616 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand(name: 'app:view', description: 'Render the view of a content item')] +#[AsCommand( + name: 'app:view', + description: 'Render the view of a content item' +)] class ViewCommand extends Command { private ContentViewBuilder $contentViewBuilder; From 560d078b6cff7f6e93916ea4a1902eba4dae56f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 10 Jul 2025 12:24:21 +0200 Subject: [PATCH 12/26] Rector PHP 8.3 changes --- .../src/AI/Action/TranscribeAudioAction.php | 5 +-- .../ActionType/TranscribeAudioActionType.php | 10 ++--- .../ai_actions/src/AI/DataType/Audio.php | 6 +-- .../Handler/LLaVaTextToTextActionHandler.php | 14 ++----- .../WhisperAudioToTextActionHandler.php | 8 ++-- .../AI/REST/Input/Parser/TranscribeAudio.php | 4 +- .../Output/ValueObjectVisitor/AudioText.php | 2 +- .../AI/REST/Value/TranscribeAudioAction.php | 14 ++----- .../ActionConfigurationCreateCommand.php | 26 +++--------- .../src/Command/AddMissingAltTextCommand.php | 33 ++++----------- .../api/commerce/src/Command/CartCommand.php | 41 ++++--------------- .../api/commerce/src/Command/OrderCommand.php | 16 ++------ .../commerce/src/Command/PaymentCommand.php | 26 +++--------- .../src/Command/PaymentMethodCommand.php | 16 ++------ .../commerce/src/Command/ShipmentCommand.php | 26 +++--------- .../src/Command/ShippingMethodCommand.php | 21 ++-------- .../Controller/CustomCheckoutController.php | 8 +--- .../src/Command/MigrationCommand.php | 6 +-- .../src/Command/AttributeCommand.php | 36 ++++------------ .../src/Command/CatalogCommand.php | 21 ++-------- .../src/Command/CurrencyCommand.php | 12 +----- .../src/Command/ProductAssetCommand.php | 21 ++-------- .../src/Command/ProductCommand.php | 31 +++----------- .../src/Command/ProductPriceCommand.php | 31 +++----------- .../src/Command/ProductTypeCommand.php | 12 +----- .../src/Command/ProductVariantCommand.php | 21 ++-------- .../src/Command/VatCommand.php | 21 ++-------- .../src/Command/AddLanguageCommand.php | 12 +----- .../Command/AddLocationToContentCommand.php | 15 +------ .../src/Command/BookmarkCommand.php | 9 +--- .../src/Command/BrowseLocationsCommand.php | 6 +-- .../src/Command/CalendarCommand.php | 12 +----- .../src/Command/CreateContentCommand.php | 18 +------- .../src/Command/CreateContentTypeCommand.php | 14 +------ .../src/Command/CreateImageCommand.php | 20 +-------- .../src/Command/DeleteContentCommand.php | 12 +----- .../src/Command/FilterCommand.php | 6 +-- .../src/Command/FilterLocationCommand.php | 6 +-- .../src/Command/FindComplexCommand.php | 9 +--- .../src/Command/FindContentCommand.php | 6 +-- .../src/Command/FindInTrashCommand.php | 6 +-- .../src/Command/FindUrlCommand.php | 12 +----- .../Command/FindWithAggregationCommand.php | 6 +-- .../src/Command/FormSubmissionCommand.php | 15 +------ .../src/Command/HideLocationCommand.php | 12 +----- .../src/Command/MoveContentCommand.php | 12 +----- .../src/Command/ObjectStateCommand.php | 17 +------- .../src/Command/SectionCommand.php | 18 +------- .../src/Command/SegmentCommand.php | 12 +----- .../src/Command/SetMainLocationCommand.php | 12 +----- .../src/Command/TaxonomyCommand.php | 16 ++------ .../src/Command/TranslateContentCommand.php | 12 +----- .../src/Command/TrashContentCommand.php | 15 +------ .../src/Command/UpdateContentCommand.php | 12 +----- .../src/Command/ViewContentCommand.php | 12 +----- .../Command/ViewContentMetaDataCommand.php | 21 +--------- .../src/Command/WorkflowCommand.php | 12 +----- .../src/Controller/CustomController.php | 5 +-- .../src/Controller/CustomFilterController.php | 5 +-- .../src/Controller/PaginationController.php | 5 +-- .../src/EventSubscriber/MyEventSubcriber.php | 2 +- .../api/rest_api/create_image.json.php | 4 +- .../Output/ValueObjectVisitorDispatcher.php | 7 +--- .../Rest/ValueObjectVisitor/RestLocation.php | 6 +-- .../api/rest_api/src/Rest/Values/Greeting.php | 8 +--- .../Calendar/Holidays/EventSourceFactory.php | 5 +-- .../src/Calendar/Holidays/EventType.php | 4 +- .../Dashboard/Everyone/EveryoneArticleTab.php | 11 +---- .../src/Command/DashboardCommand.php | 13 +++--- .../back_office/images/src/SvgController.php | 18 ++------ .../back_office/images/src/SvgExtension.php | 6 +-- .../Limitation/CustomLimitationType.php | 3 +- .../Controller/AllContentListController.php | 8 +--- .../ContentPublishEventListener.php | 7 +--- .../src/Notification/MyRenderer.php | 8 +--- .../subscriber/RichTextBlockSubscriber.php | 6 +-- .../MySuggestionEventSubscriber.php | 14 ++----- .../Model/Suggestion/ProductSuggestion.php | 2 +- .../SectionNameSortingDefinitionProvider.php | 7 +--- .../back_office/settings/src/Setting/Unit.php | 19 ++++----- .../src/Strategy/StaticThumbnailStrategy.php | 8 +--- .../ApplicationDetailsViewSubscriber.php | 6 +-- .../VerifyStateEventSubscriber.php | 20 ++------- .../customer_portal/src/Form/VerifyType.php | 6 +-- .../src/Migrations/Action/AssignSection.php | 10 ++--- .../Action/AssignSectionExecutor.php | 16 ++------ .../src/Migrations/Step/ReplaceNameStep.php | 2 +- .../Step/ReplaceNameStepExecutor.php | 12 ++---- .../src/Command/ManageDiscountsCommand.php | 24 +++-------- .../2dpoint_ft/src/FieldType/Point2D/Type.php | 1 + .../src/FieldType/Point2D/Value.php | 2 +- .../2dpoint_ft/steps/step_1/Value.php | 12 +----- .../2dpoint_ft/steps/step_6/Type.php | 1 + .../Comparison/HelloWorldComparisonEngine.php | 9 +--- .../Comparison/HelloWorldComparisonResult.php | 8 +--- .../src/FieldType/HelloWorld/Value.php | 4 +- ...kboxWithRichtextDescriptionFieldMapper.php | 1 + .../CheckboxWithRichtextDescriptionType.php | 2 + .../AttributeRichtextDescriptionType.php | 2 + .../Field/Mapper/CountryFieldMapper.php | 1 + .../src/QueryType/LatestContentQueryType.php | 2 +- .../OptionsBasedLatestContentQueryType.php | 2 +- .../src/Controller/RelationController.php | 8 +--- .../src/Controller/BreadcrumbController.php | 8 +--- .../layouts/menu/src/Menu/MenuBuilder.php | 5 +-- .../src/Command/ViewCommand.php | 11 +---- .../CustomerNotNullValidator.php | 2 +- .../Type/CustomShippingMethodOptionsType.php | 1 + .../Storage/StorageSchema.php | 6 +-- .../view_matcher/src/View/Matcher/Owner.php | 5 +-- .../src/AutomatedTranslation/AiClient.php | 8 +--- .../Block/Attribute/MyStringAttributeType.php | 2 + .../BlockEmbedEventEventSubscriber.php | 5 +-- .../Command/ActivityLogContextTestCommand.php | 31 +++----------- .../Command/DispatchMyFeatureEventCommand.php | 6 +-- .../MonitorRecentContentCreationCommand.php | 12 +----- .../src/Event/MyFeatureEvent.php | 8 +--- .../MyFeatureEventSubscriber.php | 7 +--- ...urePostActivityListLoadEventSubscriber.php | 10 ++--- .../ContentTypeGroupGroupResolver.php | 7 +--- ...riorityRangeAggregationResultExtractor.php | 2 +- .../Solr/PriorityRangeAggregationVisitor.php | 2 +- .../Solr/CameraManufacturerVisitor.php | 4 +- .../WebinarEventTitleFulltextFieldMapper.php | 12 +----- .../src/Event/RandomBlockListener.php | 16 +------- .../src/OAuth/GoogleResourceOwnerMapper.php | 30 +++----------- .../ApprovedTransitionListener.php | 5 +-- .../EventListener/LegalTransitionListener.php | 5 +-- .../workflow/strategy/NewWorkflow.php | 2 +- .../strategy/NewWorkflowConditionalStep.php | 2 +- composer.json | 3 ++ rector.php | 1 + 132 files changed, 276 insertions(+), 1129 deletions(-) diff --git a/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php b/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php index 49663f2bb3..6ab3027e0f 100644 --- a/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php +++ b/code_samples/ai_actions/src/AI/Action/TranscribeAudioAction.php @@ -9,11 +9,8 @@ final class TranscribeAudioAction extends Action { - private Audio $audio; - - public function __construct(Audio $audio) + public function __construct(private readonly Audio $audio) { - $this->audio = $audio; } public function getParameters(): array diff --git a/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php b/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php index e77e9efb45..d6b4b87f48 100644 --- a/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php +++ b/code_samples/ai_actions/src/AI/ActionType/TranscribeAudioActionType.php @@ -12,17 +12,13 @@ use Ibexa\Contracts\ConnectorAi\DataType; use Ibexa\Contracts\Core\Exception\InvalidArgumentException; -final class TranscribeAudioActionType implements ActionTypeInterface +final readonly class TranscribeAudioActionType implements ActionTypeInterface { - public const IDENTIFIER = 'transcribe_audio'; - - /** @var iterable<\Ibexa\Contracts\ConnectorAi\Action\ActionHandlerInterface> */ - private iterable $actionHandlers; + public const string IDENTIFIER = 'transcribe_audio'; /** @param iterable<\Ibexa\Contracts\ConnectorAi\Action\ActionHandlerInterface> $actionHandlers*/ - public function __construct(iterable $actionHandlers) + public function __construct(private iterable $actionHandlers) { - $this->actionHandlers = $actionHandlers; } public function getIdentifier(): string diff --git a/code_samples/ai_actions/src/AI/DataType/Audio.php b/code_samples/ai_actions/src/AI/DataType/Audio.php index 8f9f0f9475..bea562a1c9 100644 --- a/code_samples/ai_actions/src/AI/DataType/Audio.php +++ b/code_samples/ai_actions/src/AI/DataType/Audio.php @@ -11,15 +11,11 @@ */ final class Audio implements DataType { - /** @var non-empty-array */ - private array $base64; - /** * @param non-empty-array $base64 */ - public function __construct(array $base64) + public function __construct(private array $base64) { - $this->base64 = $base64; } public function getBase64(): string diff --git a/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php b/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php index 71ed36cda0..df616c173f 100644 --- a/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php +++ b/code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php @@ -12,18 +12,12 @@ use Ibexa\Contracts\ConnectorAi\ActionResponseInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -final class LLaVaTextToTextActionHandler implements ActionHandlerInterface +final readonly class LLaVaTextToTextActionHandler implements ActionHandlerInterface { - private HttpClientInterface $client; + public const string IDENTIFIER = 'LLaVATextToText'; - private string $host; - - public const IDENTIFIER = 'LLaVATextToText'; - - public function __construct(HttpClientInterface $client, string $host = 'http://localhost:8080') + public function __construct(private HttpClientInterface $client, private string $host = 'http://localhost:8080') { - $this->client = $client; - $this->host = $host; } public function supports(ActionInterface $action): bool @@ -63,7 +57,7 @@ public function handle(ActionInterface $action, array $context = []): ActionResp ] ); - $output = strip_tags(json_decode($response->getContent(), true)['choices'][0]['message']['content']); + $output = strip_tags((string) json_decode($response->getContent(), true)['choices'][0]['message']['content']); return new TextResponse(new Text([$output])); } diff --git a/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php b/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php index 1c253249ce..583f75fa54 100644 --- a/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php +++ b/code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php @@ -15,7 +15,7 @@ final class WhisperAudioToTextActionHandler implements ActionHandlerInterface { - private const TIMESTAMP_FORMAT = '/^\[\d{2}:\d{2}\.\d{3} --> \d{2}:\d{2}\.\d{3}]\s*/'; + private const string TIMESTAMP_FORMAT = '/^\[\d{2}:\d{2}\.\d{3} --> \d{2}:\d{2}\.\d{3}]\s*/'; public function supports(ActionInterface $action): bool { @@ -33,7 +33,7 @@ public function handle(ActionInterface $action, array $context = []): ActionResp $language = $action->getRuntimeContext()?->get('languageCode'); if ($language !== null) { - $arguments[] = sprintf('--language=%s', substr($language, 0, 2)); + $arguments[] = sprintf('--language=%s', substr((string) $language, 0, 2)); } $arguments[] = '--output_format=txt'; @@ -72,9 +72,7 @@ private function removeTimestamps(string $text): string { $lines = explode(PHP_EOL, $text); - $processedLines = array_map(static function (string $line): string { - return preg_replace(self::TIMESTAMP_FORMAT, '', $line) ?? ''; - }, $lines); + $processedLines = array_map(static fn (string $line): string => preg_replace(self::TIMESTAMP_FORMAT, '', $line) ?? '', $lines); return implode(PHP_EOL, $processedLines); } diff --git a/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php b/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php index 0951c9b732..78520a1e4e 100644 --- a/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php +++ b/code_samples/ai_actions/src/AI/REST/Input/Parser/TranscribeAudio.php @@ -13,8 +13,8 @@ final class TranscribeAudio extends BaseParser { - public const AUDIO_KEY = 'Audio'; - public const BASE64_KEY = 'base64'; + public const string AUDIO_KEY = 'Audio'; + public const string BASE64_KEY = 'base64'; /** @param array $data */ public function parse(array $data, ParsingDispatcher $parsingDispatcher): TranscribeAudioAction diff --git a/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php b/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php index 07b2240db0..b8184649a4 100644 --- a/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php +++ b/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php @@ -10,7 +10,7 @@ final class AudioText extends ValueObjectVisitor { - private const OBJECT_IDENTIFIER = 'AudioText'; + private const string OBJECT_IDENTIFIER = 'AudioText'; public function visit(Visitor $visitor, Generator $generator, $data): void { diff --git a/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php b/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php index 643b32867e..258381dab6 100644 --- a/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php +++ b/code_samples/ai_actions/src/AI/REST/Value/TranscribeAudioAction.php @@ -7,18 +7,10 @@ use App\AI\DataType\Audio; use Ibexa\Contracts\ConnectorAi\Action\RuntimeContext; -final class TranscribeAudioAction +final readonly class TranscribeAudioAction { - private Audio $input; - - private RuntimeContext $runtimeContext; - - public function __construct( - Audio $input, - RuntimeContext $runtimeContext - ) { - $this->input = $input; - $this->runtimeContext = $runtimeContext; + public function __construct(private Audio $input, private RuntimeContext $runtimeContext) + { } public function getInput(): Audio diff --git a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php index cb7ce9bc29..0c6ef19854 100644 --- a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php +++ b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php @@ -24,29 +24,13 @@ )] final class ActionConfigurationCreateCommand extends Command { - private ActionConfigurationServiceInterface $actionConfigurationService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private ActionServiceInterface $actionService; - - private ActionTypeRegistryInterface $actionTypeRegistry; - public function __construct( - ActionConfigurationServiceInterface $actionConfigurationService, - PermissionResolver $permissionResolver, - UserService $userService, - ActionServiceInterface $actionService, - ActionTypeRegistryInterface $actionTypeRegistry + private readonly ActionConfigurationServiceInterface $actionConfigurationService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly ActionServiceInterface $actionService, + private readonly ActionTypeRegistryInterface $actionTypeRegistry ) { - $this->actionConfigurationService = $actionConfigurationService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->actionService = $actionService; - $this->actionTypeRegistry = $actionTypeRegistry; - parent::__construct(); } diff --git a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php index 5084b61d4e..dee23735e9 100644 --- a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php +++ b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php @@ -33,35 +33,16 @@ )] final class AddMissingAltTextCommand extends Command { - private const IMAGE_FIELD_IDENTIFIER = 'image'; - - private ContentService $contentService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private FieldTypeService $fieldTypeService; - - private ActionServiceInterface $actionService; - - private IOBinarydataHandler $binaryDataHandler; + private const string IMAGE_FIELD_IDENTIFIER = 'image'; public function __construct( - ContentService $contentService, - PermissionResolver $permissionResolver, - UserService $userService, - FieldTypeService $fieldTypeService, - ActionServiceInterface $actionService, - IOBinarydataHandler $binaryDataHandler + private readonly ContentService $contentService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly FieldTypeService $fieldTypeService, + private readonly ActionServiceInterface $actionService, + private readonly IOBinarydataHandler $binaryDataHandler ) { - $this->contentService = $contentService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->fieldTypeService = $fieldTypeService; - $this->actionService = $actionService; - $this->binaryDataHandler = $binaryDataHandler; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/CartCommand.php b/code_samples/api/commerce/src/Command/CartCommand.php index aedfb50589..d44e01be36 100644 --- a/code_samples/api/commerce/src/Command/CartCommand.php +++ b/code_samples/api/commerce/src/Command/CartCommand.php @@ -27,41 +27,16 @@ )] final class CartCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private CartServiceInterface $cartService; - - private CurrencyServiceInterface $currencyService; - - private ProductServiceInterface $productService; - - private OrderServiceInterface $orderService; - - private ReorderService $reorderService; - - private CartResolverInterface $cartResolver; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - CartServiceInterface $cartService, - CurrencyServiceInterface $currencyService, - ProductServiceInterface $productService, - OrderServiceInterface $orderService, - ReorderService $reorderService, - CartResolverInterface $cartResolver + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly CartServiceInterface $cartService, + private readonly CurrencyServiceInterface $currencyService, + private readonly ProductServiceInterface $productService, + private readonly OrderServiceInterface $orderService, + private readonly ReorderService $reorderService, + private readonly CartResolverInterface $cartResolver ) { - $this->cartService = $cartService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->currencyService = $currencyService; - $this->productService = $productService; - $this->orderService = $orderService; - $this->reorderService = $reorderService; - $this->cartResolver = $cartResolver; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/OrderCommand.php b/code_samples/api/commerce/src/Command/OrderCommand.php index 904ff231ee..44b24caef5 100644 --- a/code_samples/api/commerce/src/Command/OrderCommand.php +++ b/code_samples/api/commerce/src/Command/OrderCommand.php @@ -31,21 +31,11 @@ )] final class OrderCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private OrderServiceInterface $orderService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - OrderServiceInterface $orderService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly OrderServiceInterface $orderService ) { - $this->orderService = $orderService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/PaymentCommand.php b/code_samples/api/commerce/src/Command/PaymentCommand.php index d7f98eeb6e..c2ffc98488 100644 --- a/code_samples/api/commerce/src/Command/PaymentCommand.php +++ b/code_samples/api/commerce/src/Command/PaymentCommand.php @@ -26,29 +26,13 @@ )] final class PaymentCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private PaymentServiceInterface $paymentService; - - private OrderServiceInterface $orderService; - - private PaymentMethodServiceInterface $paymentMethodService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - PaymentServiceInterface $paymentService, - OrderServiceInterface $orderService, - PaymentMethodServiceInterface $paymentMethodService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly PaymentServiceInterface $paymentService, + private readonly OrderServiceInterface $orderService, + private readonly PaymentMethodServiceInterface $paymentMethodService, ) { - $this->paymentService = $paymentService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->orderService = $orderService; - $this->paymentMethodService = $paymentMethodService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/PaymentMethodCommand.php b/code_samples/api/commerce/src/Command/PaymentMethodCommand.php index 0d26d03de0..4f4d6054e7 100644 --- a/code_samples/api/commerce/src/Command/PaymentMethodCommand.php +++ b/code_samples/api/commerce/src/Command/PaymentMethodCommand.php @@ -24,21 +24,11 @@ )] final class PaymentMethodCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private PaymentMethodServiceInterface $paymentMethodService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - PaymentMethodServiceInterface $paymentMethodService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly PaymentMethodServiceInterface $paymentMethodService ) { - $this->paymentMethodService = $paymentMethodService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/ShipmentCommand.php b/code_samples/api/commerce/src/Command/ShipmentCommand.php index 35dbfe7dfc..6dc246ee3e 100644 --- a/code_samples/api/commerce/src/Command/ShipmentCommand.php +++ b/code_samples/api/commerce/src/Command/ShipmentCommand.php @@ -27,29 +27,13 @@ )] final class ShipmentCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private ShipmentServiceInterface $shipmentService; - - private ShippingMethodServiceInterface $shippingMethodService; - - private OrderServiceInterface $orderService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - ShipmentServiceInterface $shipmentService, - ShippingMethodServiceInterface $shippingMethodService, - OrderServiceInterface $orderService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly ShipmentServiceInterface $shipmentService, + private readonly ShippingMethodServiceInterface $shippingMethodService, + private readonly OrderServiceInterface $orderService ) { - $this->shipmentService = $shipmentService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->shippingMethodService = $shippingMethodService; - $this->orderService = $orderService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Command/ShippingMethodCommand.php b/code_samples/api/commerce/src/Command/ShippingMethodCommand.php index 23f25286f9..85368142f8 100644 --- a/code_samples/api/commerce/src/Command/ShippingMethodCommand.php +++ b/code_samples/api/commerce/src/Command/ShippingMethodCommand.php @@ -23,25 +23,12 @@ )] final class ShippingMethodCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private ShippingMethodServiceInterface $shippingMethodService; - - private RegionServiceInterface $regionService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService, - ShippingMethodServiceInterface $shippingMethodService, - RegionServiceInterface $regionService + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly ShippingMethodServiceInterface $shippingMethodService, + private readonly RegionServiceInterface $regionService ) { - $this->shippingMethodService = $shippingMethodService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->regionService = $regionService; - parent::__construct(); } diff --git a/code_samples/api/commerce/src/Controller/CustomCheckoutController.php b/code_samples/api/commerce/src/Controller/CustomCheckoutController.php index 79ec15a75c..622c615697 100644 --- a/code_samples/api/commerce/src/Controller/CustomCheckoutController.php +++ b/code_samples/api/commerce/src/Controller/CustomCheckoutController.php @@ -11,14 +11,8 @@ class CustomCheckoutController extends Controller { - private CartServiceInterface $cartService; - - private CheckoutServiceInterface $checkoutService; - - public function __construct(CartServiceInterface $cartService, CheckoutServiceInterface $checkoutService) + public function __construct(private readonly CartServiceInterface $cartService, private readonly CheckoutServiceInterface $checkoutService) { - $this->cartService = $cartService; - $this->checkoutService = $checkoutService; } public function showContentAction(): Response diff --git a/code_samples/api/migration/src/Command/MigrationCommand.php b/code_samples/api/migration/src/Command/MigrationCommand.php index 862170007a..df0bf887b5 100644 --- a/code_samples/api/migration/src/Command/MigrationCommand.php +++ b/code_samples/api/migration/src/Command/MigrationCommand.php @@ -14,12 +14,8 @@ )] final class MigrationCommand extends Command { - private MigrationService $migrationService; - - public function __construct(MigrationService $migrationService) + public function __construct(private readonly MigrationService $migrationService) { - $this->migrationService = $migrationService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/AttributeCommand.php b/code_samples/api/product_catalog/src/Command/AttributeCommand.php index 609238328d..ee4d97b659 100644 --- a/code_samples/api/product_catalog/src/Command/AttributeCommand.php +++ b/code_samples/api/product_catalog/src/Command/AttributeCommand.php @@ -19,37 +19,15 @@ )] final class AttributeCommand extends Command { - private AttributeGroupServiceInterface $attributeGroupService; - - private LocalAttributeGroupServiceInterface $localAttributeGroupService; - - private AttributeDefinitionServiceInterface $attributeDefinitionService; - - private LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService; - - private AttributeTypeServiceInterface $attributeTypeService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - public function __construct( - LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService, - AttributeDefinitionServiceInterface $attributeDefinitionService, - AttributeGroupServiceInterface $attributeGroupService, - LocalAttributeGroupServiceInterface $localAttributeGroupService, - AttributeTypeServiceInterface $attributeTypeService, - UserService $userService, - PermissionResolver $permissionResolver + private readonly LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService, + private readonly AttributeDefinitionServiceInterface $attributeDefinitionService, + private readonly AttributeGroupServiceInterface $attributeGroupService, + private readonly LocalAttributeGroupServiceInterface $localAttributeGroupService, + private readonly AttributeTypeServiceInterface $attributeTypeService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver ) { - $this->localAttributeGroupService = $localAttributeGroupService; - $this->attributeGroupService = $attributeGroupService; - $this->attributeTypeService = $attributeTypeService; - $this->attributeDefinitionService = $attributeDefinitionService; - $this->localAttributeDefinitionService = $localAttributeDefinitionService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/CatalogCommand.php b/code_samples/api/product_catalog/src/Command/CatalogCommand.php index 800aa3deae..eef9eb1d62 100644 --- a/code_samples/api/product_catalog/src/Command/CatalogCommand.php +++ b/code_samples/api/product_catalog/src/Command/CatalogCommand.php @@ -24,25 +24,12 @@ )] final class CatalogCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductServiceInterface $productService; - - private CatalogServiceInterface $catalogService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductServiceInterface $productService, - CatalogServiceInterface $catalogService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductServiceInterface $productService, + private readonly CatalogServiceInterface $catalogService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->catalogService = $catalogService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php index 04f11d6d49..266ab2e0bb 100644 --- a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php +++ b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php @@ -18,18 +18,8 @@ )] final class CurrencyCommand extends Command { - private CurrencyServiceInterface $currencyService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(CurrencyServiceInterface $currencyService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly CurrencyServiceInterface $currencyService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->currencyService = $currencyService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php index 7d67874e29..aa9ed43d9e 100644 --- a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php @@ -19,25 +19,12 @@ )] final class ProductAssetCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductServiceInterface $productService; - - private AssetServiceInterface $assetService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductServiceInterface $productService, - AssetServiceInterface $assetService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductServiceInterface $productService, + private readonly AssetServiceInterface $assetService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->assetService = $assetService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductCommand.php b/code_samples/api/product_catalog/src/Command/ProductCommand.php index d58a537f89..a231d9ddd0 100644 --- a/code_samples/api/product_catalog/src/Command/ProductCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductCommand.php @@ -24,33 +24,14 @@ )] final class ProductCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductTypeServiceInterface $productTypeService; - - private ProductServiceInterface $productService; - - private LocalProductServiceInterface $localProductService; - - private ProductAvailabilityServiceInterface $productAvailabilityService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductTypeServiceInterface $productTypeService, - ProductServiceInterface $productService, - LocalProductServiceInterface $localProductService, - ProductAvailabilityServiceInterface $productAvailabilityService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductTypeServiceInterface $productTypeService, + private readonly ProductServiceInterface $productService, + private readonly LocalProductServiceInterface $localProductService, + private readonly ProductAvailabilityServiceInterface $productAvailabilityService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->productTypeService = $productTypeService; - $this->localProductService = $localProductService; - $this->productAvailabilityService = $productAvailabilityService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php index ce874bfe77..0a3c40ecbb 100644 --- a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php @@ -27,33 +27,14 @@ )] final class ProductPriceCommand extends Command { - private ProductPriceServiceInterface $productPriceService; - - private PriceResolverInterface $priceResolver; - - private ProductServiceInterface $productService; - - private CurrencyServiceInterface $currencyService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - public function __construct( - CurrencyServiceInterface $currencyService, - ProductServiceInterface $productService, - ProductPriceServiceInterface $productPriceService, - PriceResolverInterface $priceResolver, - UserService $userService, - PermissionResolver $permissionResolver + private readonly CurrencyServiceInterface $currencyService, + private readonly ProductServiceInterface $productService, + private readonly ProductPriceServiceInterface $productPriceService, + private readonly PriceResolverInterface $priceResolver, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver ) { - $this->currencyService = $currencyService; - $this->productPriceService = $productPriceService; - $this->priceResolver = $priceResolver; - $this->productService = $productService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php index 71af92cf14..b1c2f4da40 100644 --- a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php @@ -16,18 +16,8 @@ )] final class ProductTypeCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductTypeServiceInterface $productTypeService; - - public function __construct(UserService $userService, PermissionResolver $permissionResolver, ProductTypeServiceInterface $productTypeService) + public function __construct(private readonly UserService $userService, private readonly PermissionResolver $permissionResolver, private readonly ProductTypeServiceInterface $productTypeService) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productTypeService = $productTypeService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php index 6d7bcf789a..3b685a7fc4 100644 --- a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php @@ -21,25 +21,12 @@ )] final class ProductVariantCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private ProductServiceInterface $productService; - - private LocalProductServiceInterface $localProductService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - ProductServiceInterface $productService, - LocalProductServiceInterface $localProductService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly ProductServiceInterface $productService, + private readonly LocalProductServiceInterface $localProductService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->productService = $productService; - $this->localProductService = $localProductService; - parent::__construct(); } diff --git a/code_samples/api/product_catalog/src/Command/VatCommand.php b/code_samples/api/product_catalog/src/Command/VatCommand.php index 8cd7bd265b..fc5ee046c6 100644 --- a/code_samples/api/product_catalog/src/Command/VatCommand.php +++ b/code_samples/api/product_catalog/src/Command/VatCommand.php @@ -17,25 +17,12 @@ )] final class VatCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private VatServiceInterface $vatService; - - private RegionServiceInterface $regionService; - public function __construct( - UserService $userService, - PermissionResolver $permissionResolver, - VatServiceInterface $vatService, - RegionServiceInterface $regionService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly VatServiceInterface $vatService, + private readonly RegionServiceInterface $regionService ) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->vatService = $vatService; - $this->regionService = $regionService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php index d734fa9841..1144c7bf31 100644 --- a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php @@ -16,18 +16,8 @@ )] class AddLanguageCommand extends Command { - private LanguageService $languageService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LanguageService $languageService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly LanguageService $languageService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->languageService = $languageService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php index 79cf794d03..bdde5d4293 100644 --- a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php @@ -18,21 +18,8 @@ )] class AddLocationToContentCommand extends Command { - private ContentService $contentService; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php index 072185599a..daee829bc7 100644 --- a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php +++ b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php @@ -16,15 +16,8 @@ )] class BookmarkCommand extends Command { - private BookmarkService $bookmarkService; - - private LocationService $locationService; - - public function __construct(BookmarkService $bookmarkService, LocationService $locationService) + public function __construct(private readonly BookmarkService $bookmarkService, private readonly LocationService $locationService) { - $this->bookmarkService = $bookmarkService; - $this->locationService = $locationService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php index b6d7641184..9f88f6ee9e 100644 --- a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php +++ b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php @@ -16,12 +16,8 @@ )] class BrowseLocationsCommand extends Command { - private LocationService $locationService; - - public function __construct(LocationService $locationService) + public function __construct(private readonly LocationService $locationService) { - $this->locationService = $locationService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/CalendarCommand.php b/code_samples/api/public_php_api/src/Command/CalendarCommand.php index 7bcaefea8d..664c4abb52 100644 --- a/code_samples/api/public_php_api/src/Command/CalendarCommand.php +++ b/code_samples/api/public_php_api/src/Command/CalendarCommand.php @@ -18,18 +18,8 @@ )] class CalendarCommand extends Command { - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private CalendarServiceInterface $calendarService; - - public function __construct(PermissionResolver $permissionResolver, UserService $userService, CalendarServiceInterface $calendarService) + public function __construct(private readonly PermissionResolver $permissionResolver, private readonly UserService $userService, private readonly CalendarServiceInterface $calendarService) { - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->calendarService = $calendarService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php index be1ca6db5a..91700cae0c 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php @@ -19,24 +19,8 @@ )] class CreateContentCommand extends Command { - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, ContentTypeService $contentTypeService, LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly ContentTypeService $contentTypeService, private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php index 7a86405849..740383bc5a 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php @@ -18,18 +18,8 @@ )] class CreateContentTypeCommand extends Command { - private ContentTypeService $contentTypeService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentTypeService $contentTypeService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentTypeService $contentTypeService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentTypeService = $contentTypeService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } @@ -56,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier($groupIdentifier); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $output->writeln("Content type group with identifier $groupIdentifier not found"); return self::FAILURE; diff --git a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php index 5aae67c0ef..f34f599cd0 100644 --- a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php @@ -20,24 +20,8 @@ )] class CreateImageCommand extends Command { - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, ContentTypeService $contentTypeService, LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly ContentTypeService $contentTypeService, private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } @@ -67,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int [ 'path' => $file, 'fileSize' => filesize($file), - 'fileName' => basename($file), + 'fileName' => basename((string) $file), 'alternativeText' => $name, ] ); diff --git a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php index 7aa74ffd89..9541b5e2bc 100644 --- a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php @@ -16,18 +16,8 @@ )] class DeleteContentCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FilterCommand.php b/code_samples/api/public_php_api/src/Command/FilterCommand.php index a3abce7933..09f1afdd35 100644 --- a/code_samples/api/public_php_api/src/Command/FilterCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterCommand.php @@ -19,12 +19,8 @@ )] class FilterCommand extends Command { - private ContentService $contentService; - - public function __construct(ContentService $contentService) + public function __construct(private readonly ContentService $contentService) { - $this->contentService = $contentService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php index 3143fdcaad..f1f05b5b23 100644 --- a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php @@ -19,12 +19,8 @@ )] class FilterLocationCommand extends Command { - private LocationService $locationService; - - public function __construct(LocationService $locationService) + public function __construct(private readonly LocationService $locationService) { - $this->locationService = $locationService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php index 748c8d50c8..dae57ba0ec 100644 --- a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php @@ -19,15 +19,8 @@ )] class FindComplexCommand extends Command { - private SearchService $searchService; - - private LocationService $locationService; - - public function __construct(SearchService $searchService, LocationService $locationService) + public function __construct(private readonly SearchService $searchService, private readonly LocationService $locationService) { - $this->searchService = $searchService; - $this->locationService = $locationService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FindContentCommand.php b/code_samples/api/public_php_api/src/Command/FindContentCommand.php index 972bd1b295..ff72d55a46 100644 --- a/code_samples/api/public_php_api/src/Command/FindContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindContentCommand.php @@ -17,12 +17,8 @@ )] class FindContentCommand extends Command { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php index 883b11e65d..c663e92917 100644 --- a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php @@ -16,12 +16,8 @@ )] class FindInTrashCommand extends Command { - private TrashService $trashService; - - public function __construct(TrashService $trashService) + public function __construct(private readonly TrashService $trashService) { - $this->trashService = $trashService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php index b896f3acbe..916d329576 100644 --- a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php @@ -19,18 +19,8 @@ )] class FindUrlCommand extends Command { - private URLService $urlService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(URLService $URLService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly URLService $urlService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->urlService = $URLService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php index f972de32a1..664d0a85fb 100644 --- a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php @@ -18,12 +18,8 @@ )] class FindWithAggregationCommand extends Command { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php b/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php index 2f05b2c9b9..14fe4eb7a5 100644 --- a/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php +++ b/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php @@ -16,21 +16,8 @@ )] final class FormSubmissionCommand extends Command { - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private FormSubmissionServiceInterface $formSubmissionService; - - private ContentService $contentService; - - public function __construct(UserService $userService, PermissionResolver $permissionResolver, FormSubmissionServiceInterface $formSubmissionService, ContentService $contentService) + public function __construct(private readonly UserService $userService, private readonly PermissionResolver $permissionResolver, private readonly FormSubmissionServiceInterface $formSubmissionService, private readonly ContentService $contentService) { - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->formSubmissionService = $formSubmissionService; - $this->contentService = $contentService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php index 06cfae6ec6..356ce98f52 100644 --- a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php @@ -17,18 +17,8 @@ )] class HideLocationCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php index bdb5563aa2..73668ca741 100644 --- a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php @@ -17,18 +17,8 @@ )] class MoveContentCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php index 2b264dda53..9adbbcf37d 100644 --- a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php +++ b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php @@ -18,21 +18,8 @@ )] class ObjectStateCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private ObjectStateService $objectStateService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, ObjectStateService $objectStateService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly ObjectStateService $objectStateService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->userService = $userService; - $this->objectStateService = $objectStateService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } @@ -58,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($objectState->getName()); $objectStateGroupIdentifier = $input->getArgument('objectStateGroupIdentifier'); - $objectStateIdentifierList = explode(',', $input->getArgument('objectStateIdentifier')); + $objectStateIdentifierList = explode(',', (string) $input->getArgument('objectStateIdentifier')); $objectStateGroupStruct = $this->objectStateService->newObjectStateGroupCreateStruct($objectStateGroupIdentifier); $objectStateGroupStruct->defaultLanguageCode = 'eng-GB'; diff --git a/code_samples/api/public_php_api/src/Command/SectionCommand.php b/code_samples/api/public_php_api/src/Command/SectionCommand.php index 9845064b76..5ee14d92fc 100644 --- a/code_samples/api/public_php_api/src/Command/SectionCommand.php +++ b/code_samples/api/public_php_api/src/Command/SectionCommand.php @@ -21,24 +21,8 @@ )] class SectionCommand extends Command { - private SectionService $sectionService; - - private UserService $userService; - - private SearchService $searchService; - - private ContentService $contentService; - - private PermissionResolver $permissionResolver; - - public function __construct(SectionService $sectionService, UserService $userService, ContentService $contentService, SearchService $searchService, PermissionResolver $permissionResolver) + public function __construct(private readonly SectionService $sectionService, private readonly UserService $userService, private readonly ContentService $contentService, private readonly SearchService $searchService, private readonly PermissionResolver $permissionResolver) { - $this->sectionService = $sectionService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->searchService = $searchService; - $this->contentService = $contentService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/SegmentCommand.php b/code_samples/api/public_php_api/src/Command/SegmentCommand.php index 7fbbf8a4f7..7eb8833da8 100644 --- a/code_samples/api/public_php_api/src/Command/SegmentCommand.php +++ b/code_samples/api/public_php_api/src/Command/SegmentCommand.php @@ -17,18 +17,8 @@ )] class SegmentCommand extends Command { - private SegmentationService $segmentationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(SegmentationService $segmentationService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly SegmentationService $segmentationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->segmentationService = $segmentationService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php index af022123e3..b155cfde90 100644 --- a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php @@ -17,18 +17,8 @@ )] class SetMainLocationCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php b/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php index de0b0bb3b9..2b98a23b6e 100644 --- a/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php +++ b/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php @@ -17,21 +17,11 @@ )] class TaxonomyCommand extends Command { - private TaxonomyServiceInterface $taxonomyService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - TaxonomyServiceInterface $taxonomyService, - PermissionResolver $permissionResolver, - UserService $userService + private readonly TaxonomyServiceInterface $taxonomyService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService ) { - $this->taxonomyService = $taxonomyService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php index 0e33007661..d2ef82e2f9 100644 --- a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php @@ -16,18 +16,8 @@ )] class TranslateContentCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php index 88a799273b..44cf486b03 100644 --- a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php @@ -18,21 +18,8 @@ )] class TrashContentCommand extends Command { - private LocationService $locationService; - - private UserService $userService; - - private TrashService $trashService; - - private PermissionResolver $permissionResolver; - - public function __construct(LocationService $locationService, UserService $userService, TrashService $trashService, PermissionResolver $permissionResolver) + public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly TrashService $trashService, private readonly PermissionResolver $permissionResolver) { - $this->locationService = $locationService; - $this->userService = $userService; - $this->trashService = $trashService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php index cfc3f1acc3..4b4c8cd7a5 100644 --- a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php @@ -17,18 +17,8 @@ )] class UpdateContentCommand extends Command { - private ContentService $contentService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, UserService $userService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php index 8e3673316b..eae8627271 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php @@ -17,18 +17,8 @@ )] class ViewContentCommand extends Command { - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private FieldTypeService $fieldTypeService; - - public function __construct(ContentService $contentService, ContentTypeService $contentTypeService, FieldTypeService $fieldTypeService) + public function __construct(private readonly ContentService $contentService, private readonly ContentTypeService $contentTypeService, private readonly FieldTypeService $fieldTypeService) { - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->fieldTypeService = $fieldTypeService; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php index 09d4cb1295..39a95ceb70 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php @@ -21,27 +21,8 @@ )] class ViewContentMetaDataCommand extends Command { - private ContentService $contentService; - - private LocationService $locationService; - - private URLAliasService $urlAliasService; - - private UserService $userService; - - private ObjectStateService $objectStateService; - - private PermissionResolver $permissionResolver; - - public function __construct(ContentService $contentService, LocationService $locationService, URLAliasService $urlAliasService, UserService $userService, ObjectStateService $objectStateService, PermissionResolver $permissionResolver) + public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService, private readonly URLAliasService $urlAliasService, private readonly UserService $userService, private readonly ObjectStateService $objectStateService, private readonly PermissionResolver $permissionResolver) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->urlAliasService = $urlAliasService; - $this->userService = $userService; - $this->objectStateService = $objectStateService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index 1a1c021fb7..13a14de920 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -17,18 +17,8 @@ )] class WorkflowCommand extends Command { - private WorkflowServiceInterface $workflowService; - - private WorkflowRegistryInterface $workflowRegistry; - - private ContentService $contentService; - - public function __construct(WorkflowServiceInterface $workflowService, WorkflowRegistryInterface $workflowRegistry, ContentService $contentService) + public function __construct(private readonly WorkflowServiceInterface $workflowService, private readonly WorkflowRegistryInterface $workflowRegistry, private readonly ContentService $contentService) { - $this->contentService = $contentService; - $this->workflowService = $workflowService; - $this->workflowRegistry = $workflowRegistry; - parent::__construct(); } diff --git a/code_samples/api/public_php_api/src/Controller/CustomController.php b/code_samples/api/public_php_api/src/Controller/CustomController.php index 19e87da5ec..1f00f31571 100644 --- a/code_samples/api/public_php_api/src/Controller/CustomController.php +++ b/code_samples/api/public_php_api/src/Controller/CustomController.php @@ -10,11 +10,8 @@ class CustomController extends Controller { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; } public function showContentAction(int $locationId): Response diff --git a/code_samples/api/public_php_api/src/Controller/CustomFilterController.php b/code_samples/api/public_php_api/src/Controller/CustomFilterController.php index 7ec661c0cb..07c057262d 100644 --- a/code_samples/api/public_php_api/src/Controller/CustomFilterController.php +++ b/code_samples/api/public_php_api/src/Controller/CustomFilterController.php @@ -10,11 +10,8 @@ class CustomFilterController extends Controller { - private ContentService $contentService; - - public function __construct(ContentService $contentService) + public function __construct(private readonly ContentService $contentService) { - $this->contentService = $contentService; } public function showChildrenAction(ContentView $view): ContentView diff --git a/code_samples/api/public_php_api/src/Controller/PaginationController.php b/code_samples/api/public_php_api/src/Controller/PaginationController.php index cd468ae2be..ea6fad8694 100644 --- a/code_samples/api/public_php_api/src/Controller/PaginationController.php +++ b/code_samples/api/public_php_api/src/Controller/PaginationController.php @@ -13,11 +13,8 @@ class PaginationController extends Controller { - private SearchService $searchService; - - public function __construct(SearchService $searchService) + public function __construct(private readonly SearchService $searchService) { - $this->searchService = $searchService; } public function showContentAction(Request $request, int $locationId): Response diff --git a/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php b/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php index 8a82af15e9..6b6c76e671 100644 --- a/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php +++ b/code_samples/api/public_php_api/src/EventSubscriber/MyEventSubcriber.php @@ -7,7 +7,7 @@ class MyEventSubcriber implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ CopyContentEvent::class => ['onCopyContent', 0], diff --git a/code_samples/api/rest_api/create_image.json.php b/code_samples/api/rest_api/create_image.json.php index 18f70d2f8b..501931004e 100644 --- a/code_samples/api/rest_api/create_image.json.php +++ b/code_samples/api/rest_api/create_image.json.php @@ -95,7 +95,7 @@ echo "\t{$responseArray['ErrorMessage']['errorDescription']}\n"; exit(4); } - } catch (HttpException\DecodingExceptionInterface $exception) { + } catch (HttpException\DecodingExceptionInterface) { } $responseHeaders = $response->getInfo('response_headers'); $error = $responseHeaders[0] ?? $responseCode; @@ -131,7 +131,7 @@ echo "\t{$responseArray['ErrorMessage']['errorDescription']}\n"; exit(8); } - } catch (HttpException\DecodingExceptionInterface $exception) { + } catch (HttpException\DecodingExceptionInterface) { } $responseHeaders = $response->getInfo('response_headers'); $error = $responseHeaders[0] ?? $responseCode; diff --git a/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php b/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php index 39782164fc..acd98ee6d6 100644 --- a/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php +++ b/code_samples/api/rest_api/src/Rest/Output/ValueObjectVisitorDispatcher.php @@ -10,19 +10,16 @@ class ValueObjectVisitorDispatcher // extends BaseValueObjectVisitorDispatcher T { private array $visitors; - private BaseValueObjectVisitorDispatcher $valueObjectVisitorDispatcher; - private Visitor $outputVisitor; private Generator $outputGenerator; - public function __construct(iterable $visitors, BaseValueObjectVisitorDispatcher $valueObjectVisitorDispatcher) + public function __construct(iterable $visitors, private readonly BaseValueObjectVisitorDispatcher $valueObjectVisitorDispatcher) { $this->visitors = []; foreach ($visitors as $type => $visitor) { $this->visitors[$type] = $visitor; } - $this->valueObjectVisitorDispatcher = $valueObjectVisitorDispatcher; } public function setOutputVisitor(Visitor $outputVisitor): void @@ -39,7 +36,7 @@ public function setOutputGenerator(Generator $outputGenerator): void public function visit($data) { - $className = get_class($data); + $className = $data::class; if (isset($this->visitors[$className])) { return $this->visitors[$className]->visit($this->outputVisitor, $this->outputGenerator, $data); } diff --git a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php index 59dbf68fd0..fcc739e4ff 100644 --- a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php +++ b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/RestLocation.php @@ -10,13 +10,11 @@ class RestLocation extends BaseRestLocation { - private URLAliasService $urlAliasService; - - public function __construct(URLAliasService $urlAliasService) + public function __construct(private readonly URLAliasService $urlAliasService) { - $this->urlAliasService = $urlAliasService; } + #[\Override] public function visit(Visitor $visitor, Generator $generator, $data): void { // Not using $generator->startObjectElement to not have the XML Generator adding its own media-type attribute with the default vendor diff --git a/code_samples/api/rest_api/src/Rest/Values/Greeting.php b/code_samples/api/rest_api/src/Rest/Values/Greeting.php index 3052899209..7b82ac48b7 100644 --- a/code_samples/api/rest_api/src/Rest/Values/Greeting.php +++ b/code_samples/api/rest_api/src/Rest/Values/Greeting.php @@ -4,13 +4,7 @@ class Greeting { - public string $salutation; - - public string $recipient; - - public function __construct(string $salutation = 'Hello', string $recipient = 'World') + public function __construct(public string $salutation = 'Hello', public string $recipient = 'World') { - $this->salutation = $salutation; - $this->recipient = $recipient; } } diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php index b6136ff6dd..0755376d56 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php @@ -10,11 +10,8 @@ class EventSourceFactory { - private EventType $eventType; - - public function __construct(EventType $eventType) + public function __construct(private readonly EventType $eventType) { - $this->eventType = $eventType; } public function createEventSource(): EventSourceInterface diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php index 12c0370980..8dcdfcb5b7 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php @@ -8,9 +8,9 @@ class EventType implements EventTypeInterface { - private const EVENT_TYPE_IDENTIFIER = 'holiday'; + private const string EVENT_TYPE_IDENTIFIER = 'holiday'; - private EventActionCollection $actions; + private readonly EventActionCollection $actions; public function __construct(iterable $actions) { diff --git a/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php b/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php index 7c373dae72..9a54be1d5c 100644 --- a/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php +++ b/code_samples/back_office/dashboard/article_tab/src/Tab/Dashboard/Everyone/EveryoneArticleTab.php @@ -16,20 +16,13 @@ class EveryoneArticleTab extends AbstractTab implements OrderedTabInterface { - protected PagerLocationToDataMapper $pagerLocationToDataMapper; - - protected SearchService $searchService; - public function __construct( Environment $twig, TranslatorInterface $translator, - PagerLocationToDataMapper $pagerLocationToDataMapper, - SearchService $searchService + protected PagerLocationToDataMapper $pagerLocationToDataMapper, + protected SearchService $searchService ) { parent::__construct($twig, $translator); - - $this->pagerLocationToDataMapper = $pagerLocationToDataMapper; - $this->searchService = $searchService; } public function getIdentifier(): string diff --git a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php index e6cc95ba7b..b4e4ef02e1 100644 --- a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php +++ b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php @@ -20,21 +20,18 @@ )] class DashboardCommand extends Command { - private DashboardServiceInterface $dashboardService; + private readonly Locationservice $locationService; - private Locationservice $locationService; + private readonly ContentService $contentService; - private ContentService $contentService; + private readonly UserService $userService; - private UserService $userService; - - private PermissionResolver $permissionResolver; + private readonly PermissionResolver $permissionResolver; public function __construct( - DashboardServiceInterface $dashboardService, + private readonly DashboardServiceInterface $dashboardService, Repository $repository ) { - $this->dashboardService = $dashboardService; $this->locationService = $repository->getLocationService(); $this->contentService = $repository->getContentService(); $this->userService = $repository->getUserService(); diff --git a/code_samples/back_office/images/src/SvgController.php b/code_samples/back_office/images/src/SvgController.php index b2ea7be6d1..009b84cc4b 100644 --- a/code_samples/back_office/images/src/SvgController.php +++ b/code_samples/back_office/images/src/SvgController.php @@ -16,22 +16,10 @@ class SvgController extends Controller { - private const CONTENT_TYPE_HEADER = 'image/svg+xml'; + private const string CONTENT_TYPE_HEADER = 'image/svg+xml'; - private ContentService $contentService; - - private IOServiceInterface $ioService; - - private TranslationHelper $translationHelper; - - public function __construct( - ContentService $contentService, - IOServiceInterface $ioService, - TranslationHelper $translationHelper - ) { - $this->contentService = $contentService; - $this->ioService = $ioService; - $this->translationHelper = $translationHelper; + public function __construct(private readonly ContentService $contentService, private readonly IOServiceInterface $ioService, private readonly TranslationHelper $translationHelper) + { } /** diff --git a/code_samples/back_office/images/src/SvgExtension.php b/code_samples/back_office/images/src/SvgExtension.php index 821d6250e6..de6826d22f 100644 --- a/code_samples/back_office/images/src/SvgExtension.php +++ b/code_samples/back_office/images/src/SvgExtension.php @@ -10,19 +10,17 @@ class SvgExtension extends AbstractExtension { - protected RouterInterface $router; - /** * SvgExtension constructor. */ - public function __construct(RouterInterface $router) + public function __construct(protected RouterInterface $router) { - $this->router = $router; } /** * @return \Twig\TwigFunction[] */ + #[\Override] public function getFunctions(): array { return [ diff --git a/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php b/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php index 06030e605a..42d3a1ca63 100644 --- a/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php +++ b/code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.php @@ -9,7 +9,6 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Core\Repository\Values\User\Limitation; use Ibexa\Contracts\Core\Repository\Values\User\UserReference; -use Ibexa\Contracts\Core\Repository\Values\ValueObject; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Core\Base\Exceptions\InvalidArgumentType; use Ibexa\Core\FieldType\ValidationError; @@ -57,7 +56,7 @@ public function buildValue(array $limitationValues): CustomLimitationValue * * @return bool|null */ - public function evaluate(Limitation $value, UserReference $currentUser, ValueObject $object, array $targets = null): ?bool + public function evaluate(Limitation $value, UserReference $currentUser, object $object, array $targets = null): ?bool { if (!$value instanceof CustomLimitationValue) { throw new InvalidArgumentException('$value', 'Must be of type: CustomLimitationValue'); diff --git a/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php b/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php index 01aa512d68..787391a8d4 100644 --- a/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php +++ b/code_samples/back_office/menu/menu_item/src/Controller/AllContentListController.php @@ -13,14 +13,8 @@ class AllContentListController extends Controller { - private SearchService $searchService; - - private FormFactory $formFactory; - - public function __construct(SearchService $searchService, FormFactory $formFactory) + public function __construct(private readonly SearchService $searchService, private readonly FormFactory $formFactory) { - $this->searchService = $searchService; - $this->formFactory = $formFactory; } public function listAction(int $page = 1): Response diff --git a/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php b/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php index 3c2a651a32..c1447f80ba 100644 --- a/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php +++ b/code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php @@ -7,13 +7,10 @@ use Ibexa\Contracts\Core\Repository\Values\Notification\CreateStruct; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -final class ContentPublishEventListener implements EventSubscriberInterface +final readonly class ContentPublishEventListener implements EventSubscriberInterface { - private NotificationService $notificationService; - - public function __construct(NotificationService $notificationService) + public function __construct(private NotificationService $notificationService) { - $this->notificationService = $notificationService; } public static function getSubscribedEvents(): array diff --git a/code_samples/back_office/notifications/src/Notification/MyRenderer.php b/code_samples/back_office/notifications/src/Notification/MyRenderer.php index cb745cf6ab..fd8beebff6 100644 --- a/code_samples/back_office/notifications/src/Notification/MyRenderer.php +++ b/code_samples/back_office/notifications/src/Notification/MyRenderer.php @@ -11,14 +11,8 @@ class MyRenderer implements NotificationRenderer { - protected Environment $twig; - - protected RouterInterface $router; - - public function __construct(Environment $twig, RouterInterface $router) + public function __construct(protected Environment $twig, protected RouterInterface $router) { - $this->twig = $twig; - $this->router = $router; } public function render(Notification $notification): string diff --git a/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php b/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php index 6cc97a5edc..924e92ea45 100644 --- a/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php +++ b/code_samples/back_office/online_editor/src/event/subscriber/RichTextBlockSubscriber.php @@ -12,15 +12,11 @@ class RichTextBlockSubscriber implements EventSubscriberInterface { - /** @var \Ibexa\FieldTypeRichText\RichText\DOMDocumentFactory */ - private $domDocumentFactory; - /** * @param \Ibexa\FieldTypeRichText\RichText\DOMDocumentFactory $domDocumentFactory */ - public function __construct(DOMDocumentFactory $domDocumentFactory) + public function __construct(private readonly DOMDocumentFactory $domDocumentFactory) { - $this->domDocumentFactory = $domDocumentFactory; } /** diff --git a/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php b/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php index 0304243c06..9fe69380df 100644 --- a/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php +++ b/code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php @@ -15,12 +15,8 @@ class MySuggestionEventSubscriber implements EventSubscriberInterface, LoggerAwa { use LoggerAwareTrait; - private ProductServiceInterface $productService; - - public function __construct( - ProductServiceInterface $productService, - ) { - $this->productService = $productService; + public function __construct(private ProductServiceInterface $productService) + { } public static function getSubscribedEvents(): array @@ -36,14 +32,12 @@ public function onBuildSuggestionCollectionEvent(BuildSuggestionCollectionEvent $suggestionCollection = $event->getSuggestionCollection(); $text = $suggestionQuery->getQuery(); - $words = explode(' ', preg_replace('/\s+/', ' ', $text)); + $words = explode(' ', (string) preg_replace('/\s+/', ' ', $text)); $limit = $suggestionQuery->getLimit(); try { $productQuery = new ProductQuery(null, new Criterion\LogicalOr([ - new Criterion\ProductName(implode(' ', array_map(static function (string $word) { - return "$word*"; - }, $words))), + new Criterion\ProductName(implode(' ', array_map(static fn (string $word) => "$word*", $words))), new Criterion\ProductCode($words), new Criterion\ProductType($words), ]), [], 0, $limit); diff --git a/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php b/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php index a054e5550c..6e8be68e4d 100644 --- a/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php +++ b/code_samples/back_office/search/src/Search/Model/Suggestion/ProductSuggestion.php @@ -7,7 +7,7 @@ class ProductSuggestion extends Suggestion { - private Product $product; + private readonly Product $product; public function __construct( float $score, diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php index 04cdecaded..82db0c90ef 100644 --- a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php @@ -10,13 +10,10 @@ use JMS\TranslationBundle\Translation\TranslationContainerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class SectionNameSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface +final readonly class SectionNameSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function getSortingDefinitions(): array diff --git a/code_samples/back_office/settings/src/Setting/Unit.php b/code_samples/back_office/settings/src/Setting/Unit.php index 4a4eeaabe9..dd524ccf85 100644 --- a/code_samples/back_office/settings/src/Setting/Unit.php +++ b/code_samples/back_office/settings/src/Setting/Unit.php @@ -25,17 +25,14 @@ public function getDescription(): string public function getDisplayValue(string $storageValue): string { - switch ($storageValue) { - case self::METRIC_OPTION: - return 'Metric'; - case self::IMPERIAL_OPTION: - return 'Imperial'; - default: - throw new InvalidArgumentException( - '$storageValue', - sprintf('There is no \'%s\' option', $storageValue) - ); - } + return match ($storageValue) { + self::METRIC_OPTION => 'Metric', + self::IMPERIAL_OPTION => 'Imperial', + default => throw new InvalidArgumentException( + '$storageValue', + sprintf('There is no \'%s\' option', $storageValue) + ), + }; } public function getDefaultValue(): string diff --git a/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php b/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php index 1cd431c64a..76cd57d9d4 100644 --- a/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php +++ b/code_samples/back_office/thumbnails/src/Strategy/StaticThumbnailStrategy.php @@ -9,14 +9,10 @@ use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; -final class StaticThumbnailStrategy implements ThumbnailStrategy +final readonly class StaticThumbnailStrategy implements ThumbnailStrategy { - /** @var string */ - private $staticThumbnail; - - public function __construct(string $staticThumbnail) + public function __construct(private string $staticThumbnail) { - $this->staticThumbnail = $staticThumbnail; } public function getThumbnail(ContentType $contentType, array $fields, ?VersionInfo $versionInfo = null): ?Thumbnail diff --git a/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php b/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php index 16c510d16d..a3aa625019 100644 --- a/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php +++ b/code_samples/customer_portal/src/Corporate/EventSubscriber/ApplicationDetailsViewSubscriber.php @@ -13,15 +13,11 @@ final class ApplicationDetailsViewSubscriber extends AbstractViewSubscriber { - private FormFactoryInterface $formFactory; - public function __construct( SiteAccessServiceInterface $siteAccessService, - FormFactoryInterface $formFactory + private readonly FormFactoryInterface $formFactory ) { parent::__construct($siteAccessService); - - $this->formFactory = $formFactory; } /** diff --git a/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php b/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php index 5091fbee10..c503416572 100644 --- a/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php +++ b/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php @@ -15,24 +15,12 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormFactoryInterface; -final class VerifyStateEventSubscriber implements EventSubscriberInterface +final readonly class VerifyStateEventSubscriber implements EventSubscriberInterface { - private const VERIFY_STATE = 'verify'; + private const string VERIFY_STATE = 'verify'; - private FormFactoryInterface $formFactory; - - private HandlerInterface $applicationStateHandler; - - private TranslatableNotificationHandlerInterface $notificationHandler; - - public function __construct( - FormFactoryInterface $formFactory, - HandlerInterface $applicationStateHandler, - TranslatableNotificationHandlerInterface $notificationHandler - ) { - $this->formFactory = $formFactory; - $this->applicationStateHandler = $applicationStateHandler; - $this->notificationHandler = $notificationHandler; + public function __construct(private FormFactoryInterface $formFactory, private HandlerInterface $applicationStateHandler, private TranslatableNotificationHandlerInterface $notificationHandler) + { } public static function getSubscribedEvents(): array diff --git a/code_samples/customer_portal/src/Form/VerifyType.php b/code_samples/customer_portal/src/Form/VerifyType.php index 95d4685134..0326c304ac 100644 --- a/code_samples/customer_portal/src/Form/VerifyType.php +++ b/code_samples/customer_portal/src/Form/VerifyType.php @@ -13,9 +13,9 @@ final class VerifyType extends AbstractType { - private const FIELD_APPLICATION = 'application'; - private const FIELD_NOTES = 'notes'; - private const FIELD_VERIFY = 'verify'; + private const string FIELD_APPLICATION = 'application'; + private const string FIELD_NOTES = 'notes'; + private const string FIELD_VERIFY = 'verify'; public function buildForm( FormBuilderInterface $builder, diff --git a/code_samples/data_migration/src/Migrations/Action/AssignSection.php b/code_samples/data_migration/src/Migrations/Action/AssignSection.php index 635658a5e4..876c51491a 100644 --- a/code_samples/data_migration/src/Migrations/Action/AssignSection.php +++ b/code_samples/data_migration/src/Migrations/Action/AssignSection.php @@ -6,16 +6,12 @@ use Ibexa\Migration\ValueObject\Step\Action; -final class AssignSection implements Action +final readonly class AssignSection implements Action { - public const TYPE = 'assign_section'; + public const string TYPE = 'assign_section'; - /** @var string */ - private $sectionIdentifier; - - public function __construct(string $sectionIdentifier) + public function __construct(private string $sectionIdentifier) { - $this->sectionIdentifier = $sectionIdentifier; } /** diff --git a/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php b/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php index 9a19f1ad17..d633c01cee 100644 --- a/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php +++ b/code_samples/data_migration/src/Migrations/Action/AssignSectionExecutor.php @@ -8,20 +8,10 @@ use Ibexa\Migration\StepExecutor\ActionExecutor\ExecutorInterface; use Ibexa\Migration\ValueObject; -final class AssignSectionExecutor implements ExecutorInterface +final readonly class AssignSectionExecutor implements ExecutorInterface { - /** @var \Ibexa\Contracts\Core\Repository\SectionService */ - private $sectionService; - - /** @var \Ibexa\Contracts\Core\Repository\ContentService */ - private $contentService; - - public function __construct( - ContentService $contentService, - SectionService $sectionService - ) { - $this->sectionService = $sectionService; - $this->contentService = $contentService; + public function __construct(private ContentService $contentService, private SectionService $sectionService) + { } /** diff --git a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php index d846d1b083..64bbe53d68 100644 --- a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php +++ b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStep.php @@ -6,7 +6,7 @@ use Ibexa\Migration\ValueObject\Step\StepInterface; -final class ReplaceNameStep implements StepInterface +final readonly class ReplaceNameStep implements StepInterface { private string $replacement; diff --git a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php index 0f033f192c..394e3dfd01 100644 --- a/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php +++ b/code_samples/data_migration/src/Migrations/Step/ReplaceNameStepExecutor.php @@ -12,12 +12,8 @@ final class ReplaceNameStepExecutor extends AbstractStepExecutor { - private ContentService $contentService; - - public function __construct( - ContentService $contentService - ) { - $this->contentService = $contentService; + public function __construct(private readonly ContentService $contentService) + { } protected function doHandle(StepInterface $step) @@ -38,7 +34,7 @@ protected function doHandle(StepInterface $step) continue; } - if (str_contains($field->value, 'Company Name')) { + if (str_contains((string) $field->value, 'Company Name')) { $newValue = str_replace('Company Name', $step->getReplacement(), $field->value); $struct->setField($field->fieldDefIdentifier, new Value($newValue)); } @@ -48,7 +44,7 @@ protected function doHandle(StepInterface $step) $content = $this->contentService->createContentDraft($contentItem->contentInfo); $content = $this->contentService->updateContent($content->getVersionInfo(), $struct); $this->contentService->publishVersion($content->getVersionInfo()); - } catch (\Throwable $e) { + } catch (\Throwable) { // Ignore } } diff --git a/code_samples/discounts/src/Command/ManageDiscountsCommand.php b/code_samples/discounts/src/Command/ManageDiscountsCommand.php index 8852f5b5df..c22c48227e 100644 --- a/code_samples/discounts/src/Command/ManageDiscountsCommand.php +++ b/code_samples/discounts/src/Command/ManageDiscountsCommand.php @@ -23,29 +23,15 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[\Symfony\Component\Console\Attribute\AsCommand(name: 'discounts:manage')] final class ManageDiscountsCommand extends Command { - protected static $defaultName = 'discounts:manage'; - - private DiscountServiceInterface $discountService; - - private DiscountCodeServiceInterface $discountCodeService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - UserService $userSerice, - PermissionResolver $permissionResolver, - DiscountServiceInterface $discountService, - DiscountCodeServiceInterface $discountCodeService + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly DiscountServiceInterface $discountService, + private readonly DiscountCodeServiceInterface $discountCodeService ) { - $this->userService = $userSerice; - $this->discountService = $discountService; - $this->discountCodeService = $discountCodeService; - $this->permissionResolver = $permissionResolver; - parent::__construct(); } diff --git a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php index 7dc5dc9e53..5b34101a47 100644 --- a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php +++ b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php @@ -19,6 +19,7 @@ public function getFieldTypeIdentifier(): string return 'point2d'; } + #[\Override] public function getSettingsSchema(): array { return [ diff --git a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php index 422da756ee..0d9cfa5dcf 100644 --- a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php +++ b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Value.php @@ -50,7 +50,7 @@ public function setY(?float $y): void $this->y = $y; } - public function __toString() + public function __toString(): string { return "({$this->x}, {$this->y})"; } diff --git a/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php b/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php index 985a415ab7..5d6e5bdbf9 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_1/Value.php @@ -7,16 +7,8 @@ final class Value implements ValueInterface { - /** @var float|null */ - private $x; - - /** @var float|null */ - private $y; - - public function __construct(?float $x = null, ?float $y = null) + public function __construct(private ?float $x = null, private ?float $y = null) { - $this->x = $x; - $this->y = $y; } public function getX(): ?float @@ -39,7 +31,7 @@ public function setY(?float $y): void $this->y = $y; } - public function __toString() + public function __toString(): string { return "({$this->x}, {$this->y})"; } diff --git a/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php b/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php index 14a5b9209d..7019b0876c 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php @@ -15,6 +15,7 @@ public function getFieldTypeIdentifier(): string return 'point2d'; } + #[\Override] public function getSettingsSchema(): array { return [ diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php index 1467f4d827..60fdf5ca71 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonEngine.php @@ -7,16 +7,11 @@ use Ibexa\Contracts\VersionComparison\Engine\FieldTypeComparisonEngine; use Ibexa\Contracts\VersionComparison\FieldType\FieldTypeComparisonValue; use Ibexa\Contracts\VersionComparison\Result\ComparisonResult; -use Ibexa\VersionComparison\Engine\Value\StringComparisonEngine; -final class HelloWorldComparisonEngine implements FieldTypeComparisonEngine +final readonly class HelloWorldComparisonEngine implements FieldTypeComparisonEngine { - /** @var \Ibexa\VersionComparison\Engine\Value\StringComparisonEngine */ - private \Ibexa\VersionComparison\Engine\Value\StringComparisonEngine $stringValueComparisonEngine; - - public function __construct(StringComparisonEngine $stringValueComparisonEngine) + public function __construct(private \Ibexa\VersionComparison\Engine\Value\StringComparisonEngine $stringValueComparisonEngine) { - $this->stringValueComparisonEngine = $stringValueComparisonEngine; } /** diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php index 8c03b8e4d9..a8bab2d2f7 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Comparison/HelloWorldComparisonResult.php @@ -7,14 +7,10 @@ use Ibexa\Contracts\VersionComparison\Result\ComparisonResult; use Ibexa\VersionComparison\Result\Value\StringComparisonResult; -final class HelloWorldComparisonResult implements ComparisonResult +final readonly class HelloWorldComparisonResult implements ComparisonResult { - /** @var \Ibexa\VersionComparison\Result\Value\StringComparisonResult */ - private \Ibexa\VersionComparison\Result\Value\StringComparisonResult $stringDiff; - - public function __construct(StringComparisonResult $stringDiff) + public function __construct(private \Ibexa\VersionComparison\Result\Value\StringComparisonResult $stringDiff) { - $this->stringDiff = $stringDiff; } public function getHelloWorldDiff(): StringComparisonResult diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php index 80c34031a6..5810b42304 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Value.php @@ -10,7 +10,7 @@ final class Value implements ValueInterface /** * @Assert\NotBlank() */ - private ?string $name; + private ?string $name = null; public function getName(): ?string { @@ -22,7 +22,7 @@ public function setName(?string $name): void $this->name = $name; } - public function __toString() + public function __toString(): string { return "Hello {$this->name}!"; } diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php index 710d55279e..015ee0e76e 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php @@ -10,6 +10,7 @@ class CheckboxWithRichtextDescriptionFieldMapper extends GenericFieldMapper /** * {@inheritdoc} */ + #[\Override] protected function mapFormOptions(Field $field, array $constraints): array { $options = parent::mapFormOptions($field, $constraints); diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php index d0b801a0a0..a5603b63f6 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/CheckboxWithRichtextDescriptionType.php @@ -13,6 +13,7 @@ class CheckboxWithRichtextDescriptionType extends AbstractType /** * @return string|null */ + #[\Override] public function getParent(): ?string { return CheckboxType::class; @@ -21,6 +22,7 @@ public function getParent(): ?string /** * @return string */ + #[\Override] public function getBlockPrefix(): string { return 'checkbox_with_richtext_description'; diff --git a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php index 27728d1688..4162e9471b 100644 --- a/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php +++ b/code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php @@ -10,6 +10,7 @@ class AttributeRichtextDescriptionType extends AbstractType /** * @return string|null */ + #[\Override] public function getParent(): ?string { return RichTextType::class; @@ -18,6 +19,7 @@ public function getParent(): ?string /** * @return string */ + #[\Override] public function getBlockPrefix(): string { return 'field_configuration_attribute_richtext'; diff --git a/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php b/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php index 5f7f765243..32d4b9774a 100644 --- a/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php +++ b/code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php @@ -7,6 +7,7 @@ class CountryFieldMapper extends GenericFieldMapper { + #[\Override] protected function mapFormOptions(Field $field, array $constraints): array { $options = parent::mapFormOptions($field, $constraints); diff --git a/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php b/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php index 7dee3868ec..2c73561ddc 100644 --- a/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php +++ b/code_samples/front/custom_query_type/src/QueryType/LatestContentQueryType.php @@ -25,7 +25,7 @@ public function getQuery(array $parameters = []) 'sortClauses' => [ new Query\SortClause\DatePublished(Query::SORT_DESC), ], - 'limit' => isset($parameters['limit']) ? $parameters['limit'] : 10, + 'limit' => $parameters['limit'] ?? 10, ]); } diff --git a/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php b/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php index f3b987e6ad..3b0060bfc1 100644 --- a/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php +++ b/code_samples/front/custom_query_type/src/QueryType/OptionsBasedLatestContentQueryType.php @@ -27,7 +27,7 @@ protected function doGetQuery(array $parameters) 'sortClauses' => [ new Query\SortClause\DatePublished(Query::SORT_DESC), ], - 'limit' => isset($parameters['limit']) ? $parameters['limit'] : 10, + 'limit' => $parameters['limit'] ?? 10, ]); } diff --git a/code_samples/front/embed_content/src/Controller/RelationController.php b/code_samples/front/embed_content/src/Controller/RelationController.php index b0cd9aa5be..ebeaac939d 100644 --- a/code_samples/front/embed_content/src/Controller/RelationController.php +++ b/code_samples/front/embed_content/src/Controller/RelationController.php @@ -8,14 +8,8 @@ class RelationController { - private ContentService $contentService; - - private LocationService $locationService; - - public function __construct(ContentService $contentService, LocationService $locationService) + public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService) { - $this->contentService = $contentService; - $this->locationService = $locationService; } public function showContentAction(View $view, $locationId): View diff --git a/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php b/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php index e178da4048..4cbe2bc0e1 100644 --- a/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php +++ b/code_samples/front/layouts/breadcrumbs/src/Controller/BreadcrumbController.php @@ -11,14 +11,8 @@ class BreadcrumbController extends Controller { - private LocationService $locationService; - - private SearchService $searchService; - - public function __construct(LocationService $locationService, SearchService $searchService) + public function __construct(private readonly LocationService $locationService, private readonly SearchService $searchService) { - $this->locationService = $locationService; - $this->searchService = $searchService; } public function showBreadcrumbsAction($locationId): Response diff --git a/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php b/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php index 977724de5f..9266372cf2 100644 --- a/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php +++ b/code_samples/front/layouts/menu/src/Menu/MenuBuilder.php @@ -7,11 +7,8 @@ class MenuBuilder { - private FactoryInterface $factory; - - public function __construct(FactoryInterface $factory) + public function __construct(private readonly FactoryInterface $factory) { - $this->factory = $factory; } public function buildMenu(): ItemInterface diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index 4c1bf39616..c5897dfcdb 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -16,17 +16,10 @@ )] class ViewCommand extends Command { - private ContentViewBuilder $contentViewBuilder; - - private TemplateRenderer $templateRenderer; - public function __construct( - ContentViewBuilder $contentViewBuilder, - TemplateRenderer $templateRenderer + private readonly ContentViewBuilder $contentViewBuilder, + private readonly TemplateRenderer $templateRenderer ) { - $this->contentViewBuilder = $contentViewBuilder; - $this->templateRenderer = $templateRenderer; - parent::__construct(); } diff --git a/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php b/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php index e162d29fc0..da4e59ba1e 100644 --- a/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php +++ b/code_samples/front/shop/shipping/src/ShippingMethodType/CustomerNotNullValidator.php @@ -12,7 +12,7 @@ final class CustomerNotNullValidator implements OptionsValidatorInterface, TranslationContainerInterface { - public const MESSAGE = 'Customer identifier value cannot be null'; + public const string MESSAGE = 'Customer identifier value cannot be null'; public function validateOptions(OptionsBag $options): array { diff --git a/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php b/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php index 365f1a2156..d331e37781 100644 --- a/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php +++ b/code_samples/front/shop/shipping/src/ShippingMethodType/Form/Type/CustomShippingMethodOptionsType.php @@ -13,6 +13,7 @@ final class CustomShippingMethodOptionsType extends AbstractType implements TranslationContainerInterface { + #[\Override] public function getBlockPrefix(): string { return 'ibexa_shipping_method_custom'; diff --git a/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php b/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php index 4417a749c0..96470cb038 100644 --- a/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php +++ b/code_samples/front/shop/shipping/src/ShippingMethodType/Storage/StorageSchema.php @@ -8,7 +8,7 @@ final class StorageSchema extends AbstractOptionsStorageSchema { - public const TABLE_NAME = 'ibexa_shipping_method_region_custom'; - public const COLUMN_ID = 'id'; - public const COLUMN_CUSTOMER_ID = 'customer_id'; + public const string TABLE_NAME = 'ibexa_shipping_method_region_custom'; + public const string COLUMN_ID = 'id'; + public const string COLUMN_CUSTOMER_ID = 'customer_id'; } diff --git a/code_samples/front/view_matcher/src/View/Matcher/Owner.php b/code_samples/front/view_matcher/src/View/Matcher/Owner.php index 106d55bcd7..9c21e12141 100644 --- a/code_samples/front/view_matcher/src/View/Matcher/Owner.php +++ b/code_samples/front/view_matcher/src/View/Matcher/Owner.php @@ -13,14 +13,11 @@ class Owner implements MatcherInterface { - private UserService $userService; - /** @var string[] */ private array $matchingUserLogins; - public function __construct(UserService $userService) + public function __construct(private readonly UserService $userService) { - $this->userService = $userService; } /** diff --git a/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php b/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php index e423edb643..817bfa8af0 100644 --- a/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php +++ b/code_samples/multisite/automated_translation/src/AutomatedTranslation/AiClient.php @@ -14,14 +14,8 @@ final class AiClient implements ClientInterface /** @var array */ private array $supportedLanguages; - private ActionServiceInterface $actionService; - - private ActionConfigurationServiceInterface $actionConfigurationService; - - public function __construct(ActionServiceInterface $actionService, ActionConfigurationServiceInterface $actionConfigurationService) + public function __construct(private readonly ActionServiceInterface $actionService, private readonly ActionConfigurationServiceInterface $actionConfigurationService) { - $this->actionService = $actionService; - $this->actionConfigurationService = $actionConfigurationService; } public function setConfiguration(array $configuration): void diff --git a/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php b/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php index 22e65e7f7b..34604db561 100644 --- a/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php +++ b/code_samples/page/custom_attribute/src/Block/Attribute/MyStringAttributeType.php @@ -7,11 +7,13 @@ class MyStringAttributeType extends AbstractType { + #[\Override] public function getParent(): ?string { return TextType::class; } + #[\Override] public function getBlockPrefix(): string { return 'my_string_attribute'; diff --git a/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php b/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php index a86ae91b47..157c55ced7 100644 --- a/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php +++ b/code_samples/page/custom_page_block/src/Event/Subscriber/BlockEmbedEventEventSubscriber.php @@ -9,11 +9,8 @@ class BlockEmbedEventEventSubscriber implements EventSubscriberInterface { - private ContentService $contentService; - - public function __construct(ContentService $contentService) + public function __construct(private readonly ContentService $contentService) { - $this->contentService = $contentService; } public static function getSubscribedEvents(): array diff --git a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php index d4c93ccd5f..c53703e2fa 100644 --- a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php +++ b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php @@ -23,33 +23,14 @@ )] class ActivityLogContextTestCommand extends Command { - private ActivityLogServiceInterface $activityLogService; - - private ContentService $contentService; - - private ContentTypeService $contentTypeService; - - private EventDispatcherInterface $eventDispatcher; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - ActivityLogServiceInterface $activityLogService, - ContentService $contentService, - ContentTypeService $contentTypeService, - EventDispatcherInterface $eventDispatcher, - PermissionResolver $permissionResolver, - UserService $userService + private readonly ActivityLogServiceInterface $activityLogService, + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService ) { - $this->activityLogService = $activityLogService; - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->eventDispatcher = $eventDispatcher; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - parent::__construct(); } diff --git a/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php b/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php index 2b6e1baafa..ab8cec0ef0 100644 --- a/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php +++ b/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php @@ -16,12 +16,8 @@ )] class DispatchMyFeatureEventCommand extends Command { - private EventDispatcherInterface $eventDispatcher; - - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(private readonly EventDispatcherInterface $eventDispatcher) { - $this->eventDispatcher = $eventDispatcher; - parent::__construct(); } diff --git a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php index 52808377f9..39b611ea2a 100644 --- a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php +++ b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php @@ -21,18 +21,8 @@ )] class MonitorRecentContentCreationCommand extends Command { - private ActivityLogServiceInterface $activityLogService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - public function __construct(ActivityLogServiceInterface $activityLogService, PermissionResolver $permissionResolver, UserService $userService) + public function __construct(private readonly ActivityLogServiceInterface $activityLogService, private readonly PermissionResolver $permissionResolver, private readonly UserService $userService) { - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->activityLogService = $activityLogService; - parent::__construct(); } diff --git a/code_samples/recent_activity/src/Event/MyFeatureEvent.php b/code_samples/recent_activity/src/Event/MyFeatureEvent.php index 53dbfcb8cf..b5bd8e1090 100644 --- a/code_samples/recent_activity/src/Event/MyFeatureEvent.php +++ b/code_samples/recent_activity/src/Event/MyFeatureEvent.php @@ -6,14 +6,8 @@ class MyFeatureEvent extends Event { - private object $object; - - private string $action; - - public function __construct(object $object, string $action) + public function __construct(private readonly object $object, private readonly string $action) { - $this->object = $object; - $this->action = $action; } public function getObject(): object diff --git a/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php b/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php index ca8a93bcf6..812875614c 100644 --- a/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php +++ b/code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php @@ -8,11 +8,8 @@ class MyFeatureEventSubscriber implements EventSubscriberInterface { - private ActivityLogServiceInterface $activityLogService; - - public function __construct(ActivityLogServiceInterface $activityLogService) + public function __construct(private readonly ActivityLogServiceInterface $activityLogService) { - $this->activityLogService = $activityLogService; } public static function getSubscribedEvents(): array @@ -26,7 +23,7 @@ public function onMyFeatureEvent(MyFeatureEvent $event): void { /** @var \App\MyFeature\MyFeature $object */ $object = $event->getObject(); - $className = get_class($object); + $className = $object::class; $id = (string)$object->id; $action = $event->getAction(); $activityLog = $this->activityLogService->build($className, $id, $action); diff --git a/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php b/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php index 93d87e8a7b..619ff17f6e 100644 --- a/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php +++ b/code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php @@ -11,12 +11,8 @@ class MyFeaturePostActivityListLoadEventSubscriber implements EventSubscriberInterface { - private MyFeatureService $myFeatureService; - - public function __construct( - MyFeatureService $myFeatureService - ) { - $this->myFeatureService = $myFeatureService; + public function __construct(private readonly MyFeatureService $myFeatureService) + { } public static function getSubscribedEvents(): array @@ -47,7 +43,7 @@ public function loadMyFeature(PostActivityGroupListLoadEvent $event): void } $log->setRelatedObject($visitedIds[$id]); - } catch (NotFoundException|UnauthorizedException $e) { + } catch (NotFoundException|UnauthorizedException) { $visitedIds[$id] = null; } } diff --git a/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php b/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php index fd38f72dcb..a707b331c5 100644 --- a/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php +++ b/code_samples/search/custom/src/GroupResolver/ContentTypeGroupGroupResolver.php @@ -8,13 +8,10 @@ use Ibexa\Contracts\Elasticsearch\ElasticSearch\Index\Group\GroupResolverInterface; use Ibexa\Contracts\Elasticsearch\Mapping\BaseDocument; -final class ContentTypeGroupGroupResolver implements GroupResolverInterface +final readonly class ContentTypeGroupGroupResolver implements GroupResolverInterface { - private Handler $contentTypeHandler; - - public function __construct(Handler $contentTypeHandler) + public function __construct(private Handler $contentTypeHandler) { - $this->contentTypeHandler = $contentTypeHandler; } public function resolveDocumentGroup(BaseDocument $document): string diff --git a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php index ba87eda5cf..a81fb9b743 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php @@ -24,7 +24,7 @@ public function extract(Aggregation $aggregation, array $languageFilter, stdClas { $entries = []; foreach ($data as $key => $bucket) { - if ($key === 'count' || strpos($key, '_') === false) { + if ($key === 'count' || !str_contains($key, '_')) { continue; } [$from, $to] = explode('_', $key, 2); diff --git a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php index d78f1a58f6..e33fd56042 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php @@ -27,7 +27,7 @@ public function visit( foreach ($aggregation->getRanges() as $range) { $from = $this->formatRangeValue($range->getFrom()); $to = $this->formatRangeValue($range->getTo()); - $rangeFacets["${from}_${to}"] = [ + $rangeFacets["{$from}_{$to}"] = [ 'type' => 'query', 'q' => sprintf('priority_i:[%s TO %s}', $from, $to), ]; diff --git a/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php b/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php index f385d5db1d..97f404aa15 100644 --- a/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php +++ b/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php @@ -21,9 +21,7 @@ public function canVisit(CriterionInterface $criterion) public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $expressions = array_map( - function ($value): string { - return 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"'; - }, + fn ($value): string => 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"', $criterion->value ); diff --git a/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php b/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php index 6eae611537..67a209dc4d 100644 --- a/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php +++ b/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php @@ -10,16 +10,8 @@ class WebinarEventTitleFulltextFieldMapper extends ContentFieldMapper { - protected ContentHandler $contentHandler; - - protected LocationHandler $locationHandler; - - public function __construct( - ContentHandler $contentHandler, - LocationHandler $locationHandler - ) { - $this->contentHandler = $contentHandler; - $this->locationHandler = $locationHandler; + public function __construct(protected ContentHandler $contentHandler, protected LocationHandler $locationHandler) + { } public function accept(Content $content) diff --git a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php index 6415335e83..3e72e3970e 100644 --- a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php +++ b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php @@ -16,20 +16,8 @@ class RandomBlockListener implements EventSubscriberInterface { - private ContentService $contentService; - - private LocationService $locationService; - - private SearchService $searchService; - - public function __construct( - ContentService $contentService, - LocationService $locationService, - SearchService $searchService - ) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->searchService = $searchService; + public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService, private readonly SearchService $searchService) + { } public static function getSubscribedEvents(): array diff --git a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php index 0b05b8d101..cbd1d14a74 100644 --- a/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php +++ b/code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php @@ -17,35 +17,17 @@ final class GoogleResourceOwnerMapper extends ResourceOwnerToExistingOrNewUserMapper { - private const PROVIDER_PREFIX = 'google:'; - - private OAuth2UserService $oauthUserService; - - private LanguageResolver $languageResolver; - - private UserService $userService; - - /** @var string|null */ - private ?string $contentTypeIdentifier; - - /** @var string|null */ - private ?string $parentGroupRemoteId; + private const string PROVIDER_PREFIX = 'google:'; public function __construct( Repository $repository, - OAuth2UserService $oauthUserService, - LanguageResolver $languageResolver, - UserService $userService, - ?string $contentTypeIdentifier = null, - ?string $parentGroupRemoteId = null + private readonly OAuth2UserService $oauthUserService, + private readonly LanguageResolver $languageResolver, + private readonly UserService $userService, + private readonly ?string $contentTypeIdentifier = null, + private readonly ?string $parentGroupRemoteId = null ) { parent::__construct($repository); - - $this->oauthUserService = $oauthUserService; - $this->languageResolver = $languageResolver; - $this->userService = $userService; - $this->contentTypeIdentifier = $contentTypeIdentifier; - $this->parentGroupRemoteId = $parentGroupRemoteId; } /** diff --git a/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php b/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php index ed7f5af3e2..1e6d72e701 100644 --- a/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php +++ b/code_samples/workflow/custom_workflow/src/EventListener/ApprovedTransitionListener.php @@ -10,11 +10,8 @@ class ApprovedTransitionListener extends AbstractTransitionWorkflowActionListener { - private NotificationInterface $notificationHandler; - - public function __construct(NotificationInterface $notificationHandler) + public function __construct(private readonly NotificationInterface $notificationHandler) { - $this->notificationHandler = $notificationHandler; } public function getIdentifier(): string diff --git a/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php b/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php index 85f63f55b8..7c10898c57 100644 --- a/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php +++ b/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php @@ -10,11 +10,8 @@ class LegalTransitionListener extends AbstractTransitionWorkflowActionListener { - private NotificationInterface $notificationHandler; - - public function __construct(NotificationInterface $notificationHandler) + public function __construct(private readonly NotificationInterface $notificationHandler) { - $this->notificationHandler = $notificationHandler; } public function getIdentifier(): string diff --git a/code_samples/workflow/strategy/NewWorkflow.php b/code_samples/workflow/strategy/NewWorkflow.php index ac4a240d25..6d15c010ce 100644 --- a/code_samples/workflow/strategy/NewWorkflow.php +++ b/code_samples/workflow/strategy/NewWorkflow.php @@ -11,7 +11,7 @@ final class NewWorkflow implements WorkflowStrategyInterface { - private const IDENTIFIER = 'new_workflow'; + private const string IDENTIFIER = 'new_workflow'; public function getWorkflow(CartInterface $cart): WorkflowInterface { diff --git a/code_samples/workflow/strategy/NewWorkflowConditionalStep.php b/code_samples/workflow/strategy/NewWorkflowConditionalStep.php index d055c879e0..1fa93235d7 100644 --- a/code_samples/workflow/strategy/NewWorkflowConditionalStep.php +++ b/code_samples/workflow/strategy/NewWorkflowConditionalStep.php @@ -11,7 +11,7 @@ final class NewWorkflowConditionalStep implements WorkflowStrategyInterface { - private const IDENTIFIER = 'new_workflow'; + private const string IDENTIFIER = 'new_workflow'; public function getWorkflow(CartInterface $cart): WorkflowInterface { diff --git a/composer.json b/composer.json index ed8a71e403..f4f318a534 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,9 @@ "url": "https://updates.ibexa.co" } ], + "require": { + "php": "^8.3" + }, "require-dev": { "ibexa/automated-translation": "5.0.x-dev", "ibexa/code-style": "~2.0.0", diff --git a/rector.php b/rector.php index 669d153f8b..091043e174 100644 --- a/rector.php +++ b/rector.php @@ -14,6 +14,7 @@ ->withPaths([ __DIR__ . '/code_samples', ]) + ->withPhpSets() ->withSets([ IbexaSetList::IBEXA_50->value, SymfonySetList::SYMFONY_60, From 459aa2a642fe016740f081d3a87ea56bc0319525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 10 Jul 2025 14:06:56 +0200 Subject: [PATCH 13/26] Manual changes --- .../Output/ValueObjectVisitor/AudioText.php | 3 +++ .../src/Rest/ValueObjectVisitor/Greeting.php | 3 +++ .../PriorityRangeAggregationVisitor.php | 5 ++++- .../Aggregation/PriorityRangeAggregation.php | 5 +++++ .../Solr/PriorityRangeAggregationVisitor.php | 5 ++++- .../EventListener/LegalTransitionListener.php | 2 +- phpstan-baseline.neon | 18 ------------------ 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php b/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php index b8184649a4..1c8277f585 100644 --- a/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php +++ b/code_samples/ai_actions/src/AI/REST/Output/ValueObjectVisitor/AudioText.php @@ -12,6 +12,9 @@ final class AudioText extends ValueObjectVisitor { private const string OBJECT_IDENTIFIER = 'AudioText'; + /** + * @param \App\AI\REST\Value\AudioText $data + */ public function visit(Visitor $visitor, Generator $generator, $data): void { $mediaType = 'ai.' . self::OBJECT_IDENTIFIER; diff --git a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php index f909993490..85b9dce847 100644 --- a/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php +++ b/code_samples/api/rest_api/src/Rest/ValueObjectVisitor/Greeting.php @@ -8,6 +8,9 @@ class Greeting extends ValueObjectVisitor { + /** + * @param \App\Rest\Values\Greeting $data + */ public function visit(Visitor $visitor, Generator $generator, $data) { $visitor->setHeader('Content-Type', $generator->getMediaType('Greeting')); diff --git a/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php b/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php index f2d0acfb1e..7782ff33b6 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Elasticsearch/PriorityRangeAggregationVisitor.php @@ -9,6 +9,9 @@ use Ibexa\Contracts\Elasticsearch\Query\AggregationVisitor; use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter; +/** + * @phpstan-template TRangeAggregation of \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation + */ final class PriorityRangeAggregationVisitor implements AggregationVisitor { public function supports(Aggregation $aggregation, LanguageFilter $languageFilter): bool @@ -17,7 +20,7 @@ public function supports(Aggregation $aggregation, LanguageFilter $languageFilte } /** - * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation + * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation * * @return array> */ diff --git a/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php b/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php index 8f65e1794b..2952020fcd 100644 --- a/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php +++ b/code_samples/search/custom/src/Query/Aggregation/PriorityRangeAggregation.php @@ -7,6 +7,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\LocationAggregation; +/** + * @phpstan-template TValue + * + * @phpstan-extends \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation + */ final class PriorityRangeAggregation extends AbstractRangeAggregation implements LocationAggregation { } diff --git a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php index e33fd56042..4f669dc70f 100644 --- a/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php +++ b/code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php @@ -8,6 +8,9 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\Query\AggregationVisitor; +/** + * @phpstan-template TRangeAggregation of \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation + */ final class PriorityRangeAggregationVisitor implements AggregationVisitor { public function canVisit(Aggregation $aggregation, array $languageFilter): bool @@ -16,7 +19,7 @@ public function canVisit(Aggregation $aggregation, array $languageFilter): bool } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation $aggregation + * @param \App\Query\Aggregation\PriorityRangeAggregation $aggregation */ public function visit( AggregationVisitor $dispatcherVisitor, diff --git a/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php b/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php index 7c10898c57..067f46ee14 100644 --- a/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php +++ b/code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php @@ -22,7 +22,7 @@ public function getIdentifier(): string public function onWorkflowEvent(TransitionEvent $event): void { $metadata = $this->getActionMetadata($event->getWorkflow(), $event->getTransition()); - $message = $metadata['data']['message']; + $message = $metadata['data']['message'] ?? ''; $this->notificationHandler->info( $message, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ad39090a7d..345cd3db12 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -60,12 +60,6 @@ parameters: count: 3 path: code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php - - - message: '#^Parameter \#1 \$messages of method Symfony\\Component\\Console\\Output\\OutputInterface\:\:writeln\(\) expects iterable\\|string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: code_samples/api/public_php_api/src/Command/FilterLocationCommand.php - - message: '#^Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\URL\:\:\$url\.$#' identifier: property.protected @@ -288,12 +282,6 @@ parameters: count: 1 path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php - - - message: '#^Parameter \#2 \$string of function explode expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php - - message: '#^Method App\\Setting\\Group\\MyGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -744,12 +732,6 @@ parameters: count: 1 path: code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php - - - message: '#^Offset ''data'' might not exist on array\|null\.$#' - identifier: offsetAccess.notFound - count: 1 - path: code_samples/workflow/custom_workflow/src/EventListener/LegalTransitionListener.php - - message: '#^Parameter \#2 \$transition of method Ibexa\\Contracts\\Workflow\\Event\\Action\\AbstractTransitionWorkflowActionListener\:\:getActionMetadata\(\) expects Symfony\\Component\\Workflow\\Transition, Symfony\\Component\\Workflow\\Transition\|null given\.$#' identifier: argument.type From c36c8dff55e20b88b78d4fa5b6b8538ca6908e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 14 Jul 2025 12:37:31 +0200 Subject: [PATCH 14/26] Adjusted code samples inclusion --- docs/ai_actions/extend_ai_actions.md | 2 +- docs/api/php_api/php_api.md | 2 +- .../content_api/browsing_content.md | 10 ++--- .../content_api/creating_content.md | 22 +++++------ .../content_api/managing_content.md | 34 ++++++++--------- .../content_management_api/bookmark_api.md | 6 +-- .../object_state_api.md | 8 ++-- .../content_management_api/section_api.md | 8 ++-- docs/content_management/forms/form_api.md | 8 ++-- .../taxonomy/taxonomy_api.md | 10 ++--- .../url_management/url_api.md | 4 +- .../workflow/workflow_api.md | 8 ++-- docs/multisite/languages/language_api.md | 4 +- docs/search/search_api.md | 38 +++++++++---------- docs/users/oauth_client.md | 6 +-- docs/users/segment_api.md | 12 +++--- 16 files changed, 91 insertions(+), 91 deletions(-) diff --git a/docs/ai_actions/extend_ai_actions.md b/docs/ai_actions/extend_ai_actions.md index b07ed511bb..71c697b145 100644 --- a/docs/ai_actions/extend_ai_actions.md +++ b/docs/ai_actions/extend_ai_actions.md @@ -14,7 +14,7 @@ For example, you can create a handler that connects to a translation model and u You can execute AI Actions by using the [ActionServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionServiceInterface.html) service, as in the following example: ``` php -[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 105, 124) =]] +[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 104, 131) =]] ``` The `GenerateAltTextAction` is a built-in action that implements the [ActionInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html), takes an [Image](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-Action-DataType-Image.html) as an input, and generates the alternative text in the response. diff --git a/docs/api/php_api/php_api.md b/docs/api/php_api/php_api.md index c194d34865..c4917c04d8 100644 --- a/docs/api/php_api/php_api.md +++ b/docs/api/php_api/php_api.md @@ -126,7 +126,7 @@ While [using `sudo()`](#using-sudo) is the recommended option, you can also set To identify as a different user, you need to use the `UserService` together with `PermissionResolver` (in the example `admin` is the login of the administrator user): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 55, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 40, 41) =]] ``` !!! tip diff --git a/docs/content_management/content_api/browsing_content.md b/docs/content_management/content_api/browsing_content.md index 03fcbcd953..5636fa90e8 100644 --- a/docs/content_management/content_api/browsing_content.md +++ b/docs/content_management/content_api/browsing_content.md @@ -25,16 +25,16 @@ This value object provides primitive fields, such as `contentTypeId`, `published You can also use it to request other Content-related value objects from various services: -``` php hl_lines="10" +``` php hl_lines="8" // ... [[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 4, 5) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 20, 22) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 18, 22) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 55, 57) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 63, 72) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 44, 46) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 54, 65) =]] ``` -`ContentInfo` is loaded from the [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html) (line 9). +`ContentInfo` is loaded from the [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html) (line 8). It provides you with basic content metadata such as modification and publication dates or main language code. !!! note "Retrieving content information in a controller" @@ -46,7 +46,7 @@ It provides you with basic content metadata such as modification and publication To get the locations of a content item you need to make use of the [`LocationService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 73, 77) =]] } +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 55, 61) =]] ``` [`LocationService::loadLocations`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_loadLocations) uses `ContentInfo` to get all the locations of a content item. diff --git a/docs/content_management/content_api/creating_content.md b/docs/content_management/content_api/creating_content.md index 7f8997a167..7cd1df6a04 100644 --- a/docs/content_management/content_api/creating_content.md +++ b/docs/content_management/content_api/creating_content.md @@ -20,18 +20,18 @@ Value objects such as content items are read-only, so to create or modify them y [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) returns a new [`ContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentCreateStruct.html) object. -``` php hl_lines="2-3 5" -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 62, 71) =]] +``` php hl_lines="1-2 6" +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 47, 53) =]] ``` -This command creates a draft using [`ContentService::createContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_createContent) (line 7). +This command creates a draft using [`ContentService::createContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_createContent) (line 6). This method must receive a `ContentCreateStruct` and an array of location structs. -`ContentCreateStruct` (which extends `ContentStruct`) is created through [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) (line 2), +`ContentCreateStruct` (which extends `ContentStruct`) is created through [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) (line 1), which receives the content type and the primary language for the content item. For information about translating a content item into other languages, see [Translating content](#translating-content). -[`ContentStruct::setField`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentStruct.html#method_setField) (line 3) enables you to define the field values. +[`ContentStruct::setField`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentStruct.html#method_setField) (line 2) enables you to define the field values. When the field accepts a simple value, you can provide it directly, as in the example above. For some field types, for example [images](#creating-an-image), you need to provide an instance of a Value type. @@ -42,7 +42,7 @@ Therefore, when creating a content item of the Image type (or any other content the `ContentCreateStruct` is slightly more complex than in the previous example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateImageCommand.php', 61, 74) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateImageCommand.php', 47, 62) =]] ``` Value of the Image field type contains the path to the image file and other basic information based on the input file. @@ -66,7 +66,7 @@ To publish it, use [`ContentService::publishVersion`](/api/php_api/php_api_refer This method must get the [`VersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-VersionInfo.html) object of a draft version. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 73, 74) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 58, 59) =]] ``` ## Updating content @@ -76,7 +76,7 @@ and pass it to [`ContentService::updateContent`](/api/php_api/php_api_reference/ This method works on a draft, so to publish your changes you need to use [`ContentService::publishVersion`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_publishVersion) as well: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/UpdateContentCommand.php', 52, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/UpdateContentCommand.php', 45, 50) =]] ``` ## Translating content @@ -86,15 +86,15 @@ Content [translations](languages.md#language-versions) are created per version. To translate a content item to a new language, you need to update it and provide a new `initialLanguageCode`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 57, 62) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 67, 69) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 50, 52) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 58, 60) =]] ``` You can also update content in multiple languages at once using the `setField` method's third argument. Only one language can still be set as a version's initial language: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 64, 65) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 55, 55) =]] ``` ### Deleting a translation diff --git a/docs/content_management/content_api/managing_content.md b/docs/content_management/content_api/managing_content.md index 858c023f52..bf6e22dfc4 100644 --- a/docs/content_management/content_api/managing_content.md +++ b/docs/content_management/content_api/managing_content.md @@ -22,8 +22,8 @@ Creating a new location, like creating content, requires using a struct, because To add a new location to existing content you need to create a [`LocationCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationCreateStruct.html) and pass it to the [`LocationService::createLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_createLocation) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 55, 56) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 60, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 43, 43) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 48, 49) =]] ``` `LocationCreateStruct` must receive the parent location ID. @@ -32,7 +32,7 @@ It sets the `parentLocationId` property of the new location. You can also provide other properties for the location, otherwise they're set to their defaults: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 57, 59) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 45, 46) =]] ``` ### Changing the main location @@ -41,7 +41,7 @@ When a content item has more that one location, one location is always considere You can change the main location using [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html), by updating the `ContentInfo` with a [`ContentUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentUpdateStruct.html) that sets the new main location: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 53, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 44, 47) =]] ``` ### Hiding and revealing locations @@ -49,7 +49,7 @@ You can change the main location using [`ContentService`](/api/php_api/php_api_r To hide or reveal (unhide) a location you need to make use of [`LocationService::hideLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_hideLocation) or [`LocationService::unhideLocation`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_unhideLocation) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 51, 52) =]][[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 54, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 42, 42) =]][[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 45, 45) =]] ``` See [location visibility](locations.md#location-visibility) for detailed information on the behavior of visible and hidden Locations. @@ -66,14 +66,14 @@ Content which has more locations is still available in its other locations. If you delete the [main location](#changing-the-main-location) of a content item that has more locations, another location becomes the main one. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 49, 50) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 40, 40) =]] ``` To send the location and its subtree to Trash, use [`TrashService::trash`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-TrashService.html#method_trash). Items in Trash can be later [restored, or deleted permanently](#trash). ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 59, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 47, 47) =]] ``` ### Moving and copying a subtree @@ -81,7 +81,7 @@ Items in Trash can be later [restored, or deleted permanently](#trash). You can move a location with its whole subtree using [`LocationService::moveSubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_moveSubtree): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 51, 54) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 42, 44) =]] ``` [`LocationService::copySubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_copySubtree) is used in the same way, but it copies the location and its subtree instead of moving it. @@ -108,7 +108,7 @@ You must provide the method with the ID of the object in Trash. Trash location is identical to the origin location of the object. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 69, 70) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 56, 57) =]] ``` The content item is restored under its previous location. @@ -138,13 +138,13 @@ In this case you use [`ContentTypeCreateStruct`](/api/php_api/php_api_reference/ A content type must have at least one name, in the main language, and at least one field definition. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 64, 74) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 81, 90) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 55, 62) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 74, 79) =]] ``` You can specify more details of the field definition in the create struct, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 72, 82) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 63, 72) =]] ``` ### Copying content types @@ -152,7 +152,7 @@ You can specify more details of the field definition in the create struct, for e To copy a content type, use [`ContentTypeService::copyContentType`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentTypeService.html#method_copyContentType): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 94, 95) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 83, 85) =]] ``` The copy is automatically getting an identifier based on the original content type identifier and the copy's ID, for example: `copy_of_folder_21`. @@ -160,7 +160,7 @@ The copy is automatically getting an identifier based on the original content ty To change the identifier of the copy, use a [`ContentTypeUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-ContentTypeUpdateStruct.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 95, 101) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 86, 91) =]] ``` ## Calendar events @@ -177,19 +177,19 @@ To get a list of events for a specified time period, use the `CalendarServiceInt You need to provide the method with an EventQuery, which takes a date range and a count as the minimum of parameters: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 44, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 35, 45) =]] ``` You can also get the first and last event in the list by using the `first()` and `last()` methods of an `EventCollection` (`Ibexa\Contracts\Calendar\EventCollection`): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 56, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 47, 48) =]] ``` You can process the events in a collection using the `find(Closure $predicate)`, `filter(Closure $predicate)`, `map(Closure $callback)` or `slice(int $offset, ?int $length = null)` methods of `EventCollection`, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 59, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 50, 53) =]] ``` ### Performing calendar actions @@ -199,7 +199,7 @@ You must pass an `Ibexa\Contracts\Calendar\EventAction\EventActionContext` insta `EventActionContext` defines events on which the action is performed, and action-specific parameters, for example, a new date: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 64, 66) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 55, 58) =]] ``` ``` php diff --git a/docs/content_management/content_management_api/bookmark_api.md b/docs/content_management/content_management_api/bookmark_api.md index 63f5ba6176..8f57d51d51 100644 --- a/docs/content_management/content_management_api/bookmark_api.md +++ b/docs/content_management/content_management_api/bookmark_api.md @@ -13,17 +13,17 @@ description: You can use the PHP API to view the bookmark list, and add or remov To view a list of all bookmarks, use [`BookmarkService::loadBookmarks`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_loadBookmarks): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 48, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 42, 48) =]] ``` You can add a bookmark to a content item by providing its Location object to the [`BookmarkService::createBookmark`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_createBookmark) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 42, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 38, 40) =]] ``` You can remove a bookmark from a location with [`BookmarkService::deleteBookmark`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-BookmarkService.html#method_deleteBookmark): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 57, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BookmarkCommand.php', 51, 51) =]] ``` diff --git a/docs/content_management/content_management_api/object_state_api.md b/docs/content_management/content_management_api/object_state_api.md index 8d907897cf..7f65271c04 100644 --- a/docs/content_management/content_management_api/object_state_api.md +++ b/docs/content_management/content_management_api/object_state_api.md @@ -18,7 +18,7 @@ You can manage Object states by using the PHP API by using `ObjectStateService`. You can use the [`ObjectStateService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html) to get information about object state groups or object states. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 48, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 41, 46) =]] ``` ## Creating object states @@ -26,7 +26,7 @@ You can use the [`ObjectStateService`](/api/php_api/php_api_reference/classes/Ib To create an object state group and add object states to it, you need to make use of the [`ObjectStateService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 57, 61) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 50, 54) =]] ``` [`ObjectStateService::createObjectStateGroup`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_createObjectStateGroup) takes as argument an [`ObjectStateGroupCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ObjectState-ObjectStateGroupCreateStruct.html), in which you need to specify the identifier, default language and at least one name for the group. @@ -34,7 +34,7 @@ To create an object state group and add object states to it, you need to make us To create an object state inside a group, use [`ObjectStateService::newObjectStateCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_newObjectStateCreateStruct) and provide it with an `ObjectStateCreateStruct`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 63, 67) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 56, 60) =]] ``` ## Assigning object state @@ -43,5 +43,5 @@ To assign an object state to a content item, use [`ObjectStateService::setConten Provide it with a `ContentInfo` object of the content item, the object state group and the object state: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 77, 82) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ObjectStateCommand.php', 71, 75) =]] ``` diff --git a/docs/content_management/content_management_api/section_api.md b/docs/content_management/content_management_api/section_api.md index fff9973e03..f93c0760f2 100644 --- a/docs/content_management/content_management_api/section_api.md +++ b/docs/content_management/content_management_api/section_api.md @@ -17,7 +17,7 @@ You can manage sections by using the PHP API by using `SectionService`. To create a new section, you need to make use of the [`SectionCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-SectionCreateStruct.html) and pass it to the [`SectionService::createSection`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SectionService.html#method_createSection) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 58, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 48, 52) =]] ``` ## Getting section information @@ -25,7 +25,7 @@ To create a new section, you need to make use of the [`SectionCreateStruct`](/ap You can use `SectionService` to retrieve section information such as whether it's in use: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 76, 81) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 66, 71) =]] ``` ## Listing content in a section @@ -34,7 +34,7 @@ To list content items assigned to a section you need to make a [query](search_ap You can also use the query to get the total number of assigned content items: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 69, 75) =]][[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 82, 86) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 59, 65) =]][[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 72, 76) =]] ``` ## Assigning section to content @@ -43,7 +43,7 @@ To assign content to a section, use the [`SectionService::assignSection`](/api/p You need to provide it with the `ContentInfo` object of the content item, and the [`Section`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Section.html) object: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 64, 67) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SectionCommand.php', 54, 57) =]] ``` Assigning a section to content doesn't automatically assign it to the content item's children. diff --git a/docs/content_management/forms/form_api.md b/docs/content_management/forms/form_api.md index c0c9930445..925f089962 100644 --- a/docs/content_management/forms/form_api.md +++ b/docs/content_management/forms/form_api.md @@ -14,13 +14,13 @@ To manage form submissions created in the [Form Builder](form_builder_guide.md), To get existing form submissions, use `FormSubmissionServiceInterface::loadByContent()` (which takes a `ContentInfo` object as parameter), or `FormSubmissionServiceInterface::loadById()`. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 54, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 46, 46) =]] ``` Through this object, you can get information about submissions, such as their total number, and submission contents. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 55, 66) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 48, 56) =]] ``` ### Creating form submissions @@ -35,7 +35,7 @@ This method takes: - the array of form field values ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 40, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 32, 44) =]] ``` ### Deleting form submissions @@ -43,5 +43,5 @@ This method takes: You can delete a form submission by using the `FormSubmissionServiceInterface::delete()` method. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 66, 68) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php', 58, 59) =]] ``` diff --git a/docs/content_management/taxonomy/taxonomy_api.md b/docs/content_management/taxonomy/taxonomy_api.md index 3a46b2322f..aa5f85e69c 100644 --- a/docs/content_management/taxonomy/taxonomy_api.md +++ b/docs/content_management/taxonomy/taxonomy_api.md @@ -14,7 +14,7 @@ Or pass entry identifier (with optionally a taxonomy identifier), and use `TaxonomyServiceInterface::loadEntryByIdentifier()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 43, 46) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 35, 37) =]] ``` !!! note @@ -37,7 +37,7 @@ The default taxonomy identifier is given by `TaxonomyConfiguration::getDefaultTa The default limit is 30. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 41, 42) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 33, 33) =]] ``` To see how many entries is there, use `TaxonomyServiceInterface::countAllEntries()` with optionally a taxonomy identifier. @@ -47,7 +47,7 @@ provide it with the entry object, and optionally specify the limit of results an The default limit is 30: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 48, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 40, 44) =]] ``` ## Managing taxonomy entries @@ -56,7 +56,7 @@ You can move a taxonomy entry to a different parent by using `TaxonomyServiceInt Provide the method with two objects: the entry that you want to move and the new parent entry: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 54, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 46, 49) =]] ``` You can also move a taxonomy entry by passing its target sibling entry to `TaxonomyServiceInterface::moveEntry()`. @@ -64,7 +64,7 @@ The method takes as parameters the entry you want to move, the future sibling, and a `position` parameter, which is either `TaxonomyServiceInterface::MOVE_POSITION_NEXT` or `TaxonomyServiceInterface::MOVE_POSITION_PREV`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 59, 61) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TaxonomyCommand.php', 51, 52) =]] ``` !!! note diff --git a/docs/content_management/url_management/url_api.md b/docs/content_management/url_management/url_api.md index 94d93a1476..cc8188c003 100644 --- a/docs/content_management/url_management/url_api.md +++ b/docs/content_management/url_management/url_api.md @@ -19,9 +19,9 @@ in which you need to specify: ```php // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 7, 10) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 6, 10) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 41, 56) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindUrlCommand.php', 32, 51) =]] ``` ## URL search reference diff --git a/docs/content_management/workflow/workflow_api.md b/docs/content_management/workflow/workflow_api.md index d6c46a6975..157d436373 100644 --- a/docs/content_management/workflow/workflow_api.md +++ b/docs/content_management/workflow/workflow_api.md @@ -25,7 +25,7 @@ but the implementation in workflow service extends them, for example by providin To get information about a specific workflow for a content item, use `WorkflowServiceInterface::loadWorkflowMetadataForContent`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 58, 63) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 49, 53) =]] ``` !!! tip @@ -36,7 +36,7 @@ To get information about a specific workflow for a content item, use `WorkflowSe To get a list of all workflows that can be used for a given content item, use `WorkflowRegistry`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 52, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 43, 46) =]] ``` ## Applying workflow transitions @@ -44,14 +44,14 @@ To get a list of all workflows that can be used for a given content item, use `W To place a content item in a workflow, use `WorkflowService::start`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 57, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 48, 48) =]] ``` To apply a transition to a content item, use `Workflow::apply`. Additionally, you can check if the transition is possible for the given object using `WorkflowService::can`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 64, 69) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/WorkflowCommand.php', 55, 59) =]] ``` !!! tip diff --git a/docs/multisite/languages/language_api.md b/docs/multisite/languages/language_api.md index 7b5f850fcc..1380ec1cd9 100644 --- a/docs/multisite/languages/language_api.md +++ b/docs/multisite/languages/language_api.md @@ -11,7 +11,7 @@ You can manage languages configured in the system with PHP API by using [`Langua To get a list of all languages in the system use [`LanguageService::loadLanguages`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_loadLanguage) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 42, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 29, 33) =]] ``` ## Creating a language @@ -20,5 +20,5 @@ To create a new language, you need to create a [`LanguageCreateStruct`](/api/php Then, use [`LanguageService::createLanguage`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_createLanguage) and pass the `LanguageCreateStruct` to it: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 48, 52) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 35, 39) =]] ``` diff --git a/docs/search/search_api.md b/docs/search/search_api.md index 47238e952d..de1c1bca69 100644 --- a/docs/search/search_api.md +++ b/docs/search/search_api.md @@ -22,18 +22,18 @@ The service should be [injected into the constructor of your command or controll To search through content you need to create a [`LocationQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationQuery.html) and provide your Search Criteria as a series of Criterion objects. -For example, to search for all content of a selected content type, use one Criterion, [`Criterion\ContentTypeIdentifier`](contenttypeidentifier_criterion.md) (line 14). +For example, to search for all content of a selected content type, use one Criterion, [`Criterion\ContentTypeIdentifier`](contenttypeidentifier_criterion.md) (line 12). The following command takes the content type identifier as an argument and lists all results: -``` php hl_lines="14 16" +``` php hl_lines="12 14" // ... [[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 4, 7) =]]// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 16, 18) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 36, 52) =]]} +[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 14, 18) =]] // ... +[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 37, 45) =]]} ``` -[`SearchService::findContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContentInfo) (line 16) +[`SearchService::findContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContentInfo) (line 14) retrieves [`ContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Persistence-Content-ContentInfo.html) objects of the found content items. You can also use [`SearchService::findContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContent) to get full Content objects, together with their field information. @@ -116,19 +116,19 @@ It doesn't use the `SearchService` and isn't based on indexed data. For example, the following command lists all content items under the specified parent location and sorts them by name in descending order: -``` php hl_lines="13-16" +``` php hl_lines="11-14" // ... [[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 4, 9) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 37, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 38, 49) =]] ``` The same Filter can be applied to find locations instead of content items, for example: -``` php hl_lines="17" +``` php hl_lines="15" // ... [[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 4, 9) =]]// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 37, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 38, 49) =]] ``` !!! caution @@ -238,8 +238,8 @@ For more complex searches, you need to combine multiple Criteria. You can do it using logical operators: `LogicalAnd`, `LogicalOr`, and `LogicalNot`. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 48, 54) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 58, 59) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 65, 70) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 45, 48) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 59, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 60, 63) =]] ``` This example takes three parameters from a command — `$text`, `$contentTypeId`, and `$locationId`. @@ -253,7 +253,7 @@ The example below uses the `LogicalNot` operator to search for all content conta that doesn't belong to the provided Section: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 50, 51) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 53, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 47, 47) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 49, 52) =]] ``` ### Combining independent Criteria @@ -286,7 +286,7 @@ To sort the results of a query, use one of more [Sort Clauses](sort_clause_refer For example, to order search results by their publicationg date, from oldest to newest, and then alphabetically by content name, add the following Sort Clauses to the query: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 60, 64) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 54, 57) =]] ``` !!! tip @@ -305,7 +305,7 @@ For a list of supported Criteria and Sort Clauses, see [Search in trash referenc Searching through the trashed content items operates directly on the database, therefore you cannot use external search engines, such as Solr or Elasticsearch, and it's impossible to reindex the data. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 39, 46) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 38, 42) =]] ``` !!! caution @@ -324,7 +324,7 @@ With aggregations you can find the count of search results or other result infor To do this, you use of the query's `$aggregations` property: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 39, 44) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 35) =]] ``` The name of the aggregation must be unique in the given query. @@ -332,13 +332,13 @@ The name of the aggregation must be unique in the given query. Access the results by using the `get()` method of the aggregation: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 48, 49) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 40, 41) =]] ``` Aggregation results contain the name of the result and the count of found items: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 51, 54) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 43, 45) =]] ``` With field aggregations you can group search results according to the value of a specific field. @@ -347,14 +347,14 @@ In this case the aggregation takes the content type identifier and the field ide The following example creates an aggregation named `selection` that groups results according to the value of the `topic` field in the `article` content type: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 44, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 36, 36) =]] ``` With term aggregation you can define additional limits to the results. The following example limits the number of terms returned to 5 and only considers terms that have 10 or more results: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 39, 42) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 33) =]] ``` To use a range aggregation, you must provide a `ranges` array containing a set of `Range` objects that define the borders of the specific range sets. diff --git a/docs/users/oauth_client.md b/docs/users/oauth_client.md index 47e741d2e5..393f0f0039 100644 --- a/docs/users/oauth_client.md +++ b/docs/users/oauth_client.md @@ -84,11 +84,11 @@ The following example shows how to create a Resource Owner mapper for the `googl Create a resource owner mapper for Google login in `src/OAuth/GoogleResourceOwnerMapper.php`. The mapper extends `ResourceOwnerToExistingOrNewUserMapper`, which enables it to create a new user in the repository if the user doesn't exist yet. -The mapper loads a user (line 51) or creates a new one (line 61), based on the information from `resourceOwner`, that's the OAuth2 authorization server. +The mapper loads a user (line 40) or creates a new one (line 49), based on the information from `resourceOwner`, that's the OAuth2 authorization server. -The new username is set with a `google:` prefix (lines 19, 109), to avoid conflicts with users registered in a regular way. +The new username is set with a `google:` prefix (lines 20, 91), to avoid conflicts with users registered in a regular way. -``` php hl_lines="20 54 64 109" +``` php hl_lines="20 40 67 91" [[= include_file('code_samples/user_management/oauth_google/src/OAuth/GoogleResourceOwnerMapper.php') =]] ``` diff --git a/docs/users/segment_api.md b/docs/users/segment_api.md index a025b2ebe7..749aecd82f 100644 --- a/docs/users/segment_api.md +++ b/docs/users/segment_api.md @@ -15,13 +15,13 @@ To load a segment group, use `SegmentationService::loadSegmentGroupByIdentifier( Get all segments assigned to the group with `SegmentationService::loadSegmentsAssignedToGroup()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 54, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 46, 52) =]] ``` Similarly, you can load a segment by using `SegmentationService::loadSegmentByIdentifier()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 62, 63) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 54, 54) =]] ``` ## Checking assignment @@ -29,7 +29,7 @@ Similarly, you can load a segment by using `SegmentationService::loadSegmentById You can check whether a user is assigned to a segment with `SegmentationService::isUserAssignedToSegment()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 66, 71) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 58, 62) =]] ``` ## Assigning users @@ -37,7 +37,7 @@ You can check whether a user is assigned to a segment with `SegmentationService: To assign a user to a segment, use `SegmentationService::assignUserToSegment()`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 64, 65) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 56, 56) =]] ``` ## Creating segments @@ -47,13 +47,13 @@ Each segment must be assigned to a segment group. To create a segment group, use `SegmentationService::createSegmentGroup()` and provide it with a `SegmentGroupCreateStruct`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 38, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 30, 36) =]] ``` To add a segment, use `SegmentationService::createSegment()` and provide it with a `SegmentCreateStruct`, which takes an existing group as one of the parameters: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 46, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SegmentCommand.php', 38, 44) =]] ``` ## Updating segments From 8097d7025b01f24017e3e8d7ec1123525ff6889c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 14 Jul 2025 15:34:21 +0200 Subject: [PATCH 15/26] More fixes --- docs/ai_actions/extend_ai_actions.md | 12 +++--- docs/commerce/cart/cart_api.md | 39 +++++++++---------- .../order_management/order_management_api.md | 10 ++--- docs/commerce/payment/extend_payment.md | 4 +- docs/commerce/payment/payment_api.md | 13 +++---- docs/commerce/payment/payment_method_api.md | 14 +++---- .../content_api/managing_content.md | 35 ++++++++--------- docs/multisite/languages/language_api.md | 4 +- 8 files changed, 62 insertions(+), 69 deletions(-) diff --git a/docs/ai_actions/extend_ai_actions.md b/docs/ai_actions/extend_ai_actions.md index 71c697b145..81668a7074 100644 --- a/docs/ai_actions/extend_ai_actions.md +++ b/docs/ai_actions/extend_ai_actions.md @@ -14,7 +14,7 @@ For example, you can create a handler that connects to a translation model and u You can execute AI Actions by using the [ActionServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionServiceInterface.html) service, as in the following example: ``` php -[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 104, 131) =]] +[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 86, 105) =]] ``` The `GenerateAltTextAction` is a built-in action that implements the [ActionInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html), takes an [Image](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-Action-DataType-Image.html) as an input, and generates the alternative text in the response. @@ -43,7 +43,7 @@ You can influence the execution of an Action with two events: Below you can find the full example of a Symfony Command, together with a matching service definition. The command finds the images modified in the last 24 hours, and adds the alternative text to them if it's missing. -``` php hl_lines="91 104-129" +``` php hl_lines="72 85-110" [[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php') =]] ``` @@ -77,7 +77,7 @@ See [Action Configuration Search Criteria reference](action_configuration_criter The following example creates a new Action Configuration: ``` php hl_lines="3 17" -[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 62, 79) =]] +[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 46, 63) =]] ``` Actions Configurations are tied to a specific Action Type and are translatable. @@ -88,7 +88,7 @@ Reuse existing Action Configurations to simplify the execution of AI Actions. You can pass one directly to the `ActionServiceInterface::execute()` method: ``` php hl_lines="7-8" -[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 80, 88) =]] +[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 64, 72) =]] ``` The passed Action Configuration is only taken into account if the Action Context was not passed to the Action directly using the [ActionInterface::setActionContext()](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html#method_hasActionContext) method. @@ -116,7 +116,7 @@ Create a class implementing the [ActionHandlerInterface](/api/php_api/php_api_re See the code sample below, together with a matching service definition: -``` php hl_lines="21 29-32 34-69 71-74" +``` php hl_lines="17 23-26 28-63 65-68" [[= include_file('code_samples/ai_actions/src/AI/Handler/LLaVaTextToTextActionHandler.php') =]] ``` @@ -233,7 +233,7 @@ An example Action Handler combines the input data and the Action Type options an The language of the transcribed data is extracted from the Runtime Context for better results. The Action Type options provided in the Action Context dictate whether the timestamps will be removed before returning the result. -``` php hl_lines="34-37 52-55" +``` php hl_lines="66-68 52-55" [[= include_file('code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php') =]] ``` diff --git a/docs/commerce/cart/cart_api.md b/docs/commerce/cart/cart_api.md index 0d6855db34..d8208d737a 100644 --- a/docs/commerce/cart/cart_api.md +++ b/docs/commerce/cart/cart_api.md @@ -23,7 +23,7 @@ From the developer's perspective, carts and entries are referenced with a UUID i To access a single cart, use the `CartServiceInterface::getCart` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 91) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 66) =]] ``` ## Get multiple carts @@ -35,7 +35,7 @@ It follows the same search Query pattern as other APIs: [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 10, 11) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 74, 83) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 49, 57) =]] ``` ## Create cart @@ -46,7 +46,7 @@ To create a cart, use the `CartServiceInterface::createCart` method and provide [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 8, 9) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 95, 104) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 70, 78) =]] ``` ## Update cart metadata @@ -59,7 +59,7 @@ To update cart metadata, use the `CartServiceInterface::updateCartMetadata` meth [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 9, 10) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 114) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 82, 89) =]] ``` You can also use this method to change cart ownership: @@ -80,8 +80,8 @@ $cart = $cartService->updateCartMetadata($cart, $updateMetadataStruct); To delete a cart permanently, use the `CartServiceInterface::deleteCart` method and pass the `CartInterface` object: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 149, 150) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 125) =]] ``` ## Empty cart @@ -89,8 +89,8 @@ To delete a cart permanently, use the `CartServiceInterface::deleteCart` method To remove all products from the cart in a single operation, use the `CartServiceInterface::emptyCart` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 116, 117) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 91, 92) =]] ``` ## Check cart validity @@ -101,8 +101,8 @@ To validate the cart, use the `CartServiceInterface::validateCart` method. Validation is done with help from the `symfony/validator` component, and the method returns a `Symfony\Component\Validator\ConstraintViolationListInterface` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 119, 120) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 94, 95) =]] ``` ## Add entry to cart @@ -114,8 +114,8 @@ Then pass it to the `CartServiceInterface::addEntry` method: [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 131) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 99, 106) =]] ``` ## Remove entry from cart @@ -123,11 +123,8 @@ Then pass it to the `CartServiceInterface::addEntry` method: To remove an entry from the cart, use the `CartServiceInterface::removeEntry` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]] -// ... - -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 134, 137) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 112) =]] ``` ## Update entry metadata @@ -139,9 +136,9 @@ To change entry metadata, use the `CartServiceInterface::updateEntry` method and [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 88, 89) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 129, 130) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 139, 147) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 110) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 114, 122) =]] ``` ## Adding context data @@ -188,5 +185,5 @@ To combine the contents of multiple shopping carts into a target cart, use the ` This operation is helpful when you want to consolidate items from a reorder cart and a current cart into a single order. ```php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 151, 164) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 126, 139) =]] ``` diff --git a/docs/commerce/order_management/order_management_api.md b/docs/commerce/order_management/order_management_api.md index 9fc9bd0f4f..640221200f 100644 --- a/docs/commerce/order_management/order_management_api.md +++ b/docs/commerce/order_management/order_management_api.md @@ -19,7 +19,7 @@ To get orders and manage them, use the [`Ibexa\Contracts\OrderManagement\OrderSe To access a single order by using its string identifier, use the [`OrderServiceInterface::getOrderByIdentifier`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrderByIdentifier) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 61, 65) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 51, 55) =]] ``` ### Get single order by ID @@ -27,7 +27,7 @@ To access a single order by using its string identifier, use the [`OrderServiceI To access a single order by using its numerical ID, use the [`OrderServiceInterface::getOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrder) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 67, 72) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 57, 61) =]] ``` ## Get multiple orders @@ -39,7 +39,7 @@ It follows the same search query pattern as other APIs: [[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 8, 9) =]][[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 10, 14) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 120, 130) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 110, 119) =]] ``` ## Create order @@ -47,7 +47,7 @@ It follows the same search query pattern as other APIs: To create an order, use the [`OrderServiceInterface::createOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_createOrder) method and provide it with the [`Ibexa\Contracts\OrderManagement\Value\Struct\OrderCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-Value-Struct-OrderCreateStruct.html) object that contains a list of products, purchased quantities, product, total prices, and tax amounts. ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 101, 113) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 91, 102) =]] ``` ## Update order @@ -57,5 +57,5 @@ You could do it to support a scenario when, for example, the order is processed To update order information, use the [`OrderServiceInterface::updateOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_updateOrder) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 114, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 108) =]] ``` diff --git a/docs/commerce/payment/extend_payment.md b/docs/commerce/payment/extend_payment.md index feb410f7a7..76f1ce9b3a 100644 --- a/docs/commerce/payment/extend_payment.md +++ b/docs/commerce/payment/extend_payment.md @@ -94,11 +94,11 @@ When you create a payment, you can attach custom data to it, for example, you ca You add custom data by using the `setContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 97, 109) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 80, 91) =]] ``` Then, you retrieve it with the `getContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 70, 74) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 58) =]] ``` diff --git a/docs/commerce/payment/payment_api.md b/docs/commerce/payment/payment_api.md index 93d416df7f..96a6850814 100644 --- a/docs/commerce/payment/payment_api.md +++ b/docs/commerce/payment/payment_api.md @@ -17,7 +17,7 @@ You can change that by providing a custom payment identifier in `Ibexa\Contracts To access a single payment by using its numerical ID, use the `PaymentServiceInterface::getPayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 64, 68) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 52) =]] ``` ### Get single payment by identifier @@ -25,7 +25,7 @@ To access a single payment by using its numerical ID, use the `PaymentServiceInt To access a single payment by using its string identifier, use the `PaymentServiceInterface::getPaymentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 70, 72) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 56) =]] ``` ## Get multiple payments @@ -34,7 +34,7 @@ To fetch multiple payments, use the `PaymentServiceInterface::findPayments` meth It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 79, 95) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 63, 79) =]] ``` ## Create payment @@ -42,8 +42,7 @@ It follows the same search query pattern as other APIs: To create a payment, use the `PaymentServiceInterface::createPayment` method and provide it with the `Ibexa\Contracts\Payment\Payment\PaymentCreateStruct` object that takes the following arguments: `method`, `order` and `amount`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 101, 105) =]] -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 108, 112) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 95) =]] ``` ## Update payment @@ -54,7 +53,7 @@ The `Ibexa\Contracts\Payment\Payment\PaymentUpdateStruct` object takes the follo To update payment information, use the `PaymentServiceInterface::updatePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 113, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 97, 103) =]] ``` ## Delete payment @@ -62,5 +61,5 @@ To update payment information, use the `PaymentServiceInterface::updatePayment` To delete a payment from the system, use the `PaymentServiceInterface::deletePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 121, 122) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 105, 106) =]] ``` diff --git a/docs/commerce/payment/payment_method_api.md b/docs/commerce/payment/payment_method_api.md index 00856a67aa..61ff2ee38f 100644 --- a/docs/commerce/payment/payment_method_api.md +++ b/docs/commerce/payment/payment_method_api.md @@ -26,7 +26,7 @@ From the developer's perspective, payment methods are referenced with identifier To access a single payment method by using its string identifier, use the `PaymentMethodService::getPaymentMethodByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 56, 60) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 46, 50) =]] ``` ### Get single payment method by ID @@ -34,7 +34,7 @@ To access a single payment method by using its string identifier, use the `Payme To access a single payment method by using its numerical ID, use the `PaymentMethodService::getPaymentMethod` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 54) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 40, 44) =]] ``` ## Get multiple payment methods @@ -44,7 +44,7 @@ To fetch multiple payment methods, use the `PaymentMethodService::findPaymentMet It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 62, 79) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 69) =]] ``` ## Create payment method @@ -59,7 +59,7 @@ To create a payment method, use the `PaymentMethodService::createPaymentMethod` - `options` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 62, 63) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 81, 91) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 53) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 71, 81) =]] ``` ## Update payment method @@ -70,14 +70,14 @@ An `Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodUpdateStruct` object can To update payment method information, use the `PaymentMethodServiceInterface::updatePaymentMethod` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 93, 103) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 83, 93) =]] ``` ## Delete payment method To delete a payment method from the system, use the `PaymentMethodService::deletePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 105, 111) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 95, 101) =]] ``` ## Check whether payment method is used @@ -85,5 +85,5 @@ To delete a payment method from the system, use the `PaymentMethodService::delet To check whether a payment method is used, for example, before you delete it, use the `PaymentMethodService::isPaymentMethodUsed` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 113, 126) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 103, 116) =]] ``` diff --git a/docs/content_management/content_api/managing_content.md b/docs/content_management/content_api/managing_content.md index bf6e22dfc4..7f0cea4010 100644 --- a/docs/content_management/content_api/managing_content.md +++ b/docs/content_management/content_api/managing_content.md @@ -22,8 +22,8 @@ Creating a new location, like creating content, requires using a struct, because To add a new location to existing content you need to create a [`LocationCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationCreateStruct.html) and pass it to the [`LocationService::createLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_createLocation) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 43, 43) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 48, 49) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 42, 43) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 47, 49) =]] ``` `LocationCreateStruct` must receive the parent location ID. @@ -32,7 +32,7 @@ It sets the `parentLocationId` property of the new location. You can also provide other properties for the location, otherwise they're set to their defaults: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 45, 46) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 44, 46) =]] ``` ### Changing the main location @@ -41,7 +41,7 @@ When a content item has more that one location, one location is always considere You can change the main location using [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html), by updating the `ContentInfo` with a [`ContentUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentUpdateStruct.html) that sets the new main location: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 44, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 43, 47) =]] ``` ### Hiding and revealing locations @@ -49,7 +49,7 @@ You can change the main location using [`ContentService`](/api/php_api/php_api_r To hide or reveal (unhide) a location you need to make use of [`LocationService::hideLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_hideLocation) or [`LocationService::unhideLocation`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_unhideLocation) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 42, 42) =]][[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 45, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 41, 42) =]][[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 44, 45) =]] ``` See [location visibility](locations.md#location-visibility) for detailed information on the behavior of visible and hidden Locations. @@ -66,14 +66,14 @@ Content which has more locations is still available in its other locations. If you delete the [main location](#changing-the-main-location) of a content item that has more locations, another location becomes the main one. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 40, 40) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 39, 40) =]] ``` To send the location and its subtree to Trash, use [`TrashService::trash`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-TrashService.html#method_trash). Items in Trash can be later [restored, or deleted permanently](#trash). ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 47, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 46, 47) =]] ``` ### Moving and copying a subtree @@ -81,7 +81,7 @@ Items in Trash can be later [restored, or deleted permanently](#trash). You can move a location with its whole subtree using [`LocationService::moveSubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_moveSubtree): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 42, 44) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 41, 44) =]] ``` [`LocationService::copySubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_copySubtree) is used in the same way, but it copies the location and its subtree instead of moving it. @@ -138,13 +138,14 @@ In this case you use [`ContentTypeCreateStruct`](/api/php_api/php_api_reference/ A content type must have at least one name, in the main language, and at least one field definition. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 55, 62) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 74, 79) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 54, 64) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 71, 80) =]] + ``` You can specify more details of the field definition in the create struct, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 63, 72) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 62, 72) =]] ``` ### Copying content types @@ -160,7 +161,7 @@ The copy is automatically getting an identifier based on the original content ty To change the identifier of the copy, use a [`ContentTypeUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-ContentTypeUpdateStruct.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 86, 91) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 85, 91) =]] ``` ## Calendar events @@ -177,19 +178,19 @@ To get a list of events for a specified time period, use the `CalendarServiceInt You need to provide the method with an EventQuery, which takes a date range and a count as the minimum of parameters: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 35, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 34, 45) =]] ``` You can also get the first and last event in the list by using the `first()` and `last()` methods of an `EventCollection` (`Ibexa\Contracts\Calendar\EventCollection`): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 47, 48) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 46, 48) =]] ``` You can process the events in a collection using the `find(Closure $predicate)`, `filter(Closure $predicate)`, `map(Closure $callback)` or `slice(int $offset, ?int $length = null)` methods of `EventCollection`, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 50, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 49, 53) =]] ``` ### Performing calendar actions @@ -199,9 +200,5 @@ You must pass an `Ibexa\Contracts\Calendar\EventAction\EventActionContext` insta `EventActionContext` defines events on which the action is performed, and action-specific parameters, for example, a new date: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 55, 58) =]] -``` - -``` php -$context = new UnscheduleEventActionContext($eventCollection); +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 54, 58) =]] ``` diff --git a/docs/multisite/languages/language_api.md b/docs/multisite/languages/language_api.md index 1380ec1cd9..3f7105c26a 100644 --- a/docs/multisite/languages/language_api.md +++ b/docs/multisite/languages/language_api.md @@ -11,7 +11,7 @@ You can manage languages configured in the system with PHP API by using [`Langua To get a list of all languages in the system use [`LanguageService::loadLanguages`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_loadLanguage) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 29, 33) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 27, 33) =]] ``` ## Creating a language @@ -20,5 +20,5 @@ To create a new language, you need to create a [`LanguageCreateStruct`](/api/php Then, use [`LanguageService::createLanguage`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_createLanguage) and pass the `LanguageCreateStruct` to it: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 35, 39) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 34, 38) =]] ``` From 353409c367ee03d66156fda6a903fd9b028440ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 14 Jul 2025 15:50:03 +0200 Subject: [PATCH 16/26] Rebuild From 399b01fb5c1fba0d1952a62040d71fed8cdc819e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 14 Jul 2025 17:03:22 +0200 Subject: [PATCH 17/26] More fixes --- docs/ai_actions/extend_ai_actions.md | 2 +- docs/commerce/checkout/checkout_api.md | 10 ++--- docs/commerce/payment/extend_payment.md | 2 +- .../shipping_management/shipment_api.md | 12 +++--- .../shipping_method_api.md | 14 +++---- .../data_migration/data_migration_api.md | 8 ++-- docs/pim/catalog_api.md | 8 ++-- docs/pim/price_api.md | 22 +++++------ docs/pim/product_api.md | 38 +++++++++---------- 9 files changed, 58 insertions(+), 58 deletions(-) diff --git a/docs/ai_actions/extend_ai_actions.md b/docs/ai_actions/extend_ai_actions.md index 81668a7074..e8f575d13f 100644 --- a/docs/ai_actions/extend_ai_actions.md +++ b/docs/ai_actions/extend_ai_actions.md @@ -233,7 +233,7 @@ An example Action Handler combines the input data and the Action Type options an The language of the transcribed data is extracted from the Runtime Context for better results. The Action Type options provided in the Action Context dictate whether the timestamps will be removed before returning the result. -``` php hl_lines="66-68 52-55" +``` php hl_lines="34-37 52-55" [[= include_file('code_samples/ai_actions/src/AI/Handler/WhisperAudioToTextActionHandler.php') =]] ``` diff --git a/docs/commerce/checkout/checkout_api.md b/docs/commerce/checkout/checkout_api.md index b45f220587..6de1c2b39b 100644 --- a/docs/commerce/checkout/checkout_api.md +++ b/docs/commerce/checkout/checkout_api.md @@ -22,7 +22,7 @@ From the developer's perspective, checkouts are referenced with an UUID identifi To access a single checkout, use the `CheckoutServiceInterface::getCheckout` method: ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 32, 33) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 26, 27) =]] ``` ## Get single checkout for specific cart @@ -31,7 +31,7 @@ To fetch checkout for a cart that already exists, use the `CheckoutServiceInterf You can use it when you want to initiate the checkout process right after products are successfully added to a cart. ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 26, 30) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 20, 24) =]] ``` ## Create checkout @@ -39,7 +39,7 @@ You can use it when you want to initiate the checkout process right after produc To create a checkout, use the `CheckoutServiceInterface::createCheckout` method and provide it with a `CheckoutCreateStruct` struct that contains a `CartInterface` object. ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 35, 41) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 29, 35) =]] ``` ## Update checkout @@ -53,7 +53,7 @@ To update the checkout, use the `CheckoutServiceInterface::updateCheckout` metho All data is placed in session storage. ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 43, 45) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 37, 39) =]] ``` ## Delete checkout @@ -61,5 +61,5 @@ All data is placed in session storage. To delete a checkout from the session, use the `CheckoutServiceInterface::deleteCheckout` method: ``` php -[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 47, 48) =]] +[[= include_file('code_samples/api/commerce/src/Controller/CustomCheckoutController.php', 41, 42) =]] ``` diff --git a/docs/commerce/payment/extend_payment.md b/docs/commerce/payment/extend_payment.md index 76f1ce9b3a..eb76cde4af 100644 --- a/docs/commerce/payment/extend_payment.md +++ b/docs/commerce/payment/extend_payment.md @@ -94,7 +94,7 @@ When you create a payment, you can attach custom data to it, for example, you ca You add custom data by using the `setContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 80, 91) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 93) =]] ``` Then, you retrieve it with the `getContext` method: diff --git a/docs/commerce/shipping_management/shipment_api.md b/docs/commerce/shipping_management/shipment_api.md index 3d6140a151..48f605d864 100644 --- a/docs/commerce/shipping_management/shipment_api.md +++ b/docs/commerce/shipping_management/shipment_api.md @@ -16,7 +16,7 @@ From the developer's perspective, shipments are referenced with a UUID identifie To access a single shipment by using its string identifier, use the `ShipmentService::getShipmentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 73, 82) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 57, 66) =]] ``` ### Get single shipment by id @@ -24,7 +24,7 @@ To access a single shipment by using its string identifier, use the `ShipmentSer To access a single shipment by using its numerical id, use the `ShipmentService::getShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 61, 71) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 45, 55) =]] ``` ## Get multiple shipments @@ -33,7 +33,7 @@ To fetch multiple shipments, use the `ShipmentService::findShipments` method. It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 84, 103) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 68, 87) =]] ``` ## Create shipment @@ -41,7 +41,7 @@ It follows the same search query pattern as other APIs: To create a shipment, use the `ShipmentService::createShipment` method and provide it with an `Ibexa\Contracts\Shipping\Value\ShipmentCreateStruct` object that takes two parameters, a `shippingMethod` string and a `Money` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 105, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 89, 103) =]] ``` ## Update shipment @@ -51,7 +51,7 @@ You could do it to support a scenario when, for example, the shipment is process To update shipment information, use the `ShipmentService::updateShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 121, 132) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 105, 116) =]] ``` ## Delete shipment @@ -59,5 +59,5 @@ To delete a shipment from the system, use the `ShipmentService::deleteShipment` ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 134, 135) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 118, 119) =]] ``` diff --git a/docs/commerce/shipping_management/shipping_method_api.md b/docs/commerce/shipping_management/shipping_method_api.md index a869cd3570..6a47fc1687 100644 --- a/docs/commerce/shipping_management/shipping_method_api.md +++ b/docs/commerce/shipping_management/shipping_method_api.md @@ -17,7 +17,7 @@ To access a shipping method by using its identifier, use the `ShippingMethodServ The method takes a string as `$identifier` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 65, 75) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 52, 62) =]] ``` ### Get shipping method by ID @@ -26,7 +26,7 @@ To access a shipping method by using its ID, use the `ShippingMethodServiceInter The method takes a string as `$id` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 53, 63) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 40, 50) =]] ``` ## Get multiple shipping methods @@ -35,7 +35,7 @@ To fetch multiple shipping methods, use the `ShippingMethodServiceInterface::get It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 77, 95) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 64, 82) =]] ``` ## Create shipping method @@ -43,7 +43,7 @@ It follows the same search query pattern as other APIs: To create a shipping method, use the `ShippingMethodServiceInterface::createShippingMethod` method and provide it with the `Ibexa\Contracts\Shipping\Value\ShippingMethodCreateStruct` object that you created by using the `newShippingMethodCreateStruct` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 97, 120) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 84, 107) =]] ``` ## Update shipping method @@ -51,7 +51,7 @@ To create a shipping method, use the `ShippingMethodServiceInterface::createShip To update a shipping method, use the `ShippingMethodServiceInterface::updateShippingMethod` method and provide it with the `Ibexa\Contracts\Shipping\Value\ShippingMethodUpdateStruct` object that you created by using the `newShippingMethodUpdateStruct` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 122, 137) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 109, 123) =]] ``` ## Delete shipping method @@ -59,7 +59,7 @@ To update a shipping method, use the `ShippingMethodServiceInterface::updateShip To update a shipping method, use the `ShippingMethodServiceInterface::deleteShippingMethod` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 138, 144) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 125, 131) =]] ``` ## Delete shipping method translation @@ -67,5 +67,5 @@ To update a shipping method, use the `ShippingMethodServiceInterface::deleteShip To delete shipping method translation, use the `ShippingMethodServiceInterface::deleteShippingMethodTranslation` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 146, 155) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 133, 142) =]] ``` diff --git a/docs/content_management/data_migration/data_migration_api.md b/docs/content_management/data_migration/data_migration_api.md index 53a17c8a6b..89aec66ec0 100644 --- a/docs/content_management/data_migration/data_migration_api.md +++ b/docs/content_management/data_migration/data_migration_api.md @@ -11,13 +11,13 @@ You can use the PHP API to manage and run [data migrations](data_migration.md). To list all migration files available in the directory defined in configuration (by default, `src/Migrations/Ibexa`), use the `MigrationService:listMigrations()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 35, 38) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 31, 34) =]] ``` To get a single migration file by its name, use the `MigrationService:findOneByName()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 40, 41) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 35, 36) =]] ``` ## Running migration files @@ -25,7 +25,7 @@ To get a single migration file by its name, use the `MigrationService:findOneByN To run migration file(s), use either `MigrationService:executeOne()` or `MigrationService:executeAll()`: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 42, 44) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 38, 40) =]] ``` Both `executeOne()` and `executeAll()` can take an optional parameter: the login of the User that you want to execute the migrations as. @@ -35,5 +35,5 @@ Both `executeOne()` and `executeAll()` can take an optional parameter: the login To add a new migration file, use the `MigrationService:add()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 28, 34) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 24, 30) =]] ``` diff --git a/docs/pim/catalog_api.md b/docs/pim/catalog_api.md index 2caa8d2ede..c16c54a2c5 100644 --- a/docs/pim/catalog_api.md +++ b/docs/pim/catalog_api.md @@ -11,7 +11,7 @@ To get information about product catalogs and manage them, use `CatalogServiceIn To get a single catalog, use `Ibexa\Contracts\ProductCatalog\CatalogServiceInterface::getCatalog()` and provide it with catalog ID, or `CatalogServiceInterface::getCatalogByIdentifier()` and pass the identifier: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 81, 83) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 68, 70) =]] ``` ## Get products in catalog @@ -20,7 +20,7 @@ To get products from a catalog, request the product query from the catalog objec Then, create a new `ProductQuery` based on it and run a product search with `ProductServiceInterface::findProduct()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 85, 91) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 72, 78) =]] ``` ## Create catalog @@ -29,7 +29,7 @@ To create a catalog, you need to prepare a `CatalogCreateStruct` that contains: Then, pass this struct to `CatalogServiceInterface::createCatalog()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 71, 79) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 51, 66) =]] ``` ## Update catalog @@ -39,5 +39,5 @@ You must pass the catalog object and a `CatalogUpdateStruct` to the method. In the following example, you update the catalog to publish it: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 93, 97) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 80, 84) =]] ``` diff --git a/docs/pim/price_api.md b/docs/pim/price_api.md index 6d26b2cee5..019bb04b91 100644 --- a/docs/pim/price_api.md +++ b/docs/pim/price_api.md @@ -12,13 +12,13 @@ To access a currency object by its code, use `CurrencyServiceInterface::getCurre To access a whole list of currencies, use `CurrencyServiceInterface::findCurrencies`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 52, 61) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 42, 50) =]] ``` To create a new currency, use `CurrencyServiceInterface::createCurrency()` and provide it with a `CurrencyCreateStruct` with code, number of fractional digits and a flag indicating if the currency is enabled: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 67, 71) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 57, 60) =]] ``` ## Prices @@ -28,19 +28,19 @@ To manage prices, use `ProductPriceService`. To retrieve the price of a product in the currency for the current context, use `Product::getPrice()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 79, 82) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 60, 63) =]] ``` To retrieve the price of a product in a specific currency, use `ProductPriceService::getPriceByProductAndCurrency`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 83, 86) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 64, 67) =]] ``` To get all prices (in different currencies) for a given product, use `ProductPriceService::findPricesByProductCode`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 97, 103) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 78, 84) =]] ``` To load price definitions that match given criteria, use `ProductPriceServiceInterface::findPrices`: @@ -48,14 +48,14 @@ To load price definitions that match given criteria, use `ProductPriceServiceInt ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 12, 16) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 104, 114) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 85, 95) =]] ``` You can also use `ProductPriceService` to create or modify existing prices. For example, to create a new price for a given currency, use `ProductPriceService::createProductPrice` and provide it with a `ProductPriceCreateStruct` object: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 79, 85) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 69, 75) =]] ``` !!! note @@ -80,7 +80,7 @@ To resolve a price of a product in the currency for the current context, use eit ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 7, 8) =]][[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 115, 119) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 96, 100) =]] ``` ## VAT @@ -89,17 +89,17 @@ To get information about the VAT categories and rates configured in the system, VAT is configured per region, so you also need to use `RegionServiceInterface` to get the relevant region object. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 54, 55) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 41, 42) =]] ``` To get information about all VAT categories configured for the selected region, use `VatServiceInterface::getVatCategories()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 56, 61) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 43, 48) =]] ``` To get a single VAT category, use `VatServiceInterface::getVatCategoryByIdentifier()` and provide it with the region object and the identifier of the VAT category: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 62, 64) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 49, 50) =]] ``` diff --git a/docs/pim/product_api.md b/docs/pim/product_api.md index e2cb59219c..df5a4e9afe 100644 --- a/docs/pim/product_api.md +++ b/docs/pim/product_api.md @@ -21,7 +21,7 @@ month_change: false Get an individual product by using the `ProductServiceInterface::getProduct()` method: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 73, 76) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 54, 57) =]] ``` Find multiple products with `ProductServiceInterface::findProducts()`. @@ -29,7 +29,7 @@ Find multiple products with `ProductServiceInterface::findProducts()`. Provide the method with optional filter, query or Sort Clauses. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 77, 87) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 58, 68) =]] ``` See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clauses](product_sort_clauses.md) references for more information about how to use the [`ProductQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Product-ProductQuery.html) class. @@ -39,7 +39,7 @@ See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clau To create, update and delete products, use the `LocalProductServiceInterface`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 98, 102) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 79, 83) =]] ``` To create a product, use `LocalProductServiceInterface::newProductCreateStruct()` to get a [`ProductCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-Product-ProductCreateStruct.html). @@ -47,13 +47,13 @@ Provide the method with the product type object and the main language code. You also need to set (at least) the code for the product and the required Field of the underlying content type, `name`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 88, 95) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 79, 83) =]] ``` To delete a product, use `LocalProductServiceInterface::deleteProduct()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 125, 126) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 106, 107) =]] ``` ### Product variants @@ -65,13 +65,13 @@ A `ProductVariantQuery` lets you define the offset and limit of the variant quer The default offset is 0, and limit is 25. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 62, 65) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 49, 52) =]] ``` From a variant ([`ProductVariantInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-ProductVariantInterface.html)), you can access the attributes that are used to generate the variant by using `ProductVariantInterface::getDiscriminatorAttributes()`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 66, 73) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 53, 60) =]] ``` #### Creating variants @@ -81,7 +81,7 @@ This method takes the product and an array of [`ProductVariantCreateStruct`](/ap `ProductVariantCreateStruct` specifies the attribute values and the code for the new variant. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 75, 81) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 62, 68) =]] ``` ### Product assets @@ -91,14 +91,14 @@ You can get assets assigned to a product by using [`AssetServiceInterface`](/api Use `AssetServiceInterface` to get a single asset by providing the product object and the assets's ID as parameters: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 59, 61) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 46, 48) =]] ``` To get all assets assigned to a product, use `AssetServiceInterface::findAssets()`. You can retrieve the tags (corresponding to attribute values) of assets with the `AssetInterface::getTags()` method: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 62, 71) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 49, 58) =]] ``` ## Product types @@ -108,13 +108,13 @@ To work with product types, use [`ProductTypeServiceInterface`](/api/php_api/php Get a product type object by using `ProductTypeServiceInterface::getProductType()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 48, 49) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 38, 39) =]] ``` You can also get a list of product types with `ProductTypeServiceInterface::findProductTypes()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 52, 57) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 42, 47) =]] ``` ## Product availability @@ -128,14 +128,14 @@ Get the availability object with `ProductAvailabilityServiceInterface::getAvaila You can then use `ProductAvailabilityServiceInterface::getStock()` to get the stock number for the product: ```php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 109, 114) =]] } +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 90, 95) =]] } ``` To change availability for a product, use `ProductAvailabilityServiceInterface::updateProductAvailability()` with a [`ProductAvailabilityUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Availability-ProductAvailabilityUpdateStruct.html) and provide it with the product object. The second parameter defines whether product is available, and the third whether its stock is infinite. The fourth parameter is the stock number: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 117, 120) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 98, 101) =]] ``` ## Attributes @@ -146,24 +146,24 @@ To get information about product attribute groups, use the [`AttributeGroupServi `AttributeGroupServiceInterface::findAttributeGroups()` gets attribute groups, all of them or filtered with an optional [`AttributeGroupQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-AttributeGroup-AttributeGroupQuery.html) object: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 75, 76) =]] -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 96, 102) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 53, 54) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 74, 79) =]] ``` To create an attribute group, use `LocalAttributeGroupServiceinterface::createAttributeGroup()` and provide it with an [`AttributeGroupCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeGroup-AttributeGroupCreateStruct.html): ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 69, 75) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 48, 52) =]] ``` To get information about product attributes, use the [`AttributeDefinitionServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-AttributeDefinitionServiceInterface.html), or [`LocalAttributeDefinitionServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-LocalAttributeDefinitionServiceInterface.html) to modify attributes. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 81, 85) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 60, 62) =]] ``` To create an attribute, use `LocalAttributeGroupServiceinterface::createAttributeDefinition()` and provide it with an [`AttributeDefinitionCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeDefinition-AttributeDefinitionCreateStruct.html): ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 86, 94) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 65, 71) =]] ``` From e8d2aa8f4230bbe3dfb8698492a4aab9dd9f1ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Tue, 15 Jul 2025 13:38:01 +0200 Subject: [PATCH 18/26] More fixes --- docs/content_management/data_migration/data_migration_api.md | 2 +- docs/pim/product_api.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content_management/data_migration/data_migration_api.md b/docs/content_management/data_migration/data_migration_api.md index 89aec66ec0..53c247b17c 100644 --- a/docs/content_management/data_migration/data_migration_api.md +++ b/docs/content_management/data_migration/data_migration_api.md @@ -17,7 +17,7 @@ To list all migration files available in the directory defined in configuration To get a single migration file by its name, use the `MigrationService:findOneByName()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 35, 36) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 36, 37) =]] ``` ## Running migration files diff --git a/docs/pim/product_api.md b/docs/pim/product_api.md index df5a4e9afe..5f76ee7ffc 100644 --- a/docs/pim/product_api.md +++ b/docs/pim/product_api.md @@ -47,7 +47,7 @@ Provide the method with the product type object and the main language code. You also need to set (at least) the code for the product and the required Field of the underlying content type, `name`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 79, 83) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 71, 76) =]] ``` To delete a product, use `LocalProductServiceInterface::deleteProduct()`: From 878c15cb7142128a3cd929dbc33c65cac902a8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 24 Jul 2025 16:16:19 +0200 Subject: [PATCH 19/26] Update rector.php Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> --- rector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rector.php b/rector.php index 091043e174..571c2cf6bb 100644 --- a/rector.php +++ b/rector.php @@ -25,4 +25,5 @@ SymfonySetList::SYMFONY_70, SymfonySetList::SYMFONY_71, SymfonySetList::SYMFONY_72, + SymfonySetList::SYMFONY_73, ]); From d265d154749ca827ec542118a815586799dadc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 24 Jul 2025 17:06:55 +0200 Subject: [PATCH 20/26] Manual fixes before running Rector --- .../Calendar/Holidays/EventSourceFactory.php | 2 +- .../src/Calendar/Holidays/EventType.php | 2 +- phpstan-baseline.neon | 18 ------------------ 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php index 0755376d56..42744e3c4a 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php @@ -4,7 +4,7 @@ use DateTime; use DateTimeInterface; -use Ibexa\Calendar\EventSource\InMemoryEventSource; +use Ibexa\Contracts\Calendar\EventSource\InMemoryEventSource; use Ibexa\Contracts\Calendar\EventCollection; use Ibexa\Contracts\Calendar\EventSource\EventSourceInterface; diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php index 8dcdfcb5b7..4b21a0e9e9 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php @@ -2,7 +2,7 @@ namespace App\Calendar\Holidays; -use Ibexa\Calendar\EventAction\EventActionCollection; +use Ibexa\Contracts\Calendar\EventAction\EventActionCollection; use Ibexa\Contracts\Calendar\Event; use Ibexa\Contracts\Calendar\EventType\EventTypeInterface; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 345cd3db12..12b238568c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -282,12 +282,6 @@ parameters: count: 1 path: code_samples/back_office/search/src/EventSubscriber/MySuggestionEventSubscriber.php - - - message: '#^Method App\\Setting\\Group\\MyGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/back_office/settings/src/Setting/Group/MyGroup.php - - message: '#^Method App\\Setting\\Unit\:\:mapFieldForm\(\) has parameter \$formBuilder with generic interface Symfony\\Component\\Form\\FormBuilderInterface but does not specify its types\: TData$#' identifier: missingType.generics @@ -444,12 +438,6 @@ parameters: count: 1 path: code_samples/field_types/generic_ft/src/Form/Type/HelloWorldType.php - - - message: '#^Method App\\FormBuilder\\FieldType\\Field\\Mapper\\CheckboxWithRichtextDescriptionFieldMapper\:\:mapFormOptions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/forms/custom_form_attribute/src/FormBuilder/FieldType/Field/Mapper/CheckboxWithRichtextDescriptionFieldMapper.php - - message: '#^Class App\\FormBuilder\\Form\\Type\\CheckboxWithRichtextDescriptionType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics @@ -462,12 +450,6 @@ parameters: count: 1 path: code_samples/forms/custom_form_attribute/src/FormBuilder/Form/Type/FieldAttribute/AttributeRichtextDescriptionType.php - - - message: '#^Method App\\FormBuilder\\Field\\Mapper\\CountryFieldMapper\:\:mapFormOptions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/forms/custom_form_field/src/FormBuilder/Field/Mapper/CountryFieldMapper.php - - message: '#^Method App\\QueryType\\LatestContentQueryType\:\:getQuery\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue From 441506314fc5eac5a617592a45689bea414ff2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 24 Jul 2025 17:09:46 +0200 Subject: [PATCH 21/26] Automated changes: Rector + CSFixer --- .../ActionConfigurationCreateCommand.php | 25 ++++++---------- .../src/Command/AddMissingAltTextCommand.php | 27 +++++++---------- .../api/commerce/src/Command/CartCommand.php | 24 +++++++-------- .../api/commerce/src/Command/OrderCommand.php | 18 ++++-------- .../commerce/src/Command/PaymentCommand.php | 22 +++++--------- .../src/Command/PaymentMethodCommand.php | 14 ++++----- .../commerce/src/Command/ShipmentCommand.php | 18 +++++------- .../src/Command/ShippingMethodCommand.php | 16 +++++----- .../src/Command/MigrationCommand.php | 10 +++---- .../src/Command/AttributeCommand.php | 26 +++++++---------- .../src/Command/CatalogCommand.php | 18 +++++------- .../src/Command/CurrencyCommand.php | 19 ++++++------ .../src/Command/ProductAssetCommand.php | 18 +++++------- .../src/Command/ProductCommand.php | 24 +++++++-------- .../src/Command/ProductPriceCommand.php | 26 ++++++++--------- .../src/Command/ProductTypeCommand.php | 17 ++++++----- .../src/Command/ProductVariantCommand.php | 18 +++++------- .../src/Command/VatCommand.php | 16 +++++----- .../src/Command/AddLanguageCommand.php | 15 +++++----- .../Command/AddLocationToContentCommand.php | 20 +++++++------ .../src/Command/BookmarkCommand.php | 13 ++++----- .../src/Command/BrowseLocationsCommand.php | 10 +++---- .../src/Command/CalendarCommand.php | 19 +++++------- .../src/Command/CreateContentCommand.php | 26 ++++++++++------- .../src/Command/CreateContentTypeCommand.php | 26 +++++++++-------- .../src/Command/CreateImageCommand.php | 24 ++++++++------- .../src/Command/DeleteContentCommand.php | 17 ++++++----- .../src/Command/FilterCommand.php | 10 +++---- .../src/Command/FilterLocationCommand.php | 10 +++---- .../src/Command/FindComplexCommand.php | 14 ++++----- .../src/Command/FindContentCommand.php | 10 +++---- .../src/Command/FindInTrashCommand.php | 10 +++---- .../src/Command/FindUrlCommand.php | 15 +++++----- .../Command/FindWithAggregationCommand.php | 8 ++--- .../src/Command/FormSubmissionCommand.php | 16 +++++----- .../src/Command/HideLocationCommand.php | 17 ++++++----- .../src/Command/MoveContentCommand.php | 19 ++++++------ .../src/Command/ObjectStateCommand.php | 24 ++++++++------- .../src/Command/SectionCommand.php | 23 ++++++++------- .../src/Command/SegmentCommand.php | 15 +++++----- .../src/Command/SetMainLocationCommand.php | 19 ++++++------ .../src/Command/TaxonomyCommand.php | 8 ++--- .../src/Command/TranslateContentCommand.php | 25 ++++++++-------- .../src/Command/TrashContentCommand.php | 27 +++++++++-------- .../src/Command/UpdateContentCommand.php | 19 ++++++------ .../src/Command/ViewContentCommand.php | 17 ++++++----- .../Command/ViewContentMetaDataCommand.php | 20 ++++++++----- .../src/Command/WorkflowCommand.php | 21 +++++++------- .../Calendar/Holidays/EventSourceFactory.php | 2 +- .../src/Calendar/Holidays/EventType.php | 2 +- .../src/Command/DashboardCommand.php | 23 +++++---------- .../back_office/images/src/SvgController.php | 7 +++-- .../back_office/images/src/SvgExtension.php | 13 +-------- .../VerifyStateEventSubscriber.php | 7 +++-- .../src/Command/ManageDiscountsCommand.php | 14 ++++----- .../src/Command/ViewCommand.php | 29 ++++++------------- .../siteaccess/AcmeExampleExtension.php | 3 +- .../Command/ActivityLogContextTestCommand.php | 15 +++------- .../Command/DispatchMyFeatureEventCommand.php | 6 ++-- .../MonitorRecentContentCreationCommand.php | 13 +++++---- .../src/Event/RandomBlockListener.php | 7 +++-- 61 files changed, 474 insertions(+), 540 deletions(-) diff --git a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php index 0c6ef19854..6190323003 100644 --- a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php +++ b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php @@ -15,33 +15,26 @@ use Ibexa\Contracts\Core\Repository\UserService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'app:action-configuration-create' )] -final class ActionConfigurationCreateCommand extends Command +final readonly class ActionConfigurationCreateCommand { public function __construct( - private readonly ActionConfigurationServiceInterface $actionConfigurationService, - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly ActionServiceInterface $actionService, - private readonly ActionTypeRegistryInterface $actionTypeRegistry + private ActionConfigurationServiceInterface $actionConfigurationService, + private PermissionResolver $permissionResolver, + private UserService $userService, + private ActionServiceInterface $actionService, + private ActionTypeRegistryInterface $actionTypeRegistry ) { - parent::__construct(); } - protected function configure(): void + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'user', description: 'Login of the user executing the actions')] + ?string $user, OutputInterface $output): int { - $this->addArgument('user', InputArgument::OPTIONAL, 'Login of the user executing the actions', 'admin'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $user = $input->getArgument('user'); + $user = $user; $this->permissionResolver->setCurrentUserReference($this->userService->loadUserByLogin($user)); $refineTextActionType = $this->actionTypeRegistry->getActionType('refine_text'); diff --git a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php index dee23735e9..81b5991c62 100644 --- a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php +++ b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php @@ -24,36 +24,29 @@ use Ibexa\Core\IO\IOBinarydataHandler; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'app:add-alt-text', )] -final class AddMissingAltTextCommand extends Command +final readonly class AddMissingAltTextCommand { private const string IMAGE_FIELD_IDENTIFIER = 'image'; public function __construct( - private readonly ContentService $contentService, - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly FieldTypeService $fieldTypeService, - private readonly ActionServiceInterface $actionService, - private readonly IOBinarydataHandler $binaryDataHandler + private ContentService $contentService, + private PermissionResolver $permissionResolver, + private UserService $userService, + private FieldTypeService $fieldTypeService, + private ActionServiceInterface $actionService, + private IOBinarydataHandler $binaryDataHandler ) { - parent::__construct(); } - protected function configure(): void + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'user', description: 'Login of the user executing the actions')] + ?string $user, OutputInterface $output): int { - $this->addArgument('user', InputArgument::OPTIONAL, 'Login of the user executing the actions', 'admin'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->setUser($input->getArgument('user')); + $this->setUser($user); $modifiedImages = $this->getModifiedImages(); $output->writeln(sprintf('Found %d modified image in the last 24h', $modifiedImages->getTotalCount())); diff --git a/code_samples/api/commerce/src/Command/CartCommand.php b/code_samples/api/commerce/src/Command/CartCommand.php index d44e01be36..fbba6d987e 100644 --- a/code_samples/api/commerce/src/Command/CartCommand.php +++ b/code_samples/api/commerce/src/Command/CartCommand.php @@ -19,28 +19,26 @@ use Ibexa\Core\Repository\Permission\PermissionResolver; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:cart' )] -final class CartCommand extends Command +final readonly class CartCommand { public function __construct( - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly CartServiceInterface $cartService, - private readonly CurrencyServiceInterface $currencyService, - private readonly ProductServiceInterface $productService, - private readonly OrderServiceInterface $orderService, - private readonly ReorderService $reorderService, - private readonly CartResolverInterface $cartResolver + private PermissionResolver $permissionResolver, + private UserService $userService, + private CartServiceInterface $cartService, + private CurrencyServiceInterface $currencyService, + private ProductServiceInterface $productService, + private OrderServiceInterface $orderService, + private ReorderService $reorderService, + private CartResolverInterface $cartResolver ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $this->permissionResolver->setCurrentUserReference( $this->userService->loadUserByLogin('admin') @@ -138,6 +136,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Merge the carts into the target cart and delete the merged carts $reorderCart = $this->cartService->mergeCarts($reorderCart, true, $existingCart); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/commerce/src/Command/OrderCommand.php b/code_samples/api/commerce/src/Command/OrderCommand.php index 44b24caef5..dd572bbe77 100644 --- a/code_samples/api/commerce/src/Command/OrderCommand.php +++ b/code_samples/api/commerce/src/Command/OrderCommand.php @@ -23,27 +23,21 @@ use Money; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:order' )] -final class OrderCommand extends Command +final readonly class OrderCommand { public function __construct( - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly OrderServiceInterface $orderService + private PermissionResolver $permissionResolver, + private UserService $userService, + private OrderServiceInterface $orderService ) { - parent::__construct(); } - public function configure(): void - { - } - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $currentUser = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($currentUser); @@ -118,6 +112,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln(sprintf('Found %d orders with provided criteria', count($orders))); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/commerce/src/Command/PaymentCommand.php b/code_samples/api/commerce/src/Command/PaymentCommand.php index c2ffc98488..fe824d1a9b 100644 --- a/code_samples/api/commerce/src/Command/PaymentCommand.php +++ b/code_samples/api/commerce/src/Command/PaymentCommand.php @@ -18,29 +18,23 @@ use Money; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:payment' )] -final class PaymentCommand extends Command +final readonly class PaymentCommand { public function __construct( - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly PaymentServiceInterface $paymentService, - private readonly OrderServiceInterface $orderService, - private readonly PaymentMethodServiceInterface $paymentMethodService, + private PermissionResolver $permissionResolver, + private UserService $userService, + private PaymentServiceInterface $paymentService, + private OrderServiceInterface $orderService, + private PaymentMethodServiceInterface $paymentMethodService ) { - parent::__construct(); } - public function configure(): void - { - } - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $currentUser = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($currentUser); @@ -105,6 +99,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Delete existing payment permanently $this->paymentService->deletePayment($payment); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/commerce/src/Command/PaymentMethodCommand.php b/code_samples/api/commerce/src/Command/PaymentMethodCommand.php index 4f4d6054e7..11d2488eb0 100644 --- a/code_samples/api/commerce/src/Command/PaymentMethodCommand.php +++ b/code_samples/api/commerce/src/Command/PaymentMethodCommand.php @@ -16,23 +16,21 @@ use Ibexa\Payment\Values\PaymentMethodType; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:paymentMethod' )] -final class PaymentMethodCommand extends Command +final readonly class PaymentMethodCommand { public function __construct( - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly PaymentMethodServiceInterface $paymentMethodService + private PermissionResolver $permissionResolver, + private UserService $userService, + private PaymentMethodServiceInterface $paymentMethodService ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $currentUser = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($currentUser); @@ -115,6 +113,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int )); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/commerce/src/Command/ShipmentCommand.php b/code_samples/api/commerce/src/Command/ShipmentCommand.php index 6dc246ee3e..3be9f1b815 100644 --- a/code_samples/api/commerce/src/Command/ShipmentCommand.php +++ b/code_samples/api/commerce/src/Command/ShipmentCommand.php @@ -19,25 +19,23 @@ use Money; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:shipment' )] -final class ShipmentCommand extends Command +final readonly class ShipmentCommand { public function __construct( - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly ShipmentServiceInterface $shipmentService, - private readonly ShippingMethodServiceInterface $shippingMethodService, - private readonly OrderServiceInterface $orderService + private PermissionResolver $permissionResolver, + private UserService $userService, + private ShipmentServiceInterface $shipmentService, + private ShippingMethodServiceInterface $shippingMethodService, + private OrderServiceInterface $orderService ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $currentUser = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($currentUser); @@ -118,6 +116,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Delete existing shipment permanently $this->shipmentService->deleteShipment($shipment); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/commerce/src/Command/ShippingMethodCommand.php b/code_samples/api/commerce/src/Command/ShippingMethodCommand.php index 85368142f8..cd8290b85d 100644 --- a/code_samples/api/commerce/src/Command/ShippingMethodCommand.php +++ b/code_samples/api/commerce/src/Command/ShippingMethodCommand.php @@ -15,24 +15,22 @@ use Ibexa\Shipping\Value\ShippingMethodType; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:shippingMethod' )] -final class ShippingMethodCommand extends Command +final readonly class ShippingMethodCommand { public function __construct( - private readonly PermissionResolver $permissionResolver, - private readonly UserService $userService, - private readonly ShippingMethodServiceInterface $shippingMethodService, - private readonly RegionServiceInterface $regionService + private PermissionResolver $permissionResolver, + private UserService $userService, + private ShippingMethodServiceInterface $shippingMethodService, + private RegionServiceInterface $regionService ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $currentUser = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($currentUser); @@ -141,6 +139,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $languageCode )); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/migration/src/Command/MigrationCommand.php b/code_samples/api/migration/src/Command/MigrationCommand.php index df0bf887b5..93beb87116 100644 --- a/code_samples/api/migration/src/Command/MigrationCommand.php +++ b/code_samples/api/migration/src/Command/MigrationCommand.php @@ -6,20 +6,18 @@ use Ibexa\Migration\Repository\Migration; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:migration' )] -final class MigrationCommand extends Command +final readonly class MigrationCommand { - public function __construct(private readonly MigrationService $migrationService) + public function __construct(private MigrationService $migrationService) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $string_with_migration_content = ''; $this->migrationService->add( @@ -39,6 +37,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->migrationService->executeOne($my_migration); $this->migrationService->executeAll('admin'); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/AttributeCommand.php b/code_samples/api/product_catalog/src/Command/AttributeCommand.php index ee4d97b659..51246b511b 100644 --- a/code_samples/api/product_catalog/src/Command/AttributeCommand.php +++ b/code_samples/api/product_catalog/src/Command/AttributeCommand.php @@ -11,31 +11,25 @@ use Ibexa\Contracts\ProductCatalog\Local\LocalAttributeGroupServiceInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:attributes' )] -final class AttributeCommand extends Command +final readonly class AttributeCommand { public function __construct( - private readonly LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService, - private readonly AttributeDefinitionServiceInterface $attributeDefinitionService, - private readonly AttributeGroupServiceInterface $attributeGroupService, - private readonly LocalAttributeGroupServiceInterface $localAttributeGroupService, - private readonly AttributeTypeServiceInterface $attributeTypeService, - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver + private LocalAttributeDefinitionServiceInterface $localAttributeDefinitionService, + private AttributeDefinitionServiceInterface $attributeDefinitionService, + private AttributeGroupServiceInterface $attributeGroupService, + private LocalAttributeGroupServiceInterface $localAttributeGroupService, + private AttributeTypeServiceInterface $attributeTypeService, + private UserService $userService, + private PermissionResolver $permissionResolver ) { - parent::__construct(); } - public function configure(): void - { - } - - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -78,6 +72,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Attribute group ' . $attributeGroup->getIdentifier() . ' with name ' . $attributeGroup->getName()); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/CatalogCommand.php b/code_samples/api/product_catalog/src/Command/CatalogCommand.php index eef9eb1d62..fd440a051f 100644 --- a/code_samples/api/product_catalog/src/Command/CatalogCommand.php +++ b/code_samples/api/product_catalog/src/Command/CatalogCommand.php @@ -16,21 +16,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:catalog' )] -final class CatalogCommand extends Command +final readonly class CatalogCommand { public function __construct( - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver, - private readonly ProductServiceInterface $productService, - private readonly CatalogServiceInterface $catalogService + private UserService $userService, + private PermissionResolver $permissionResolver, + private ProductServiceInterface $productService, + private CatalogServiceInterface $catalogService ) { - parent::__construct(); } public function configure(): void @@ -41,12 +39,12 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $catalogIdentifier = $input->getArgument('catalogIdentifier'); + $catalogIdentifier = $catalogIdentifier; // Create catalog $catalogCriterion = new Criterion\LogicalAnd( @@ -83,6 +81,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->catalogService->updateCatalog($catalog, $catalogUpdateStruct); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php index 266ab2e0bb..95515d4b0f 100644 --- a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php +++ b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php @@ -10,17 +10,18 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:currency' )] -final class CurrencyCommand extends Command +final readonly class CurrencyCommand { - public function __construct(private readonly CurrencyServiceInterface $currencyService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private CurrencyServiceInterface $currencyService, + private UserService $userService, + private PermissionResolver $permissionResolver + ) { } public function configure(): void @@ -32,13 +33,13 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $currencyCode = $input->getArgument('currencyCode'); - $newCurrencyCode = $input->getArgument('newCurrencyCode'); + $currencyCode = $currencyCode; + $newCurrencyCode = $newCurrencyCode; $currency = $this->currencyService->getCurrencyByCode($currencyCode); $output->writeln('Currency ID: ' . $currency->getId()); @@ -59,6 +60,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->currencyService->createCurrency($currencyCreateStruct); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php index aa9ed43d9e..a89de9a20f 100644 --- a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php @@ -11,21 +11,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:assets' )] -final class ProductAssetCommand extends Command +final readonly class ProductAssetCommand { public function __construct( - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver, - private readonly ProductServiceInterface $productService, - private readonly AssetServiceInterface $assetService + private UserService $userService, + private PermissionResolver $permissionResolver, + private ProductServiceInterface $productService, + private AssetServiceInterface $assetService ) { - parent::__construct(); } public function configure(): void @@ -36,12 +34,12 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $input->getArgument('productCode'); + $productCode = $productCode; $product = $this->productService->getProduct($productCode); $singleAsset = $this->assetService->getAsset($product, '1'); @@ -57,6 +55,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/ProductCommand.php b/code_samples/api/product_catalog/src/Command/ProductCommand.php index a231d9ddd0..d502f3ef97 100644 --- a/code_samples/api/product_catalog/src/Command/ProductCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductCommand.php @@ -16,23 +16,21 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:product' )] -final class ProductCommand extends Command +final readonly class ProductCommand { public function __construct( - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver, - private readonly ProductTypeServiceInterface $productTypeService, - private readonly ProductServiceInterface $productService, - private readonly LocalProductServiceInterface $localProductService, - private readonly ProductAvailabilityServiceInterface $productAvailabilityService + private UserService $userService, + private PermissionResolver $permissionResolver, + private ProductTypeServiceInterface $productTypeService, + private ProductServiceInterface $productService, + private LocalProductServiceInterface $localProductService, + private ProductAvailabilityServiceInterface $productAvailabilityService ) { - parent::__construct(); } public function configure(): void @@ -44,13 +42,13 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $input->getArgument('productCode'); - $productType = $input->getArgument('productType'); + $productCode = $productCode; + $productType = $productType; $product = $this->productService->getProduct($productCode); @@ -106,6 +104,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->localProductService->deleteProduct($product); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php index 0a3c40ecbb..6051d7014c 100644 --- a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php @@ -19,23 +19,21 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:price' )] -final class ProductPriceCommand extends Command +final readonly class ProductPriceCommand { public function __construct( - private readonly CurrencyServiceInterface $currencyService, - private readonly ProductServiceInterface $productService, - private readonly ProductPriceServiceInterface $productPriceService, - private readonly PriceResolverInterface $priceResolver, - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver + private CurrencyServiceInterface $currencyService, + private ProductServiceInterface $productService, + private ProductPriceServiceInterface $productPriceService, + private PriceResolverInterface $priceResolver, + private UserService $userService, + private PermissionResolver $permissionResolver ) { - parent::__construct(); } public function configure(): void @@ -48,14 +46,14 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $input->getArgument('productCode'); + $productCode = $productCode; $product = $this->productService->getProduct($productCode); - $currencyCode = $input->getArgument('currencyCode'); + $currencyCode = $currencyCode; $currency = $this->currencyService->getCurrencyByCode($currencyCode); $productPrice = $product->getPrice(); @@ -66,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Price for ' . $product->getName() . ' in ' . $currencyCode . ' is ' . $productPrice); - $newCurrencyCode = $input->getArgument('newCurrencyCode'); + $newCurrencyCode = $newCurrencyCode; $newCurrency = $this->currencyService->getCurrencyByCode($newCurrencyCode); $money = new Money\Money(50000, new Money\Currency($newCurrencyCode)); @@ -99,6 +97,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Price in ' . $currency->getCode() . ' for ' . $product->getName() . ' is ' . $price); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php index b1c2f4da40..ebaf3f757c 100644 --- a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php @@ -8,17 +8,18 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:product_type' )] -final class ProductTypeCommand extends Command +final readonly class ProductTypeCommand { - public function __construct(private readonly UserService $userService, private readonly PermissionResolver $permissionResolver, private readonly ProductTypeServiceInterface $productTypeService) - { - parent::__construct(); + public function __construct( + private UserService $userService, + private PermissionResolver $permissionResolver, + private ProductTypeServiceInterface $productTypeService + ) { } public function configure(): void @@ -29,12 +30,12 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productTypeIdentifier = $input->getArgument('productTypeIdentifier'); + $productTypeIdentifier = $productTypeIdentifier; $productType = $this->productTypeService->getProductType($productTypeIdentifier); @@ -46,6 +47,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($productType->getName() . ' with identifier ' . $productType->getIdentifier()); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php index 3b685a7fc4..c822bd8ffc 100644 --- a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php @@ -13,21 +13,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:product_variant' )] -final class ProductVariantCommand extends Command +final readonly class ProductVariantCommand { public function __construct( - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver, - private readonly ProductServiceInterface $productService, - private readonly LocalProductServiceInterface $localProductService + private UserService $userService, + private PermissionResolver $permissionResolver, + private ProductServiceInterface $productService, + private LocalProductServiceInterface $localProductService ) { - parent::__construct(); } public function configure(): void @@ -38,12 +36,12 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $input->getArgument('productCode'); + $productCode = $productCode; $product = $this->productService->getProduct($productCode); // Get variants @@ -67,6 +65,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->localProductService->createProductVariants($product, $variantCreateStructs); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/product_catalog/src/Command/VatCommand.php b/code_samples/api/product_catalog/src/Command/VatCommand.php index fc5ee046c6..0dcfb80b8d 100644 --- a/code_samples/api/product_catalog/src/Command/VatCommand.php +++ b/code_samples/api/product_catalog/src/Command/VatCommand.php @@ -9,21 +9,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:vat' )] -final class VatCommand extends Command +final readonly class VatCommand { public function __construct( - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver, - private readonly VatServiceInterface $vatService, - private readonly RegionServiceInterface $regionService + private UserService $userService, + private PermissionResolver $permissionResolver, + private VatServiceInterface $vatService, + private RegionServiceInterface $regionService ) { - parent::__construct(); } public function configure(): void @@ -34,7 +32,7 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -51,6 +49,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln((string) $vatCategory->getVatValue()); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php index 1144c7bf31..7056518e23 100644 --- a/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLanguageCommand.php @@ -7,21 +7,22 @@ use Ibexa\Contracts\Core\Repository\UserService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:add_language', description: 'Lists available languages and add Polish.' )] -class AddLanguageCommand extends Command +class AddLanguageCommand { - public function __construct(private readonly LanguageService $languageService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly LanguageService $languageService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -38,6 +39,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->languageService->createLanguage($languageCreateStruct); $output->writeln('Added language Polish with language code pol-PL.'); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php index bdde5d4293..0650f8d19a 100644 --- a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php @@ -9,18 +9,20 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:add_location', description: 'Add a Location to content item and hides it.' )] -class AddLocationToContentCommand extends Command +class AddLocationToContentCommand { - public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -32,13 +34,13 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $parentLocationId = (int) $input->getArgument('parentLocationId'); - $contentId = (int) $input->getArgument('contentId'); + $parentLocationId = (int) $parentLocationId; + $contentId = (int) $contentId; $locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocationId); @@ -50,6 +52,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Added hidden location ' . $newLocation->id . ' to content item: ' . $contentInfo->name); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php index daee829bc7..a01b7be32e 100644 --- a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php +++ b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php @@ -7,18 +7,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:bookmark' )] -class BookmarkCommand extends Command +class BookmarkCommand { public function __construct(private readonly BookmarkService $bookmarkService, private readonly LocationService $locationService) { - parent::__construct(); } protected function configure(): void @@ -30,9 +28,10 @@ protected function configure(): void ->addOption('delete', 'd', InputOption::VALUE_NONE, 'Delete the created bookmark?', null); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option] + $delete, OutputInterface $output): int { - $locationId = (int) $input->getArgument('locationId'); + $locationId = (int) $locationId; $location = $this->locationService->loadLocation($locationId); $this->bookmarkService->createBookmark($location); @@ -47,11 +46,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($bookmark->getContentInfo()->name); } - if ($input->getOption('delete')) { + if ($delete) { $this->bookmarkService->deleteBookmark($location); $output->writeln('Deleted bookmark from ' . $location->getContentInfo()->name); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php index 9f88f6ee9e..67fecce68a 100644 --- a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php +++ b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php @@ -7,18 +7,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:browse_locations', description: 'Lists all descendants of the Location' )] -class BrowseLocationsCommand extends Command +class BrowseLocationsCommand { public function __construct(private readonly LocationService $locationService) { - parent::__construct(); } protected function configure(): void @@ -39,13 +37,13 @@ private function browseLocation(Location $location, OutputInterface $output, int } } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $locationId = (int) $input->getArgument('locationId'); + $locationId = (int) $locationId; $location = $this->locationService->loadLocation($locationId); $this->browseLocation($location, $output); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/CalendarCommand.php b/code_samples/api/public_php_api/src/Command/CalendarCommand.php index 664c4abb52..92623424cb 100644 --- a/code_samples/api/public_php_api/src/Command/CalendarCommand.php +++ b/code_samples/api/public_php_api/src/Command/CalendarCommand.php @@ -9,25 +9,22 @@ use Ibexa\Scheduler\Calendar\EventAction\RescheduleEventActionContext; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:calendar', description: 'Lists Calendar event in the provided time range and reschedules them.' )] -class CalendarCommand extends Command +class CalendarCommand { - public function __construct(private readonly PermissionResolver $permissionResolver, private readonly UserService $userService, private readonly CalendarServiceInterface $calendarService) - { - parent::__construct(); - } - - public function configure(): void - { + public function __construct( + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService, + private readonly CalendarServiceInterface $calendarService + ) { } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -57,6 +54,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->calendarService->executeAction($context); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php index 91700cae0c..9b83cfaba5 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php @@ -10,18 +10,21 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:create_content' )] -class CreateContentCommand extends Command +class CreateContentCommand { - public function __construct(private readonly ContentService $contentService, private readonly ContentTypeService $contentTypeService, private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -35,14 +38,15 @@ protected function configure(): void ->addOption('publish', 'p', InputOption::VALUE_NONE, 'Do you want to publish the content item?'); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option] + $publish, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $parentLocationId = (int) $input->getArgument('parentLocationId'); - $contentTypeIdentifier = $input->getArgument('contentType'); - $name = $input->getArgument('name'); + $parentLocationId = (int) $parentLocationId; + $contentTypeIdentifier = $contentType; + $name = $name; $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, 'eng-GB'); @@ -54,11 +58,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Created a draft of ' . $contentType->getName() . ' with name ' . $draft->getName()); - if ($input->getOption('publish')) { + if ($publish) { $content = $this->contentService->publishVersion($draft->versionInfo); $output->writeln('Published content item ' . $content->getName()); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php index 740383bc5a..ea0c5e07ba 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php @@ -9,18 +9,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:create_content_type' )] -class CreateContentTypeCommand extends Command +class CreateContentTypeCommand { - public function __construct(private readonly ContentTypeService $contentTypeService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentTypeService $contentTypeService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -33,15 +34,16 @@ protected function configure(): void ->addOption('copy', 'c', InputOption::VALUE_NONE, 'Do you want to make a copy of the content type?'); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option] + $copy, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $groupIdentifier = $input->getArgument('group_identifier'); - $contentTypeIdentifier = $input->getArgument('identifier'); - if ($input->getArgument('copy_identifier')) { - $copyIdentifier = $input->getArgument('copy_identifier'); + $groupIdentifier = $group_identifier; + $contentTypeIdentifier = $identifier; + if ($copy_identifier) { + $copyIdentifier = $copy_identifier; } try { @@ -79,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->contentTypeService->publishContentTypeDraft($contentTypeDraft); $output->writeln("Content type '$contentTypeIdentifier' with ID $contentTypeDraft->id created"); - if ($input->getOption('copy')) { + if ($copy) { $contentTypeToCopy = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); $copy = $this->contentTypeService->copyContentType($contentTypeToCopy); @@ -92,6 +94,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Copy of the new CT created with identifier ' . $copyIdentifier); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php index f34f599cd0..677941b2b7 100644 --- a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php @@ -11,18 +11,21 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:create_image' )] -class CreateImageCommand extends Command +class CreateImageCommand { - public function __construct(private readonly ContentService $contentService, private readonly ContentTypeService $contentTypeService, private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -35,14 +38,15 @@ protected function configure(): void ->addOption('publish', 'p', InputOption::VALUE_NONE, 'Do you want to publish the content item?'); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option] + $publish, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $name = $input->getArgument('name'); - $file = $input->getArgument('file'); - $publish = $input->getOption('publish'); + $name = $name; + $file = $file; + $publish = $publish; $contentType = $this->contentTypeService->loadContentTypeByIdentifier('image'); $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, 'eng-GB'); @@ -68,6 +72,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Published content item ' . $content->getName()); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php index 9541b5e2bc..21e8a81615 100644 --- a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php @@ -8,17 +8,18 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:delete_content' )] -class DeleteContentCommand extends Command +class DeleteContentCommand { - public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -28,12 +29,12 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $input->getArgument('locationId'); + $locationId = (int) $locationId; $location = $this->locationService->loadLocation($locationId); @@ -41,6 +42,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Location ' . $locationId . ' deleted.'); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FilterCommand.php b/code_samples/api/public_php_api/src/Command/FilterCommand.php index 09f1afdd35..6626fa835d 100644 --- a/code_samples/api/public_php_api/src/Command/FilterCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterCommand.php @@ -10,18 +10,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:filter', description: 'Returns children of the provided Location, sorted by name in descending order.' )] -class FilterCommand extends Command +class FilterCommand { public function __construct(private readonly ContentService $contentService) { - parent::__construct(); } public function configure(): void @@ -31,9 +29,9 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $parentLocationId = (int)$input->getArgument('parentLocationId'); + $parentLocationId = (int)$parentLocationId; $filter = new Filter(); $filter @@ -48,6 +46,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($content->getName() ?? 'No content name'); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php index f1f05b5b23..2da30e76a8 100644 --- a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php @@ -10,18 +10,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:filter_location', description: 'Returns children of the provided Location, sorted by name in descending order.' )] -class FilterLocationCommand extends Command +class FilterLocationCommand { public function __construct(private readonly LocationService $locationService) { - parent::__construct(); } public function configure(): void @@ -31,9 +29,9 @@ public function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $parentLocationId = (int)$input->getArgument('parentLocationId'); + $parentLocationId = (int)$parentLocationId; $filter = new Filter(); $filter @@ -48,6 +46,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($content->getContent()->getName()); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php index dae57ba0ec..48f4a6a960 100644 --- a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php @@ -10,18 +10,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:find_complex', description: 'Lists content belonging to the provided content type.' )] -class FindComplexCommand extends Command +class FindComplexCommand { public function __construct(private readonly SearchService $searchService, private readonly LocationService $locationService) { - parent::__construct(); } protected function configure(): void @@ -34,11 +32,11 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $locationId = (int) $input->getArgument('locationId'); - $contentTypeIdentifier = $input->getArgument('contentTypeIdentifier'); - $text = $input->getArgument('text'); + $locationId = (int) $locationId; + $contentTypeIdentifier = $contentTypeIdentifier; + $text = $text; $query = new LocationQuery(); @@ -62,6 +60,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($searchHit->valueObject->name); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FindContentCommand.php b/code_samples/api/public_php_api/src/Command/FindContentCommand.php index ff72d55a46..e6f940e4d4 100644 --- a/code_samples/api/public_php_api/src/Command/FindContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindContentCommand.php @@ -8,18 +8,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:find_content', description: 'Lists content belonging to the provided content type.' )] -class FindContentCommand extends Command +class FindContentCommand { public function __construct(private readonly SearchService $searchService) { - parent::__construct(); } protected function configure(): void @@ -30,9 +28,9 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $contentTypeIdentifier = $input->getArgument('contentTypeIdentifier'); + $contentTypeIdentifier = $contentTypeIdentifier; $query = new LocationQuery(); $query->filter = new Criterion\ContentTypeIdentifier($contentTypeIdentifier); @@ -44,6 +42,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($searchHit->valueObject->name); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php index c663e92917..851033a7cf 100644 --- a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php @@ -7,18 +7,16 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:find_in_trash', description: 'Lists content in Trash belonging to the provided content type.' )] -class FindInTrashCommand extends Command +class FindInTrashCommand { public function __construct(private readonly TrashService $trashService) { - parent::__construct(); } protected function configure(): void @@ -29,9 +27,9 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $contentTypeId = (int) $input->getArgument('contentTypeId'); + $contentTypeId = (int) $contentTypeId; $query = new Query(); @@ -41,6 +39,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($trashedLocation->getContentInfo()->name); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php index 916d329576..eea9ef6c98 100644 --- a/code_samples/api/public_php_api/src/Command/FindUrlCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindUrlCommand.php @@ -10,21 +10,22 @@ use Ibexa\Contracts\Core\Repository\Values\URL\URLQuery; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:find_url', description: 'Finds all valid URLs in the provided Section.' )] -class FindUrlCommand extends Command +class FindUrlCommand { - public function __construct(private readonly URLService $urlService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly URLService $urlService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -49,6 +50,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($result->url); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php index 664d0a85fb..6ba660146d 100644 --- a/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php @@ -9,21 +9,19 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:find_with_aggregation', description: 'Counts content per content type and the value of Selection Field.' )] -class FindWithAggregationCommand extends Command +class FindWithAggregationCommand { public function __construct(private readonly SearchService $searchService) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $query = new LocationQuery(); $query->query = new Criterion\ParentLocationId(2); @@ -48,6 +46,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($selection . ': ' . $count); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php b/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php index 14fe4eb7a5..8d3e51914b 100644 --- a/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php +++ b/code_samples/api/public_php_api/src/Command/FormSubmissionCommand.php @@ -8,20 +8,22 @@ use Ibexa\Contracts\FormBuilder\FormSubmission\FormSubmissionServiceInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:form-submission' )] -final class FormSubmissionCommand extends Command +final readonly class FormSubmissionCommand { - public function __construct(private readonly UserService $userService, private readonly PermissionResolver $permissionResolver, private readonly FormSubmissionServiceInterface $formSubmissionService, private readonly ContentService $contentService) - { - parent::__construct(); + public function __construct( + private UserService $userService, + private PermissionResolver $permissionResolver, + private FormSubmissionServiceInterface $formSubmissionService, + private ContentService $contentService + ) { } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -58,6 +60,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $submission = $this->formSubmissionService->loadById(29); $this->formSubmissionService->delete($submission); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php index 356ce98f52..63d8403fb4 100644 --- a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php @@ -8,18 +8,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:hide', description: 'Hides and reveals again selected Location.' )] -class HideLocationCommand extends Command +class HideLocationCommand { - public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -30,12 +31,12 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $input->getArgument('location_id'); + $locationId = (int) $location_id; $location = $this->locationService->loadLocation($locationId); @@ -45,6 +46,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->locationService->unhideLocation($location); $output->writeln('Location revealed: ' . $locationId); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php index 73668ca741..a18a7d46dc 100644 --- a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php @@ -8,18 +8,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:move_content', description: 'Moves the selected Location with its subtree.' )] -class MoveContentCommand extends Command +class MoveContentCommand { - public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -31,19 +32,19 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $input->getArgument('locationId'); - $targetLocationId = (int) $input->getArgument('targetLocationId'); + $locationId = (int) $locationId; + $targetLocationId = (int) $targetLocationId; $sourceLocation = $this->locationService->loadLocation($locationId); $targetLocation = $this->locationService->loadLocation($targetLocationId); $this->locationService->moveSubtree($sourceLocation, $targetLocation); $output->writeln('Location ' . $locationId . ' moved to ' . $targetLocationId . ' with its subtree.'); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php index 9adbbcf37d..a9ae501d00 100644 --- a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php +++ b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php @@ -9,18 +9,20 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:object_state', description: 'Creates OS group with provided States and assigned the Lock OS to provided content item' )] -class ObjectStateCommand extends Command +class ObjectStateCommand { - public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly ObjectStateService $objectStateService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly ObjectStateService $objectStateService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -33,7 +35,7 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -44,8 +46,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($objectStateGroup->getName()); $output->writeln($objectState->getName()); - $objectStateGroupIdentifier = $input->getArgument('objectStateGroupIdentifier'); - $objectStateIdentifierList = explode(',', (string) $input->getArgument('objectStateIdentifier')); + $objectStateGroupIdentifier = $objectStateGroupIdentifier; + $objectStateIdentifierList = explode(',', (string) $objectStateIdentifier); $objectStateGroupStruct = $this->objectStateService->newObjectStateGroupCreateStruct($objectStateGroupIdentifier); $objectStateGroupStruct->defaultLanguageCode = 'eng-GB'; @@ -64,8 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('* ' . $objectState->getName()); } - if ($input->getArgument('contentID')) { - $contentId = (int) $input->getArgument('contentID'); + if ($contentID) { + $contentId = (int) $contentID; $objectStateToAssign = $objectStateIdentifierList[0]; $contentInfo = $this->contentService->loadContentInfo($contentId); $objectStateGroup = $this->objectStateService->loadObjectStateGroupByIdentifier($objectStateGroupIdentifier); @@ -75,6 +77,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Content ' . $contentInfo->name . ' assigned state ' . $objectState->getName()); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/SectionCommand.php b/code_samples/api/public_php_api/src/Command/SectionCommand.php index 5ee14d92fc..8bbc69188d 100644 --- a/code_samples/api/public_php_api/src/Command/SectionCommand.php +++ b/code_samples/api/public_php_api/src/Command/SectionCommand.php @@ -12,18 +12,21 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:section', description: 'Creates new section and adds selected content item to it.' )] -class SectionCommand extends Command +class SectionCommand { - public function __construct(private readonly SectionService $sectionService, private readonly UserService $userService, private readonly ContentService $contentService, private readonly SearchService $searchService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly SectionService $sectionService, + private readonly UserService $userService, + private readonly ContentService $contentService, + private readonly SearchService $searchService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -36,14 +39,14 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $sectionName = $input->getArgument('sectionName'); - $sectionIdentifier = $input->getArgument('sectionIdentifier'); - $contentId = (int) $input->getArgument('contentId'); + $sectionName = $sectionName; + $sectionIdentifier = $sectionIdentifier; + $contentId = (int) $contentId; $sectionCreateStruct = $this->sectionService->newSectionCreateStruct(); $sectionCreateStruct->name = $sectionName; @@ -74,6 +77,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('* ' . $searchResult->valueObject->name); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/SegmentCommand.php b/code_samples/api/public_php_api/src/Command/SegmentCommand.php index 7eb8833da8..eab191596a 100644 --- a/code_samples/api/public_php_api/src/Command/SegmentCommand.php +++ b/code_samples/api/public_php_api/src/Command/SegmentCommand.php @@ -9,20 +9,21 @@ use Ibexa\Segmentation\Value\SegmentGroupCreateStruct; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:segment' )] -class SegmentCommand extends Command +class SegmentCommand { - public function __construct(private readonly SegmentationService $segmentationService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly SegmentationService $segmentationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -61,6 +62,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int : 'The user is not assigned to the segment.' )); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php index b155cfde90..52fd5dd4df 100644 --- a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php @@ -8,18 +8,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:set_main_location', description: 'Set a Location as content item\'s main' )] -class SetMainLocationCommand extends Command +class SetMainLocationCommand { - public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -31,13 +32,13 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $input->getArgument('contentId'); - $locationId = (int) $input->getArgument('locationId'); + $contentId = (int) $contentId; + $locationId = (int) $locationId; $contentInfo = $this->contentService->loadContentInfo($contentId); @@ -48,6 +49,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Location ' . $locationId . ' is now the main Location for ' . $contentInfo->name); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php b/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php index 2b98a23b6e..4b6f89ecb4 100644 --- a/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php +++ b/code_samples/api/public_php_api/src/Command/TaxonomyCommand.php @@ -9,23 +9,21 @@ use Ibexa\Contracts\Taxonomy\Service\TaxonomyServiceInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:taxonomy' )] -class TaxonomyCommand extends Command +class TaxonomyCommand { public function __construct( private readonly TaxonomyServiceInterface $taxonomyService, private readonly PermissionResolver $permissionResolver, private readonly UserService $userService ) { - parent::__construct(); } - public function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -51,6 +49,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $sibling = $this->taxonomyService->loadEntryByIdentifier('school_desks'); $this->taxonomyService->moveEntryRelativeToSibling($entryToMove, $sibling, TaxonomyServiceInterface::MOVE_POSITION_PREV); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php index d2ef82e2f9..494c9f9734 100644 --- a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php @@ -8,17 +8,18 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:translate_content' )] -class TranslateContentCommand extends Command +class TranslateContentCommand { - public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -33,16 +34,16 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $input->getArgument('contentId'); - $language = $input->getArgument('language'); - $newName = $input->getArgument('nameInNewLanguage'); - $secondaryLanguage = $input->getArgument('secondaryLanguage'); - $nameInSecondaryLanguage = $input->getArgument('nameInSecondaryLanguage'); + $contentId = (int) $contentId; + $language = $language; + $newName = $nameInNewLanguage; + $secondaryLanguage = $secondaryLanguage; + $nameInSecondaryLanguage = $nameInSecondaryLanguage; $contentInfo = $this->contentService->loadContentInfo($contentId); $contentDraft = $this->contentService->createContentDraft($contentInfo); @@ -59,6 +60,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->contentService->publishVersion($contentDraft->versionInfo); $output->writeln('Translated ' . $contentInfo->name . ' to ' . $language . ' as ' . $newName); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php index 44cf486b03..2f98505e9f 100644 --- a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php @@ -9,18 +9,20 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:trash_content' )] -class TrashContentCommand extends Command +class TrashContentCommand { - public function __construct(private readonly LocationService $locationService, private readonly UserService $userService, private readonly TrashService $trashService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly TrashService $trashService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -32,14 +34,15 @@ protected function configure(): void ->addOption('restore', 'r', InputOption::VALUE_NONE, 'Do you want to restore the content item?'); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option] + $restore, OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $input->getArgument('locationId'); - if ($input->getArgument('newParentId')) { - $newParentId = (int) $input->getArgument('newParentId'); + $locationId = (int) $locationId; + if ($newParentId) { + $newParentId = (int) $newParentId; } $location = $this->locationService->loadLocation($locationId); @@ -47,8 +50,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->trashService->trash($location); $output->writeln('Location ' . $locationId . ' moved to trash.'); - if ($input->getOption('restore')) { - if ($input->getArgument('newParentId')) { + if ($restore) { + if ($newParentId) { $newParent = $this->locationService->loadLocation($newParentId); } else { $newParent = null; @@ -58,6 +61,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Restored from trash.'); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php index 4b4c8cd7a5..ca25dfe3f7 100644 --- a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php @@ -8,18 +8,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:update_content', description: 'Update provided content item with a new name' )] -class UpdateContentCommand extends Command +class UpdateContentCommand { - public function __construct(private readonly ContentService $contentService, private readonly UserService $userService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -31,13 +32,13 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $input->getArgument('contentId'); - $newName = $input->getArgument('newName'); + $contentId = (int) $contentId; + $newName = $newName; $contentInfo = $this->contentService->loadContentInfo($contentId); $contentDraft = $this->contentService->createContentDraft($contentInfo); @@ -51,6 +52,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Content item ' . $contentId . ' updated with new name: ' . $newName); - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php index eae8627271..32e02e09e8 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php @@ -8,18 +8,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:view_content', description: 'Output Field values on provided content item.' )] -class ViewContentCommand extends Command +class ViewContentCommand { - public function __construct(private readonly ContentService $contentService, private readonly ContentTypeService $contentTypeService, private readonly FieldTypeService $fieldTypeService) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly ContentTypeService $contentTypeService, + private readonly FieldTypeService $fieldTypeService + ) { } protected function configure(): void @@ -30,9 +31,9 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $contentId = (int) $input->getArgument('contentId'); + $contentId = (int) $contentId; $content = $this->contentService->loadContent($contentId); $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); @@ -46,6 +47,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln($valueHash); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php index 39a95ceb70..80057ca903 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php @@ -12,18 +12,22 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:view_metadata', description: 'Output various metadata about a content item.' )] -class ViewContentMetaDataCommand extends Command +class ViewContentMetaDataCommand { - public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService, private readonly URLAliasService $urlAliasService, private readonly UserService $userService, private readonly ObjectStateService $objectStateService, private readonly PermissionResolver $permissionResolver) - { - parent::__construct(); + public function __construct( + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly URLAliasService $urlAliasService, + private readonly UserService $userService, + private readonly ObjectStateService $objectStateService, + private readonly PermissionResolver $permissionResolver + ) { } protected function configure(): void @@ -34,12 +38,12 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $input->getArgument('contentId'); + $contentId = (int) $contentId; // Metadata $contentInfo = $this->contentService->loadContentInfo($contentId); @@ -105,6 +109,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln("Object state: $state->identifier"); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index 13a14de920..db297c3e8b 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -8,18 +8,19 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:workflow', description: 'Starts content in the selected workflow and makes the provided transition.' )] -class WorkflowCommand extends Command +class WorkflowCommand { - public function __construct(private readonly WorkflowServiceInterface $workflowService, private readonly WorkflowRegistryInterface $workflowRegistry, private readonly ContentService $contentService) - { - parent::__construct(); + public function __construct( + private readonly WorkflowServiceInterface $workflowService, + private readonly WorkflowRegistryInterface $workflowRegistry, + private readonly ContentService $contentService + ) { } protected function configure(): void @@ -32,11 +33,11 @@ protected function configure(): void ]); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { - $contentId = (int) $input->getArgument('contentId'); - $workflowName = $input->getArgument('workflowName'); - $transitionName = $input->getArgument('transitionName'); + $contentId = (int) $contentId; + $workflowName = $workflowName; + $transitionName = $transitionName; $content = $this->contentService->loadContent($contentId); @@ -58,6 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Moved ' . $content->getName() . ' through transition ' . $transitionName); } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php index 42744e3c4a..67478c33fd 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventSourceFactory.php @@ -4,9 +4,9 @@ use DateTime; use DateTimeInterface; -use Ibexa\Contracts\Calendar\EventSource\InMemoryEventSource; use Ibexa\Contracts\Calendar\EventCollection; use Ibexa\Contracts\Calendar\EventSource\EventSourceInterface; +use Ibexa\Contracts\Calendar\EventSource\InMemoryEventSource; class EventSourceFactory { diff --git a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php index 4b21a0e9e9..dc6be1db5e 100644 --- a/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php +++ b/code_samples/back_office/calendar/src/Calendar/Holidays/EventType.php @@ -2,8 +2,8 @@ namespace App\Calendar\Holidays; -use Ibexa\Contracts\Calendar\EventAction\EventActionCollection; use Ibexa\Contracts\Calendar\Event; +use Ibexa\Contracts\Calendar\EventAction\EventActionCollection; use Ibexa\Contracts\Calendar\EventType\EventTypeInterface; class EventType implements EventTypeInterface diff --git a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php index b4e4ef02e1..2caee0e946 100644 --- a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php +++ b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php @@ -10,15 +10,13 @@ use Ibexa\Contracts\Dashboard\DashboardServiceInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'doc:dashboard', description: 'Set a custom dashboard to user group.' )] -class DashboardCommand extends Command +class DashboardCommand { private readonly Locationservice $locationService; @@ -36,21 +34,14 @@ public function __construct( $this->contentService = $repository->getContentService(); $this->userService = $repository->getUserService(); $this->permissionResolver = $repository->getPermissionResolver(); - - parent::__construct(); - } - - public function configure(): void - { - $this - ->addArgument('dashboard', InputArgument::REQUIRED, 'Location ID of the dashboard model') - ->addArgument('group', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'User Group Content ID(s)'); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'dashboard', description: 'Location ID of the dashboard model')] + string $dashboard, #[\Symfony\Component\Console\Attribute\Argument(name: 'group', description: 'User Group Content ID(s)')] + string $group, OutputInterface $output): int { - $dashboardModelLocationId = (int)$input->getArgument('dashboard'); - $userGroupLocationIdList = array_map('intval', $input->getArgument('group')); + $dashboardModelLocationId = (int)$dashboard; + $userGroupLocationIdList = array_map('intval', $group); foreach ($userGroupLocationIdList as $userGroupLocationId) { try { @@ -66,6 +57,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - return self::SUCCESS; + return Command::SUCCESS; } } diff --git a/code_samples/back_office/images/src/SvgController.php b/code_samples/back_office/images/src/SvgController.php index 009b84cc4b..3d44e5b33b 100644 --- a/code_samples/back_office/images/src/SvgController.php +++ b/code_samples/back_office/images/src/SvgController.php @@ -18,8 +18,11 @@ class SvgController extends Controller { private const string CONTENT_TYPE_HEADER = 'image/svg+xml'; - public function __construct(private readonly ContentService $contentService, private readonly IOServiceInterface $ioService, private readonly TranslationHelper $translationHelper) - { + public function __construct( + private readonly ContentService $contentService, + private readonly IOServiceInterface $ioService, + private readonly TranslationHelper $translationHelper + ) { } /** diff --git a/code_samples/back_office/images/src/SvgExtension.php b/code_samples/back_office/images/src/SvgExtension.php index de6826d22f..173efcb5c3 100644 --- a/code_samples/back_office/images/src/SvgExtension.php +++ b/code_samples/back_office/images/src/SvgExtension.php @@ -6,7 +6,6 @@ use Symfony\Component\Routing\RouterInterface; use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; class SvgExtension extends AbstractExtension { @@ -17,17 +16,7 @@ public function __construct(protected RouterInterface $router) { } - /** - * @return \Twig\TwigFunction[] - */ - #[\Override] - public function getFunctions(): array - { - return [ - new TwigFunction('ibexa_svg_link', $this->generateLink(...)), - ]; - } - + #[\Twig\Attribute\AsTwigFunction('ibexa_svg_link')] public function generateLink(int $contentId, string $fieldIdentifier, string $filename): string { return $this->router->generate('app.svg_download', [ diff --git a/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php b/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php index c503416572..54a85470e1 100644 --- a/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php +++ b/code_samples/customer_portal/src/Corporate/EventSubscriber/VerifyStateEventSubscriber.php @@ -19,8 +19,11 @@ { private const string VERIFY_STATE = 'verify'; - public function __construct(private FormFactoryInterface $formFactory, private HandlerInterface $applicationStateHandler, private TranslatableNotificationHandlerInterface $notificationHandler) - { + public function __construct( + private FormFactoryInterface $formFactory, + private HandlerInterface $applicationStateHandler, + private TranslatableNotificationHandlerInterface $notificationHandler + ) { } public static function getSubscribedEvents(): array diff --git a/code_samples/discounts/src/Command/ManageDiscountsCommand.php b/code_samples/discounts/src/Command/ManageDiscountsCommand.php index c22c48227e..88221cafad 100644 --- a/code_samples/discounts/src/Command/ManageDiscountsCommand.php +++ b/code_samples/discounts/src/Command/ManageDiscountsCommand.php @@ -20,22 +20,20 @@ use Ibexa\Discounts\Value\DiscountRule\FixedAmount; use Ibexa\DiscountsCodes\Value\DiscountCondition\IsValidDiscountCode; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[\Symfony\Component\Console\Attribute\AsCommand(name: 'discounts:manage')] -final class ManageDiscountsCommand extends Command +final readonly class ManageDiscountsCommand { public function __construct( - private readonly UserService $userService, - private readonly PermissionResolver $permissionResolver, - private readonly DiscountServiceInterface $discountService, - private readonly DiscountCodeServiceInterface $discountCodeService + private UserService $userService, + private PermissionResolver $permissionResolver, + private DiscountServiceInterface $discountService, + private DiscountCodeServiceInterface $discountCodeService ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $this->permissionResolver->setCurrentUserReference( $this->userService->loadUserByLogin('admin') diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index c5897dfcdb..5a65cfb6f2 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -5,42 +5,31 @@ use Ibexa\Core\MVC\Symfony\View\Builder\ContentViewBuilder; use Ibexa\Core\MVC\Symfony\View\Renderer\TemplateRenderer; use Symfony\Component\Console\Attribute\AsCommand; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'app:view', description: 'Render the view of a content item' )] -class ViewCommand extends Command +class ViewCommand { - public function __construct( - private readonly ContentViewBuilder $contentViewBuilder, - private readonly TemplateRenderer $templateRenderer - ) { - parent::__construct(); - } - - protected function configure(): void + public function __construct(private readonly ContentViewBuilder $contentViewBuilder, private readonly TemplateRenderer $templateRenderer) { - $this - ->addOption('content-id', 'c', InputOption::VALUE_OPTIONAL, 'Content ID') - ->addOption('location-id', 'l', InputOption::VALUE_OPTIONAL, 'Location ID') - ->addOption('view-type', 't', InputOption::VALUE_OPTIONAL, 'View Type', 'line'); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(#[\Symfony\Component\Console\Attribute\Option] + $content_id, #[\Symfony\Component\Console\Attribute\Option] + $location_id, #[\Symfony\Component\Console\Attribute\Option] + $view_type, OutputInterface $output): int { - $contentId = $input->getOption('content-id'); - $locationId = $input->getOption('location-id'); + $contentId = $content_id; + $locationId = $location_id; if (empty($contentId) && empty($locationId)) { throw new \InvalidArgumentException('No Content ID nor Location ID given'); } $viewParameters = [ - 'viewType' => $input->getOption('view-type'), + 'viewType' => $view_type, '_controller' => 'ibexa_content:viewAction', ]; diff --git a/code_samples/multisite/siteaccess/AcmeExampleExtension.php b/code_samples/multisite/siteaccess/AcmeExampleExtension.php index 3c56d8023a..230b330026 100644 --- a/code_samples/multisite/siteaccess/AcmeExampleExtension.php +++ b/code_samples/multisite/siteaccess/AcmeExampleExtension.php @@ -11,7 +11,7 @@ final class AcmeExampleExtension extends Extension { - public const ACME_CONFIG_DIR = __DIR__ . '/../../../config/acme'; + public const string ACME_CONFIG_DIR = __DIR__ . '/../../../config/acme'; /** * @throws \Exception @@ -54,6 +54,7 @@ static function ($scopeSettings, $currentScope, ContextualizerInterface $context } /** @param array $config */ + #[\Override] public function getConfiguration(array $config, ContainerBuilder $container): Configuration { return new Configuration(); diff --git a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php index c53703e2fa..e20b09f9b5 100644 --- a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php +++ b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php @@ -12,8 +12,6 @@ use Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -21,7 +19,7 @@ name: 'doc:test:activity-log-context', description: 'Test activity log context usage' )] -class ActivityLogContextTestCommand extends Command +class ActivityLogContextTestCommand { public function __construct( private readonly ActivityLogServiceInterface $activityLogService, @@ -31,17 +29,12 @@ public function __construct( private readonly PermissionResolver $permissionResolver, private readonly UserService $userService ) { - parent::__construct(); } - protected function configure(): void + public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'id', description: 'A test number')] + string $id, OutputInterface $output): int { - $this->addArgument('id', InputArgument::REQUIRED, 'A test number'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $id = $input->getArgument('id'); + $id = $id; $this->permissionResolver->setCurrentUserReference($this->userService->loadUserByLogin('admin')); $this->activityLogService->prepareContext('my_feature', 'Operation description'); diff --git a/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php b/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php index ab8cec0ef0..e8004be454 100644 --- a/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php +++ b/code_samples/recent_activity/src/Command/DispatchMyFeatureEventCommand.php @@ -6,7 +6,6 @@ use App\MyFeature\MyFeature; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -14,14 +13,13 @@ name: 'app:test:throw-my-feature-event', description: 'Throw/Dispatch a MyFeatureEvent' )] -class DispatchMyFeatureEventCommand extends Command +class DispatchMyFeatureEventCommand { public function __construct(private readonly EventDispatcherInterface $eventDispatcher) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $event = new MyFeatureEvent(new MyFeature(['id' => 123, 'name' => 'Logged Name']), 'simulate'); $this->eventDispatcher->dispatch($event); diff --git a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php index 39b611ea2a..0880b9d68e 100644 --- a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php +++ b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php @@ -11,7 +11,6 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; @@ -19,14 +18,16 @@ name: 'app:monitor-content-creation', description: 'List last 10 log entry groups with creations in the last hour' )] -class MonitorRecentContentCreationCommand extends Command +class MonitorRecentContentCreationCommand { - public function __construct(private readonly ActivityLogServiceInterface $activityLogService, private readonly PermissionResolver $permissionResolver, private readonly UserService $userService) - { - parent::__construct(); + public function __construct( + private readonly ActivityLogServiceInterface $activityLogService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService + ) { } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(OutputInterface $output): int { $query = new Query([ new Criterion\ObjectCriterion(Content::class), diff --git a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php index 3e72e3970e..8d04f283fb 100644 --- a/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php +++ b/code_samples/tutorials/page_tutorial/src/Event/RandomBlockListener.php @@ -16,8 +16,11 @@ class RandomBlockListener implements EventSubscriberInterface { - public function __construct(private readonly ContentService $contentService, private readonly LocationService $locationService, private readonly SearchService $searchService) - { + public function __construct( + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly SearchService $searchService + ) { } public static function getSubscribedEvents(): array From 4afb98f6596e1b84d9a27e8fccda18523a4b3e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 24 Jul 2025 20:05:08 +0200 Subject: [PATCH 22/26] Manual fixes --- .php-cs-fixer.php | 3 ++ .../ActionConfigurationCreateCommand.php | 8 +++-- .../src/Command/AddMissingAltTextCommand.php | 8 +++-- .../src/Command/CatalogCommand.php | 18 +++-------- .../src/Command/CurrencyCommand.php | 22 ++++--------- .../src/Command/ProductAssetCommand.php | 17 +++------- .../src/Command/ProductCommand.php | 21 ++++-------- .../src/Command/ProductPriceCommand.php | 24 +++++--------- .../src/Command/ProductTypeCommand.php | 18 +++-------- .../src/Command/ProductVariantCommand.php | 17 +++------- .../src/Command/VatCommand.php | 16 +++------- .../Command/AddLocationToContentCommand.php | 21 ++++-------- .../src/Command/BookmarkCommand.php | 22 ++++--------- .../src/Command/BrowseLocationsCommand.php | 18 +++-------- .../src/Command/CreateContentCommand.php | 27 ++++++---------- .../src/Command/CreateContentTypeCommand.php | 32 +++++++------------ .../src/Command/CreateImageCommand.php | 29 ++++++----------- .../src/Command/DeleteContentCommand.php | 17 +++------- .../src/Command/FilterCommand.php | 17 +++------- .../src/Command/FilterLocationCommand.php | 17 +++------- .../src/Command/FindComplexCommand.php | 24 ++++---------- .../src/Command/FindContentCommand.php | 18 +++-------- .../src/Command/FindInTrashCommand.php | 18 +++-------- .../src/Command/HideLocationCommand.php | 18 ++++------- .../src/Command/MoveContentCommand.php | 21 ++++-------- .../src/Command/ObjectStateCommand.php | 23 +++++-------- .../src/Command/SectionCommand.php | 24 ++++---------- .../src/Command/SetMainLocationCommand.php | 21 ++++-------- .../src/Command/TranslateContentCommand.php | 28 ++++++---------- .../src/Command/TrashContentCommand.php | 27 +++++----------- .../src/Command/UpdateContentCommand.php | 21 ++++-------- .../src/Command/ViewContentCommand.php | 18 +++-------- .../Command/ViewContentMetaDataCommand.php | 18 +++-------- .../src/Command/WorkflowCommand.php | 20 ++++-------- .../src/Command/DashboardCommand.php | 12 ++++--- .../src/Command/ViewCommand.php | 12 ++++--- .../Command/ActivityLogContextTestCommand.php | 3 +- .../MonitorRecentContentCreationCommand.php | 5 +-- phpstan-baseline.neon | 6 ---- 39 files changed, 229 insertions(+), 480 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 38b8df8e41..bc76d9099e 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -11,6 +11,9 @@ $configFactory = new InternalConfigFactory(); $configFactory->withRules([ 'header_comment' => false, + 'method_argument_space' => [ + 'attribute_placement' => 'same_line' + ] ]); return $configFactory diff --git a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php index 6190323003..59c0ae9772 100644 --- a/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php +++ b/code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php @@ -13,6 +13,7 @@ use Ibexa\Contracts\Core\Collection\ArrayMap; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\OutputInterface; @@ -31,9 +32,10 @@ public function __construct( ) { } - public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'user', description: 'Login of the user executing the actions')] - ?string $user, OutputInterface $output): int - { + public function __invoke( + #[Argument(name: 'user', description: 'Login of the user executing the actions')] string $user, + OutputInterface $output + ): int { $user = $user; $this->permissionResolver->setCurrentUserReference($this->userService->loadUserByLogin($user)); diff --git a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php index 81b5991c62..67084cc909 100644 --- a/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php +++ b/code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php @@ -22,6 +22,7 @@ use Ibexa\Contracts\Core\Repository\Values\Filter\Filter; use Ibexa\Core\FieldType\Image\Value; use Ibexa\Core\IO\IOBinarydataHandler; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\OutputInterface; @@ -43,9 +44,10 @@ public function __construct( ) { } - public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'user', description: 'Login of the user executing the actions')] - ?string $user, OutputInterface $output): int - { + public function __invoke( + #[Argument(name: 'user', description: 'Login of the user executing the actions')] string $user, + OutputInterface $output + ): int { $this->setUser($user); $modifiedImages = $this->getModifiedImages(); diff --git a/code_samples/api/product_catalog/src/Command/CatalogCommand.php b/code_samples/api/product_catalog/src/Command/CatalogCommand.php index fd440a051f..ae2563a6ac 100644 --- a/code_samples/api/product_catalog/src/Command/CatalogCommand.php +++ b/code_samples/api/product_catalog/src/Command/CatalogCommand.php @@ -13,9 +13,9 @@ use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; use Ibexa\ProductCatalog\Local\Repository\Values\Catalog\Status; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -31,21 +31,13 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('catalogIdentifier', InputArgument::REQUIRED, 'Catalog identifier'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Catalog identifier')] string $catalogIdentifier + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $catalogIdentifier = $catalogIdentifier; - // Create catalog $catalogCriterion = new Criterion\LogicalAnd( [ diff --git a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php index 95515d4b0f..56a9ba4b47 100644 --- a/code_samples/api/product_catalog/src/Command/CurrencyCommand.php +++ b/code_samples/api/product_catalog/src/Command/CurrencyCommand.php @@ -7,9 +7,9 @@ use Ibexa\Contracts\ProductCatalog\CurrencyServiceInterface; use Ibexa\Contracts\ProductCatalog\Values\Currency\CurrencyCreateStruct; use Ibexa\Contracts\ProductCatalog\Values\Currency\CurrencyUpdateStruct; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -24,23 +24,14 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('currencyCode', InputArgument::REQUIRED, 'Currency code'), - new InputArgument('newCurrencyCode', InputArgument::REQUIRED, 'New currency code'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Currency code')] string $currencyCode, + #[Argument(description: 'New currency code')] string $newCurrencyCode + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $currencyCode = $currencyCode; - $newCurrencyCode = $newCurrencyCode; - $currency = $this->currencyService->getCurrencyByCode($currencyCode); $output->writeln('Currency ID: ' . $currency->getId()); @@ -56,6 +47,7 @@ public function __invoke(OutputInterface $output): int $this->currencyService->updateCurrency($currency, $currencyUpdateStruct); + assert($newCurrencyCode !== '', 'Currency code cannot be empty'); $currencyCreateStruct = new CurrencyCreateStruct($newCurrencyCode, 2, true); $this->currencyService->createCurrency($currencyCreateStruct); diff --git a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php index a89de9a20f..4c888b81f0 100644 --- a/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductAssetCommand.php @@ -8,9 +8,9 @@ use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\ProductCatalog\AssetServiceInterface; use Ibexa\Contracts\ProductCatalog\ProductServiceInterface; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -26,20 +26,13 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('productCode', InputArgument::REQUIRED, 'Product code'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Product code')] string $productCode + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $productCode; $product = $this->productService->getProduct($productCode); $singleAsset = $this->assetService->getAsset($product, '1'); diff --git a/code_samples/api/product_catalog/src/Command/ProductCommand.php b/code_samples/api/product_catalog/src/Command/ProductCommand.php index d502f3ef97..99f0c6d6ea 100644 --- a/code_samples/api/product_catalog/src/Command/ProductCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductCommand.php @@ -13,9 +13,9 @@ use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery; use Ibexa\Contracts\ProductCatalog\Values\Product\Query\Criterion; use Ibexa\Contracts\ProductCatalog\Values\Product\Query\SortClause; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -33,23 +33,14 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('productCode', InputArgument::REQUIRED, 'Product code'), - new InputArgument('productType', InputArgument::REQUIRED, 'Product type'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Product code')] string $productCode, + #[Argument(description: 'Product type')] string $productType + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $productCode; - $productType = $productType; - $product = $this->productService->getProduct($productCode); $output->writeln('Product with code ' . $product->getCode() . ' is ' . $product->getName()); diff --git a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php index 6051d7014c..b71a3e106a 100644 --- a/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductPriceCommand.php @@ -16,9 +16,9 @@ use Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\LogicalOr; use Ibexa\Contracts\ProductCatalog\Values\Price\Query\Criterion\Product; use Money; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -36,24 +36,16 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('productCode', InputArgument::REQUIRED, 'Product code'), - new InputArgument('currencyCode', InputArgument::REQUIRED, 'Currency code'), - new InputArgument('newCurrencyCode', InputArgument::REQUIRED, 'New currency code'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Product code')] string $productCode, + #[Argument(description: 'Currency code')] string $currencyCode, + #[Argument(description: 'New currency code')] string $newCurrencyCode + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $productCode; $product = $this->productService->getProduct($productCode); - $currencyCode = $currencyCode; $currency = $this->currencyService->getCurrencyByCode($currencyCode); $productPrice = $product->getPrice(); @@ -64,9 +56,9 @@ public function __invoke(OutputInterface $output): int $output->writeln('Price for ' . $product->getName() . ' in ' . $currencyCode . ' is ' . $productPrice); - $newCurrencyCode = $newCurrencyCode; $newCurrency = $this->currencyService->getCurrencyByCode($newCurrencyCode); + assert($newCurrencyCode !== '', 'Currency code cannot be empty'); $money = new Money\Money(50000, new Money\Currency($newCurrencyCode)); $priceCreateStruct = new ProductPriceCreateStruct($product, $newCurrency, $money, null, null); diff --git a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php index ebaf3f757c..32d711316a 100644 --- a/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductTypeCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\ProductCatalog\ProductTypeServiceInterface; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -22,21 +22,13 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('productTypeIdentifier', InputArgument::REQUIRED, 'Product type identifier'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Product type identifier')] string $productTypeIdentifier + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productTypeIdentifier = $productTypeIdentifier; - $productType = $this->productTypeService->getProductType($productTypeIdentifier); $output->writeln($productType->getName()); diff --git a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php index c822bd8ffc..29c1d74893 100644 --- a/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php +++ b/code_samples/api/product_catalog/src/Command/ProductVariantCommand.php @@ -10,9 +10,9 @@ use Ibexa\Contracts\ProductCatalog\Local\Values\Product\ProductVariantCreateStruct; use Ibexa\Contracts\ProductCatalog\ProductServiceInterface; use Ibexa\Contracts\ProductCatalog\Values\Product\ProductVariantQuery; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -28,20 +28,13 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('productCode', InputArgument::REQUIRED, 'Product code'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Product code')] string $productCode + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $productCode = $productCode; $product = $this->productService->getProduct($productCode); // Get variants diff --git a/code_samples/api/product_catalog/src/Command/VatCommand.php b/code_samples/api/product_catalog/src/Command/VatCommand.php index 0dcfb80b8d..91c57e3a88 100644 --- a/code_samples/api/product_catalog/src/Command/VatCommand.php +++ b/code_samples/api/product_catalog/src/Command/VatCommand.php @@ -6,9 +6,9 @@ use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\ProductCatalog\RegionServiceInterface; use Ibexa\Contracts\ProductCatalog\VatServiceInterface; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -24,16 +24,10 @@ public function __construct( ) { } - public function configure(): void - { - $this - ->setDefinition([ - new InputArgument('productCode', InputArgument::REQUIRED, 'Product code'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Product code')] string $productCode + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); diff --git a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php index 0650f8d19a..87e1c8b3db 100644 --- a/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php @@ -6,9 +6,9 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -25,23 +25,14 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'Parent Location ID'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Content ID')] int $contentId, + #[Argument(description: 'Parent Location ID')] int $parentLocationId, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $parentLocationId = (int) $parentLocationId; - $contentId = (int) $contentId; - $locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocationId); $locationCreateStruct->priority = 500; diff --git a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php index a01b7be32e..f1fb275ec7 100644 --- a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php +++ b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php @@ -4,10 +4,10 @@ use Ibexa\Contracts\Core\Repository\BookmarkService; use Ibexa\Contracts\Core\Repository\LocationService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Attribute\Option; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -19,19 +19,11 @@ public function __construct(private readonly BookmarkService $bookmarkService, p { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location id'), - ]) - ->addOption('delete', 'd', InputOption::VALUE_NONE, 'Delete the created bookmark?', null); - } - - public function __invoke(#[\Symfony\Component\Console\Attribute\Option] - $delete, OutputInterface $output): int - { - $locationId = (int) $locationId; + public function __invoke( + #[Argument(description: 'Location id')] int $locationId, + #[Option(shortcut: 'd', description: 'Delete the created bookmark?')] bool $delete, + OutputInterface $output + ): int { $location = $this->locationService->loadLocation($locationId); $this->bookmarkService->createBookmark($location); diff --git a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php index 67fecce68a..aa67a998ad 100644 --- a/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php +++ b/code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php @@ -4,9 +4,9 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\Values\Content\Location; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -19,14 +19,6 @@ public function __construct(private readonly LocationService $locationService) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location ID to browse from'), - ]); - } - private function browseLocation(Location $location, OutputInterface $output, int $depth = 0): void { $output->writeln($location->contentInfo->name); @@ -37,10 +29,10 @@ private function browseLocation(Location $location, OutputInterface $output, int } } - public function __invoke(OutputInterface $output): int - { - $locationId = (int) $locationId; - + public function __invoke( + #[Argument(description: 'Location ID to browse from')] int $locationId, + OutputInterface $output + ): int { $location = $this->locationService->loadLocation($locationId); $this->browseLocation($location, $output); diff --git a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php index 9b83cfaba5..11c79e185c 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php @@ -7,10 +7,10 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Attribute\Option; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -27,26 +27,17 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'Parent Location ID'), - new InputArgument('contentType', InputArgument::REQUIRED, 'Identifier of a content type with a Name and Description Field'), - new InputArgument('name', InputArgument::REQUIRED, 'Content for the Name field'), - ]) - ->addOption('publish', 'p', InputOption::VALUE_NONE, 'Do you want to publish the content item?'); - } - - public function __invoke(#[\Symfony\Component\Console\Attribute\Option] - $publish, OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Parent Location ID')] int $parentLocationId, + #[Argument(description: 'Identifier of a content type with a Name and Description Field')] string $contentType, + #[Argument(description: 'Content for the Name field')] string $name, + #[Option(shortcut: 'p', description: 'Do you want to publish the content item?')] bool $publish, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $parentLocationId = (int) $parentLocationId; $contentTypeIdentifier = $contentType; - $name = $name; $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, 'eng-GB'); diff --git a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php index ea0c5e07ba..1f434e2de3 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php @@ -6,10 +6,10 @@ use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Attribute\Option; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -24,34 +24,26 @@ public function __construct( ) { } - protected function configure(): void - { - $this->setDefinition([ - new InputArgument('identifier', InputArgument::REQUIRED, 'Content type identifier'), - new InputArgument('group_identifier', InputArgument::REQUIRED, 'Content type group identifier'), - new InputArgument('copy_identifier', InputArgument::OPTIONAL, 'Identifier of the CT copy'), - ]) - ->addOption('copy', 'c', InputOption::VALUE_NONE, 'Do you want to make a copy of the content type?'); - } - - public function __invoke(#[\Symfony\Component\Console\Attribute\Option] - $copy, OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Content type identifier')] string $identifier, + #[Argument(description: 'Content type group identifier')] string $group_identifier, + #[Argument(description: 'Identifier of the CT copy')] ?string $copy_identifier, + #[Option(shortcut: 'c', description: 'Do you want to make a copy of the content type?')] bool $copy, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); $groupIdentifier = $group_identifier; $contentTypeIdentifier = $identifier; - if ($copy_identifier) { - $copyIdentifier = $copy_identifier; - } + $copyIdentifier = $copy_identifier; try { $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier($groupIdentifier); } catch (NotFoundException) { $output->writeln("Content type group with identifier $groupIdentifier not found"); - return self::FAILURE; + return Command::FAILURE; } $contentTypeCreateStruct = $this->contentTypeService->newContentTypeCreateStruct($contentTypeIdentifier); @@ -88,7 +80,7 @@ public function __invoke(#[\Symfony\Component\Console\Attribute\Option] $copyDraft = $this->contentTypeService->createContentTypeDraft($copy); $copyUpdateStruct = $this->contentTypeService->newContentTypeUpdateStruct(); $copyUpdateStruct->identifier = $copyIdentifier; - $copyUpdateStruct->names = ['eng-GB' => $copyIdentifier]; + $copyUpdateStruct->names = ['eng-GB' => $copyIdentifier ?? $contentTypeIdentifier . '_copy']; $this->contentTypeService->updateContentTypeDraft($copyDraft, $copyUpdateStruct); $this->contentTypeService->publishContentTypeDraft($copyDraft); $output->writeln('Copy of the new CT created with identifier ' . $copyIdentifier); diff --git a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php index 677941b2b7..98f4b253ac 100644 --- a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php @@ -8,10 +8,10 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Core\FieldType\Image\Value; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Attribute\Option; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -28,26 +28,15 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('name', InputArgument::REQUIRED, 'Content for the Name field'), - new InputArgument('file', InputArgument::REQUIRED, 'Content for the Image field'), - ]) - ->addOption('publish', 'p', InputOption::VALUE_NONE, 'Do you want to publish the content item?'); - } - - public function __invoke(#[\Symfony\Component\Console\Attribute\Option] - $publish, OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Content for the Name field')] string $name, + #[Argument(description: 'Content for the Image field')] string $file, + #[Option(shortcut: 'p', description: 'Do you want to publish the content item?')] bool $publish, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $name = $name; - $file = $file; - $publish = $publish; - $contentType = $this->contentTypeService->loadContentTypeByIdentifier('image'); $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, 'eng-GB'); $contentCreateStruct->setField('name', $name); @@ -67,7 +56,7 @@ public function __invoke(#[\Symfony\Component\Console\Attribute\Option] $output->writeln('Created a draft of ' . $contentType->getName() . ' with name ' . $draft->getName()); - if ($publish == true) { + if ($publish) { $content = $this->contentService->publishVersion($draft->versionInfo); $output->writeln('Published content item ' . $content->getName()); } diff --git a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php index 21e8a81615..e497d59131 100644 --- a/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/DeleteContentCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -22,20 +22,13 @@ public function __construct( ) { } - protected function configure(): void - { - $this->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location to delete'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Location to delete')] int $locationId, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $locationId; - $location = $this->locationService->loadLocation($locationId); $this->locationService->deleteLocation($location); diff --git a/code_samples/api/public_php_api/src/Command/FilterCommand.php b/code_samples/api/public_php_api/src/Command/FilterCommand.php index 6626fa835d..e1962f5590 100644 --- a/code_samples/api/public_php_api/src/Command/FilterCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterCommand.php @@ -7,9 +7,9 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Core\Repository\Values\Filter\Filter; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -22,17 +22,10 @@ public function __construct(private readonly ContentService $contentService) { } - public function configure(): void - { - $this->setDefinition([ - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), - ]); - } - - public function __invoke(OutputInterface $output): int - { - $parentLocationId = (int)$parentLocationId; - + public function __invoke( + #[Argument(description: 'ID of the parent Location')] int $parentLocationId, + OutputInterface $output + ): int { $filter = new Filter(); $filter ->withCriterion(new Criterion\ParentLocationId($parentLocationId)) diff --git a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php index 2da30e76a8..11a0691306 100644 --- a/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/FilterLocationCommand.php @@ -7,9 +7,9 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Core\Repository\Values\Filter\Filter; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -22,17 +22,10 @@ public function __construct(private readonly LocationService $locationService) { } - public function configure(): void - { - $this->setDefinition([ - new InputArgument('parentLocationId', InputArgument::REQUIRED, 'ID of the parent Location'), - ]); - } - - public function __invoke(OutputInterface $output): int - { - $parentLocationId = (int)$parentLocationId; - + public function __invoke( + #[Argument(description: 'ID of the parent Location')] int $parentLocationId, + OutputInterface $output + ): int { $filter = new Filter(); $filter ->withCriterion(new Criterion\ParentLocationId($parentLocationId)) diff --git a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php index 48f4a6a960..5040f4e47a 100644 --- a/code_samples/api/public_php_api/src/Command/FindComplexCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindComplexCommand.php @@ -7,9 +7,9 @@ use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -22,22 +22,12 @@ public function __construct(private readonly SearchService $searchService, priva { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, ''), - new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), - new InputArgument('text', InputArgument::REQUIRED, ''), - ]); - } - - public function __invoke(OutputInterface $output): int - { - $locationId = (int) $locationId; - $contentTypeIdentifier = $contentTypeIdentifier; - $text = $text; - + public function __invoke( + #[Argument(description: 'Location ID')] int $locationId, + #[Argument(description: 'Content type identifier')] string $contentTypeIdentifier, + #[Argument(description: 'Search text')] string $text, + OutputInterface $output + ): int { $query = new LocationQuery(); $query->query = new Criterion\LogicalAnd([ diff --git a/code_samples/api/public_php_api/src/Command/FindContentCommand.php b/code_samples/api/public_php_api/src/Command/FindContentCommand.php index e6f940e4d4..2663ea0247 100644 --- a/code_samples/api/public_php_api/src/Command/FindContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindContentCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\SearchService; use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -20,18 +20,10 @@ public function __construct(private readonly SearchService $searchService) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier'), - ]); - } - - public function __invoke(OutputInterface $output): int - { - $contentTypeIdentifier = $contentTypeIdentifier; - + public function __invoke( + #[Argument(description: 'Content type identifier')] string $contentTypeIdentifier, + OutputInterface $output + ): int { $query = new LocationQuery(); $query->filter = new Criterion\ContentTypeIdentifier($contentTypeIdentifier); diff --git a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php index 851033a7cf..1c56f5a560 100644 --- a/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php +++ b/code_samples/api/public_php_api/src/Command/FindInTrashCommand.php @@ -4,9 +4,9 @@ use Ibexa\Contracts\Core\Repository\TrashService; use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -19,18 +19,10 @@ public function __construct(private readonly TrashService $trashService) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentTypeId', InputArgument::REQUIRED, 'Content type ID'), - ]); - } - - public function __invoke(OutputInterface $output): int - { - $contentTypeId = (int) $contentTypeId; - + public function __invoke( + #[Argument(description: 'Content type ID')] int $contentTypeId, + OutputInterface $output + ): int { $query = new Query(); $query->filter = new Query\Criterion\ContentTypeId($contentTypeId); diff --git a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php index 63d8403fb4..433a235c1a 100644 --- a/code_samples/api/public_php_api/src/Command/HideLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/HideLocationCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -23,20 +23,14 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('location_id', InputArgument::REQUIRED, 'Location ID'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Location ID')] int $location_id, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $location_id; + $locationId = $location_id; $location = $this->locationService->loadLocation($locationId); diff --git a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php index a18a7d46dc..2e3dc81b2a 100644 --- a/code_samples/api/public_php_api/src/Command/MoveContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/MoveContentCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -23,23 +23,14 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location to copy'), - new InputArgument('targetLocationId', InputArgument::REQUIRED, 'Target to copy or move to'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Location to copy')] int $locationId, + #[Argument(description: 'Target to copy or move to')] int $targetLocationId, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $locationId; - $targetLocationId = (int) $targetLocationId; - $sourceLocation = $this->locationService->loadLocation($locationId); $targetLocation = $this->locationService->loadLocation($targetLocationId); $this->locationService->moveSubtree($sourceLocation, $targetLocation); diff --git a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php index a9ae501d00..2dda18c2ca 100644 --- a/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php +++ b/code_samples/api/public_php_api/src/Command/ObjectStateCommand.php @@ -6,9 +6,9 @@ use Ibexa\Contracts\Core\Repository\ObjectStateService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -25,18 +25,12 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('objectStateGroupIdentifier', InputArgument::REQUIRED, 'Identifier of new OG group to create'), - new InputArgument('objectStateIdentifier', InputArgument::REQUIRED, 'Identifier(s) of a new Object State'), - new InputArgument('contentID', InputArgument::OPTIONAL, 'Content ID'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Identifier of new OG group to create')] string $objectStateGroupIdentifier, + #[Argument(description: 'Identifier(s) of a new Object State')] string $objectStateIdentifier, + #[Argument(description: 'Content ID')] ?int $contentID, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); @@ -46,7 +40,6 @@ public function __invoke(OutputInterface $output): int $output->writeln($objectStateGroup->getName()); $output->writeln($objectState->getName()); - $objectStateGroupIdentifier = $objectStateGroupIdentifier; $objectStateIdentifierList = explode(',', (string) $objectStateIdentifier); $objectStateGroupStruct = $this->objectStateService->newObjectStateGroupCreateStruct($objectStateGroupIdentifier); @@ -67,7 +60,7 @@ public function __invoke(OutputInterface $output): int } if ($contentID) { - $contentId = (int) $contentID; + $contentId = $contentID; $objectStateToAssign = $objectStateIdentifierList[0]; $contentInfo = $this->contentService->loadContentInfo($contentId); $objectStateGroup = $this->objectStateService->loadObjectStateGroupByIdentifier($objectStateGroupIdentifier); diff --git a/code_samples/api/public_php_api/src/Command/SectionCommand.php b/code_samples/api/public_php_api/src/Command/SectionCommand.php index 8bbc69188d..313129d9da 100644 --- a/code_samples/api/public_php_api/src/Command/SectionCommand.php +++ b/code_samples/api/public_php_api/src/Command/SectionCommand.php @@ -9,9 +9,9 @@ use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -29,25 +29,15 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('sectionName', InputArgument::REQUIRED, 'Name of the new Section'), - new InputArgument('sectionIdentifier', InputArgument::REQUIRED, 'Identifier of the new Section'), - new InputArgument('contentId', InputArgument::REQUIRED, 'Content id'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Name of the new Section')] string $sectionName, + #[Argument(description: 'Identifier of the new Section')] string $sectionIdentifier, + #[Argument(description: 'Content id')] int $contentId, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $sectionName = $sectionName; - $sectionIdentifier = $sectionIdentifier; - $contentId = (int) $contentId; - $sectionCreateStruct = $this->sectionService->newSectionCreateStruct(); $sectionCreateStruct->name = $sectionName; $sectionCreateStruct->identifier = $sectionIdentifier; diff --git a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php index 52fd5dd4df..b24206e287 100644 --- a/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php +++ b/code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -23,23 +23,14 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'The Content ID'), - new InputArgument('locationId', InputArgument::REQUIRED, 'One of the Locations of the Content'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'The Content ID')] int $contentId, + #[Argument(description: 'One of the Locations of the Content')] int $locationId, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $contentId; - $locationId = (int) $locationId; - $contentInfo = $this->contentService->loadContentInfo($contentId); $contentUpdateStruct = $this->contentService->newContentMetadataUpdateStruct(); diff --git a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php index 494c9f9734..74dff5d8cb 100644 --- a/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TranslateContentCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -22,28 +22,18 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'ID of content to be updated'), - new InputArgument('language', InputArgument::REQUIRED, 'Language to add'), - new InputArgument('nameInNewLanguage', InputArgument::REQUIRED, 'Content name in new language'), - new InputArgument('secondaryLanguage', InputArgument::OPTIONAL, 'Secondary language to add'), - new InputArgument('nameInSecondaryLanguage', InputArgument::OPTIONAL, 'Content name in secondary language'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'ID of content to be updated')] int $contentId, + #[Argument(description: 'Language to add')] string $language, + #[Argument(description: 'Content name in new language')] string $nameInNewLanguage, + #[Argument(description: 'Secondary language to add')] ?string $secondaryLanguage, + #[Argument(description: 'Content name in secondary language')] ?string $nameInSecondaryLanguage, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $contentId; - $language = $language; $newName = $nameInNewLanguage; - $secondaryLanguage = $secondaryLanguage; - $nameInSecondaryLanguage = $nameInSecondaryLanguage; $contentInfo = $this->contentService->loadContentInfo($contentId); $contentDraft = $this->contentService->createContentDraft($contentInfo); diff --git a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php index 2f98505e9f..5b6bb27c74 100644 --- a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php @@ -6,10 +6,10 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\TrashService; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Attribute\Option; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -25,26 +25,15 @@ public function __construct( ) { } - protected function configure(): void - { - $this->setDefinition([ - new InputArgument('locationId', InputArgument::REQUIRED, 'Location to trash'), - new InputArgument('newParentId', InputArgument::OPTIONAL, 'New Location to restore under'), - ]) - ->addOption('restore', 'r', InputOption::VALUE_NONE, 'Do you want to restore the content item?'); - } - - public function __invoke(#[\Symfony\Component\Console\Attribute\Option] - $restore, OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Location to trash')] int $locationId, + #[Argument(description: 'New Location to restore under')] ?int $newParentId, + #[Option(shortcut: 'r', description: 'Do you want to restore the content item?')] bool $restore, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $locationId = (int) $locationId; - if ($newParentId) { - $newParentId = (int) $newParentId; - } - $location = $this->locationService->loadLocation($locationId); $this->trashService->trash($location); diff --git a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php index ca25dfe3f7..4932fb067b 100644 --- a/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/UpdateContentCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -23,23 +23,14 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), - new InputArgument('newName', InputArgument::REQUIRED, 'New name for the updated content item'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'Content ID')] int $contentId, + #[Argument(description: 'New name for the updated content item')] string $newName, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $contentId; - $newName = $newName; - $contentInfo = $this->contentService->loadContentInfo($contentId); $contentDraft = $this->contentService->createContentDraft($contentInfo); diff --git a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php index 32e02e09e8..eee9b2c3c0 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\FieldTypeService; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -23,18 +23,10 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Location ID'), - ]); - } - - public function __invoke(OutputInterface $output): int - { - $contentId = (int) $contentId; - + public function __invoke( + #[Argument(description: 'Content ID')] int $contentId, + OutputInterface $output + ): int { $content = $this->contentService->loadContent($contentId); $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); diff --git a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php index 80057ca903..c54435f572 100644 --- a/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php +++ b/code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php @@ -9,9 +9,9 @@ use Ibexa\Contracts\Core\Repository\URLAliasService; use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -30,21 +30,13 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'An existing content ID'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + #[Argument(description: 'An existing content ID')] int $contentId, + OutputInterface $output + ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); - $contentId = (int) $contentId; - // Metadata $contentInfo = $this->contentService->loadContentInfo($contentId); diff --git a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php index db297c3e8b..7c867a4c5e 100644 --- a/code_samples/api/public_php_api/src/Command/WorkflowCommand.php +++ b/code_samples/api/public_php_api/src/Command/WorkflowCommand.php @@ -5,9 +5,9 @@ use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Workflow\Registry\WorkflowRegistryInterface; use Ibexa\Contracts\Workflow\Service\WorkflowServiceInterface; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -23,18 +23,12 @@ public function __construct( ) { } - protected function configure(): void - { - $this - ->setDefinition([ - new InputArgument('contentId', InputArgument::REQUIRED, 'Content ID'), - new InputArgument('workflowName', InputArgument::REQUIRED, 'Workflow identifier'), - new InputArgument('transitionName', InputArgument::REQUIRED, 'Transition name'), - ]); - } - - public function __invoke(OutputInterface $output): int - { + public function __invoke( + OutputInterface $output, + #[Argument(description: 'Content ID')] int $contentId, + #[Argument(description: 'Workflow identifier')] string $workflowName, + #[Argument(description: 'Transition name')] string $transitionName + ): int { $contentId = (int) $contentId; $workflowName = $workflowName; $transitionName = $transitionName; diff --git a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php index 2caee0e946..4a35b42b38 100644 --- a/code_samples/back_office/dashboard/src/Command/DashboardCommand.php +++ b/code_samples/back_office/dashboard/src/Command/DashboardCommand.php @@ -8,6 +8,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\Dashboard\DashboardServiceInterface; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\OutputInterface; @@ -36,12 +37,13 @@ public function __construct( $this->permissionResolver = $repository->getPermissionResolver(); } - public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'dashboard', description: 'Location ID of the dashboard model')] - string $dashboard, #[\Symfony\Component\Console\Attribute\Argument(name: 'group', description: 'User Group Content ID(s)')] - string $group, OutputInterface $output): int - { + public function __invoke( + #[Argument(name: 'dashboard', description: 'Location ID of the dashboard model')] string $dashboard, + #[Argument(name: 'group', description: 'User Group Content ID(s)')] string $group, + OutputInterface $output + ): int { $dashboardModelLocationId = (int)$dashboard; - $userGroupLocationIdList = array_map('intval', $group); + $userGroupLocationIdList = array_map('intval', explode(',', $group)); foreach ($userGroupLocationIdList as $userGroupLocationId) { try { diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index 5a65cfb6f2..d54eadc079 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -5,6 +5,7 @@ use Ibexa\Core\MVC\Symfony\View\Builder\ContentViewBuilder; use Ibexa\Core\MVC\Symfony\View\Renderer\TemplateRenderer; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Attribute\Option; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( @@ -17,11 +18,12 @@ public function __construct(private readonly ContentViewBuilder $contentViewBuil { } - public function __invoke(#[\Symfony\Component\Console\Attribute\Option] - $content_id, #[\Symfony\Component\Console\Attribute\Option] - $location_id, #[\Symfony\Component\Console\Attribute\Option] - $view_type, OutputInterface $output): int - { + public function __invoke( + #[Option] int $content_id, + #[Option] int $location_id, + #[Option] string $view_type, + OutputInterface $output + ): int { $contentId = $content_id; $locationId = $location_id; if (empty($contentId) && empty($locationId)) { diff --git a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php index e20b09f9b5..b8f8b243a8 100644 --- a/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php +++ b/code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\UserService; use Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct; +use Symfony\Component\Console\Attribute\Argument; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Output\OutputInterface; @@ -31,7 +32,7 @@ public function __construct( ) { } - public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'id', description: 'A test number')] + public function __invoke(#[Argument(name: 'id', description: 'A test number')] string $id, OutputInterface $output): int { $id = $id; diff --git a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php index 0880b9d68e..fe8c30145c 100644 --- a/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php +++ b/code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php @@ -11,7 +11,6 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( @@ -27,7 +26,7 @@ public function __construct( ) { } - public function __invoke(OutputInterface $output): int + public function __invoke(SymfonyStyle $io): int { $query = new Query([ new Criterion\ObjectCriterion(Content::class), @@ -35,8 +34,6 @@ public function __invoke(OutputInterface $output): int new Criterion\LoggedAtCriterion(new \DateTime('- 1 hour'), Criterion\LoggedAtCriterion::GTE), ], [new LoggedAtSortClause(LoggedAtSortClause::DESC)], 0, 10); - $io = new SymfonyStyle($input, $output); - $this->permissionResolver->setCurrentUserReference($this->userService->loadUserByLogin('admin')); foreach ($this->activityLogService->findGroups($query) as $activityLogGroup) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 12b238568c..9359f1762c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -54,12 +54,6 @@ parameters: count: 1 path: code_samples/api/public_php_api/src/Command/CalendarCommand.php - - - message: '#^Variable \$copyIdentifier might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php - - message: '#^Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\URL\:\:\$url\.$#' identifier: property.protected From a88fc803c0989a6dff1ec32b0df1ce35cfc04a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Tue, 29 Jul 2025 16:23:33 +0200 Subject: [PATCH 23/26] Adjusted code sample usage --- .../api/commerce/src/Command/CartCommand.php | 2 +- docs/ai_actions/extend_ai_actions.md | 8 +-- docs/api/php_api/php_api.md | 2 +- docs/commerce/cart/cart_api.md | 36 +++++----- .../order_management/order_management_api.md | 12 ++-- docs/commerce/payment/extend_payment.md | 4 +- docs/commerce/payment/payment_api.md | 12 ++-- docs/commerce/payment/payment_method_api.md | 14 ++-- .../shipping_management/shipment_api.md | 12 ++-- .../shipping_method_api.md | 14 ++-- .../content_api/browsing_content.md | 48 +++++++------- .../content_api/creating_content.md | 22 +++---- .../content_api/managing_content.md | 34 +++++----- .../data_migration/data_migration_api.md | 8 +-- docs/multisite/languages/language_api.md | 4 +- docs/pim/price_api.md | 8 +-- docs/pim/product_api.md | 38 +++++------ docs/search/search_api.md | 65 ++++++++----------- 18 files changed, 163 insertions(+), 180 deletions(-) diff --git a/code_samples/api/commerce/src/Command/CartCommand.php b/code_samples/api/commerce/src/Command/CartCommand.php index fbba6d987e..b1d9b07f02 100644 --- a/code_samples/api/commerce/src/Command/CartCommand.php +++ b/code_samples/api/commerce/src/Command/CartCommand.php @@ -90,7 +90,7 @@ public function __invoke(OutputInterface $output): int $this->cartService->emptyCart($cart); // Validate a cart - $violationList = $this->cartService->validateCart($cart); // Symfony\Component\Validator\ConstraintViolationListInterface + $violationList = $this->cartService->validateCart($cart); // Add product to a cart $product = $this->productService->getProduct('desk1'); diff --git a/docs/ai_actions/extend_ai_actions.md b/docs/ai_actions/extend_ai_actions.md index e8f575d13f..8286527bf7 100644 --- a/docs/ai_actions/extend_ai_actions.md +++ b/docs/ai_actions/extend_ai_actions.md @@ -14,7 +14,7 @@ For example, you can create a handler that connects to a translation model and u You can execute AI Actions by using the [ActionServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionServiceInterface.html) service, as in the following example: ``` php -[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 86, 105) =]] +[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 81, 100) =]] ``` The `GenerateAltTextAction` is a built-in action that implements the [ActionInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html), takes an [Image](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-Action-DataType-Image.html) as an input, and generates the alternative text in the response. @@ -43,7 +43,7 @@ You can influence the execution of an Action with two events: Below you can find the full example of a Symfony Command, together with a matching service definition. The command finds the images modified in the last 24 hours, and adds the alternative text to them if it's missing. -``` php hl_lines="72 85-110" +``` php hl_lines="67 80-105" [[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php') =]] ``` @@ -77,7 +77,7 @@ See [Action Configuration Search Criteria reference](action_configuration_criter The following example creates a new Action Configuration: ``` php hl_lines="3 17" -[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 46, 63) =]] +[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 40, 58) =]] ``` Actions Configurations are tied to a specific Action Type and are translatable. @@ -88,7 +88,7 @@ Reuse existing Action Configurations to simplify the execution of AI Actions. You can pass one directly to the `ActionServiceInterface::execute()` method: ``` php hl_lines="7-8" -[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 64, 72) =]] +[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 59, 67) =]] ``` The passed Action Configuration is only taken into account if the Action Context was not passed to the Action directly using the [ActionInterface::setActionContext()](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html#method_hasActionContext) method. diff --git a/docs/api/php_api/php_api.md b/docs/api/php_api/php_api.md index c4917c04d8..c1d5308242 100644 --- a/docs/api/php_api/php_api.md +++ b/docs/api/php_api/php_api.md @@ -126,7 +126,7 @@ While [using `sudo()`](#using-sudo) is the recommended option, you can also set To identify as a different user, you need to use the `UserService` together with `PermissionResolver` (in the example `admin` is the login of the administrator user): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 40, 41) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 36, 38) =]] ``` !!! tip diff --git a/docs/commerce/cart/cart_api.md b/docs/commerce/cart/cart_api.md index d8208d737a..be299705fc 100644 --- a/docs/commerce/cart/cart_api.md +++ b/docs/commerce/cart/cart_api.md @@ -23,7 +23,7 @@ From the developer's perspective, carts and entries are referenced with a UUID i To access a single cart, use the `CartServiceInterface::getCart` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 66) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 64) =]] ``` ## Get multiple carts @@ -35,7 +35,7 @@ It follows the same search Query pattern as other APIs: [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 10, 11) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 49, 57) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 47, 56) =]] ``` ## Create cart @@ -46,7 +46,7 @@ To create a cart, use the `CartServiceInterface::createCart` method and provide [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 8, 9) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 70, 78) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 68, 76) =]] ``` ## Update cart metadata @@ -59,7 +59,7 @@ To update cart metadata, use the `CartServiceInterface::updateCartMetadata` meth [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 9, 10) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 82, 89) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 80, 87) =]] ``` You can also use this method to change cart ownership: @@ -80,8 +80,8 @@ $cart = $cartService->updateCartMetadata($cart, $updateMetadataStruct); To delete a cart permanently, use the `CartServiceInterface::deleteCart` method and pass the `CartInterface` object: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 125) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 63) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 122, 124) =]] ``` ## Empty cart @@ -89,8 +89,8 @@ To delete a cart permanently, use the `CartServiceInterface::deleteCart` method To remove all products from the cart in a single operation, use the `CartServiceInterface::emptyCart` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 91, 92) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 89, 91) =]] ``` ## Check cart validity @@ -101,8 +101,8 @@ To validate the cart, use the `CartServiceInterface::validateCart` method. Validation is done with help from the `symfony/validator` component, and the method returns a `Symfony\Component\Validator\ConstraintViolationListInterface` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 94, 95) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 92, 93) =]] ``` ## Add entry to cart @@ -114,8 +114,8 @@ Then pass it to the `CartServiceInterface::addEntry` method: [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 99, 106) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 97, 104) =]] ``` ## Remove entry from cart @@ -123,8 +123,8 @@ Then pass it to the `CartServiceInterface::addEntry` method: To remove an entry from the cart, use the `CartServiceInterface::removeEntry` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 112) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 110) =]] ``` ## Update entry metadata @@ -136,9 +136,9 @@ To change entry metadata, use the `CartServiceInterface::updateEntry` method and [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 110) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 114, 122) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 109) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 112, 120) =]] ``` ## Adding context data @@ -185,5 +185,5 @@ To combine the contents of multiple shopping carts into a target cart, use the ` This operation is helpful when you want to consolidate items from a reorder cart and a current cart into a single order. ```php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 126, 139) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 125, 137) =]] ``` diff --git a/docs/commerce/order_management/order_management_api.md b/docs/commerce/order_management/order_management_api.md index 640221200f..3e59958950 100644 --- a/docs/commerce/order_management/order_management_api.md +++ b/docs/commerce/order_management/order_management_api.md @@ -19,7 +19,7 @@ To get orders and manage them, use the [`Ibexa\Contracts\OrderManagement\OrderSe To access a single order by using its string identifier, use the [`OrderServiceInterface::getOrderByIdentifier`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrderByIdentifier) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 51, 55) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 45, 49) =]] ``` ### Get single order by ID @@ -27,7 +27,7 @@ To access a single order by using its string identifier, use the [`OrderServiceI To access a single order by using its numerical ID, use the [`OrderServiceInterface::getOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrder) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 57, 61) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 51, 55) =]] ``` ## Get multiple orders @@ -36,10 +36,10 @@ To fetch multiple orders, use the [`OrderServiceInterface::findOrders`](/api/php It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 8, 9) =]][[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 10, 14) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 9, 14) =]] // ... -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 110, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 113) =]] ``` ## Create order @@ -47,7 +47,7 @@ It follows the same search query pattern as other APIs: To create an order, use the [`OrderServiceInterface::createOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_createOrder) method and provide it with the [`Ibexa\Contracts\OrderManagement\Value\Struct\OrderCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-Value-Struct-OrderCreateStruct.html) object that contains a list of products, purchased quantities, product, total prices, and tax amounts. ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 91, 102) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 85, 96) =]] ``` ## Update order @@ -57,5 +57,5 @@ You could do it to support a scenario when, for example, the order is processed To update order information, use the [`OrderServiceInterface::updateOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_updateOrder) method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 108) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 98, 102) =]] ``` diff --git a/docs/commerce/payment/extend_payment.md b/docs/commerce/payment/extend_payment.md index eb76cde4af..33ed3045bd 100644 --- a/docs/commerce/payment/extend_payment.md +++ b/docs/commerce/payment/extend_payment.md @@ -94,11 +94,11 @@ When you create a payment, you can attach custom data to it, for example, you ca You add custom data by using the `setContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 93) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 75, 87) =]] ``` Then, you retrieve it with the `getContext` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 58) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 52) =]] ``` diff --git a/docs/commerce/payment/payment_api.md b/docs/commerce/payment/payment_api.md index 96a6850814..5a0f1a2b70 100644 --- a/docs/commerce/payment/payment_api.md +++ b/docs/commerce/payment/payment_api.md @@ -17,7 +17,7 @@ You can change that by providing a custom payment identifier in `Ibexa\Contracts To access a single payment by using its numerical ID, use the `PaymentServiceInterface::getPayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 52) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 42, 46) =]] ``` ### Get single payment by identifier @@ -25,7 +25,7 @@ To access a single payment by using its numerical ID, use the `PaymentServiceInt To access a single payment by using its string identifier, use the `PaymentServiceInterface::getPaymentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 56) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 50) =]] ``` ## Get multiple payments @@ -34,7 +34,7 @@ To fetch multiple payments, use the `PaymentServiceInterface::findPayments` meth It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 63, 79) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 57, 73) =]] ``` ## Create payment @@ -42,7 +42,7 @@ It follows the same search query pattern as other APIs: To create a payment, use the `PaymentServiceInterface::createPayment` method and provide it with the `Ibexa\Contracts\Payment\Payment\PaymentCreateStruct` object that takes the following arguments: `method`, `order` and `amount`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 95) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 75, 89) =]] ``` ## Update payment @@ -53,7 +53,7 @@ The `Ibexa\Contracts\Payment\Payment\PaymentUpdateStruct` object takes the follo To update payment information, use the `PaymentServiceInterface::updatePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 97, 103) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 91, 97) =]] ``` ## Delete payment @@ -61,5 +61,5 @@ To update payment information, use the `PaymentServiceInterface::updatePayment` To delete a payment from the system, use the `PaymentServiceInterface::deletePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 105, 106) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 99, 100) =]] ``` diff --git a/docs/commerce/payment/payment_method_api.md b/docs/commerce/payment/payment_method_api.md index 61ff2ee38f..dbea65b7fd 100644 --- a/docs/commerce/payment/payment_method_api.md +++ b/docs/commerce/payment/payment_method_api.md @@ -26,7 +26,7 @@ From the developer's perspective, payment methods are referenced with identifier To access a single payment method by using its string identifier, use the `PaymentMethodService::getPaymentMethodByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 46, 50) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 44, 48) =]] ``` ### Get single payment method by ID @@ -34,7 +34,7 @@ To access a single payment method by using its string identifier, use the `Payme To access a single payment method by using its numerical ID, use the `PaymentMethodService::getPaymentMethod` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 40, 44) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 38, 42) =]] ``` ## Get multiple payment methods @@ -44,7 +44,7 @@ To fetch multiple payment methods, use the `PaymentMethodService::findPaymentMet It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 69) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 68) =]] ``` ## Create payment method @@ -59,7 +59,7 @@ To create a payment method, use the `PaymentMethodService::createPaymentMethod` - `options` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 53) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 71, 81) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 51) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 70, 79) =]] ``` ## Update payment method @@ -70,14 +70,14 @@ An `Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodUpdateStruct` object can To update payment method information, use the `PaymentMethodServiceInterface::updatePaymentMethod` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 83, 93) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 81, 91) =]] ``` ## Delete payment method To delete a payment method from the system, use the `PaymentMethodService::deletePayment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 95, 101) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 93, 99) =]] ``` ## Check whether payment method is used @@ -85,5 +85,5 @@ To delete a payment method from the system, use the `PaymentMethodService::delet To check whether a payment method is used, for example, before you delete it, use the `PaymentMethodService::isPaymentMethodUsed` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 103, 116) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 101, 114) =]] ``` diff --git a/docs/commerce/shipping_management/shipment_api.md b/docs/commerce/shipping_management/shipment_api.md index 48f605d864..23efb05c84 100644 --- a/docs/commerce/shipping_management/shipment_api.md +++ b/docs/commerce/shipping_management/shipment_api.md @@ -16,7 +16,7 @@ From the developer's perspective, shipments are referenced with a UUID identifie To access a single shipment by using its string identifier, use the `ShipmentService::getShipmentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 57, 66) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 56, 64) =]] ``` ### Get single shipment by id @@ -24,7 +24,7 @@ To access a single shipment by using its string identifier, use the `ShipmentSer To access a single shipment by using its numerical id, use the `ShipmentService::getShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 45, 55) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 44, 53) =]] ``` ## Get multiple shipments @@ -33,7 +33,7 @@ To fetch multiple shipments, use the `ShipmentService::findShipments` method. It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 68, 87) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 66, 85) =]] ``` ## Create shipment @@ -41,7 +41,7 @@ It follows the same search query pattern as other APIs: To create a shipment, use the `ShipmentService::createShipment` method and provide it with an `Ibexa\Contracts\Shipping\Value\ShipmentCreateStruct` object that takes two parameters, a `shippingMethod` string and a `Money` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 89, 103) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 87, 101) =]] ``` ## Update shipment @@ -51,7 +51,7 @@ You could do it to support a scenario when, for example, the shipment is process To update shipment information, use the `ShipmentService::updateShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 105, 116) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 103, 114) =]] ``` ## Delete shipment @@ -59,5 +59,5 @@ To delete a shipment from the system, use the `ShipmentService::deleteShipment` ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 118, 119) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 116, 117) =]] ``` diff --git a/docs/commerce/shipping_management/shipping_method_api.md b/docs/commerce/shipping_management/shipping_method_api.md index 6a47fc1687..43154e3b4a 100644 --- a/docs/commerce/shipping_management/shipping_method_api.md +++ b/docs/commerce/shipping_management/shipping_method_api.md @@ -17,7 +17,7 @@ To access a shipping method by using its identifier, use the `ShippingMethodServ The method takes a string as `$identifier` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 52, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 51, 60) =]] ``` ### Get shipping method by ID @@ -26,7 +26,7 @@ To access a shipping method by using its ID, use the `ShippingMethodServiceInter The method takes a string as `$id` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 40, 50) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 39, 48) =]] ``` ## Get multiple shipping methods @@ -35,7 +35,7 @@ To fetch multiple shipping methods, use the `ShippingMethodServiceInterface::get It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 64, 82) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 62, 80) =]] ``` ## Create shipping method @@ -43,7 +43,7 @@ It follows the same search query pattern as other APIs: To create a shipping method, use the `ShippingMethodServiceInterface::createShippingMethod` method and provide it with the `Ibexa\Contracts\Shipping\Value\ShippingMethodCreateStruct` object that you created by using the `newShippingMethodCreateStruct` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 84, 107) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 82, 105) =]] ``` ## Update shipping method @@ -51,7 +51,7 @@ To create a shipping method, use the `ShippingMethodServiceInterface::createShip To update a shipping method, use the `ShippingMethodServiceInterface::updateShippingMethod` method and provide it with the `Ibexa\Contracts\Shipping\Value\ShippingMethodUpdateStruct` object that you created by using the `newShippingMethodUpdateStruct` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 109, 123) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 107, 121) =]] ``` ## Delete shipping method @@ -59,7 +59,7 @@ To update a shipping method, use the `ShippingMethodServiceInterface::updateShip To update a shipping method, use the `ShippingMethodServiceInterface::deleteShippingMethod` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 125, 131) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 123, 129) =]] ``` ## Delete shipping method translation @@ -67,5 +67,5 @@ To update a shipping method, use the `ShippingMethodServiceInterface::deleteShip To delete shipping method translation, use the `ShippingMethodServiceInterface::deleteShippingMethodTranslation` method. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 133, 142) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 131, 140) =]] ``` diff --git a/docs/content_management/content_api/browsing_content.md b/docs/content_management/content_api/browsing_content.md index 5636fa90e8..ebd3fc7163 100644 --- a/docs/content_management/content_api/browsing_content.md +++ b/docs/content_management/content_api/browsing_content.md @@ -25,16 +25,12 @@ This value object provides primitive fields, such as `contentTypeId`, `published You can also use it to request other Content-related value objects from various services: -``` php hl_lines="8" -// ... -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 4, 5) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 18, 22) =]] -// ... -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 44, 46) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 54, 65) =]] +``` php hl_lines="1" +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 40, 48) =]] ``` -`ContentInfo` is loaded from the [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html) (line 8). +`ContentInfo` is loaded from the [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html). It provides you with basic content metadata such as modification and publication dates or main language code. !!! note "Retrieving content information in a controller" @@ -46,7 +42,7 @@ It provides you with basic content metadata such as modification and publication To get the locations of a content item you need to make use of the [`LocationService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 55, 61) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 50, 54) =]] } ``` [`LocationService::loadLocations`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_loadLocations) uses `ContentInfo` to get all the locations of a content item. @@ -60,7 +56,7 @@ The [`URLAliasService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-C [`URLAliasService::reverseLookup`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-URLAliasService.html#method_reverseLookup) gets the location's main [URL alias](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-URLAlias.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 73, 76) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 77, 80) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 50, 53) =]][[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 54, 57) =]] ``` ### Content type @@ -68,7 +64,7 @@ The [`URLAliasService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-C You can retrieve the content type of a content item through the [`getContentType`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html#method_getContentType) method of the ContentInfo object: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 82, 84) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 59, 61) =]] ``` ### Versions @@ -76,13 +72,13 @@ You can retrieve the content type of a content item through the [`getContentType To iterate over the versions of a content item, use the [`ContentService::loadVersions`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadVersions) method, which returns an array of `VersionInfo` value objects. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 86, 92) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 63, 69) =]] ``` You can additionally provide the `loadVersions` method with the version status to get only versions of a specific status, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 93, 94) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 70, 71) =]] ``` !!! note @@ -98,7 +94,7 @@ This method loads only the specified subset of relations to improve performance You can get the current version's `VersionInfo` using [`ContentService::loadVersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadVersionInfo). ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 105, 112) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 82, 89) =]] ``` You can also specify the version number as the second argument to get Relations for a specific version: @@ -117,7 +113,7 @@ It also holds the [relation type](content_relations.md), and the optional field You can use the `getOwner` method of the `ContentInfo` object to load the content item's owner as a `User` value object. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 114, 115) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 91, 92) =]] ``` To get the creator of the current version and not the content item's owner, you need to use the `creatorId` property from the current version's `VersionInfo` object. @@ -127,7 +123,7 @@ To get the creator of the current version and not the content item's owner, you You can find the section to which a content item belongs through the [`getSection`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html#method_getSection) method of the ContentInfo object: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 117, 118) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 94, 95) =]] ``` !!! note @@ -142,23 +138,23 @@ You need to provide it with the object state group. All object state groups can be retrieved through [`loadObjectStateGroups`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ObjectStateService.html#method_loadObjectStateGroups). ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 120, 125) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentMetaDataCommand.php', 97, 102) =]] ``` ## Viewing content with fields To retrieve the fields of the selected content item, you can use the following command: -```php hl_lines="9-10 12-19" -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentCommand.php', 4, 7) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentCommand.php', 42, 60) =]] -} +```php hl_lines="27 30-31 33-40" +[[= include_file('code_samples/api/public_php_api/src/Command/ViewContentCommand.php') =]] ``` -Line 9 shows how [`ContentService::loadContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadContent) loads the content item provided to the command. -Line 10 makes use of the [`ContentTypeService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentTypeService.html) to retrieve the content type of the requested item. +The example shows how to: + +- use [`ContentService::loadContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_loadContent) loads the content item provided to the command +- use the [`ContentTypeService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentTypeService.html) to retrieve the content type of the requested item +- iterate over fields defined by the content type -Lines 12-19 iterate over fields defined by the content type. For each field they print out its identifier, and then using [`FieldTypeService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-FieldTypeService.html) retrieve the field's value and print it out to the console. ## Viewing content in different languages @@ -182,12 +178,12 @@ $contentService->loadContent($content->id, Language::ALL); To go through all the content items contained in a subtree, you need to use the [`LocationService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html). ``` php hl_lines="5 15" -[[= include_file('code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php', 35, 54) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php', 21, 40) =]] ``` -`loadLocation` (line 15) returns a value object, here a `Location`. +`loadLocation` returns a value object, here a `Location`. -[`LocationService::loadLocationChildren`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_loadLocationChildren) (line 5) returns a [`LocationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationList.html) value object that you can iterate over. +[`LocationService::loadLocationChildren`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_loadLocationChildren) returns a [`LocationList`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationList.html) value object that you can iterate over. !!! note diff --git a/docs/content_management/content_api/creating_content.md b/docs/content_management/content_api/creating_content.md index 7cd1df6a04..05149b4b80 100644 --- a/docs/content_management/content_api/creating_content.md +++ b/docs/content_management/content_api/creating_content.md @@ -20,18 +20,18 @@ Value objects such as content items are read-only, so to create or modify them y [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) returns a new [`ContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentCreateStruct.html) object. -``` php hl_lines="1-2 6" -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 47, 53) =]] +``` php hl_lines="2-3 5" +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 40, 50) =]] ``` -This command creates a draft using [`ContentService::createContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_createContent) (line 6). +This command creates a draft using [`ContentService::createContent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_createContent). This method must receive a `ContentCreateStruct` and an array of location structs. -`ContentCreateStruct` (which extends `ContentStruct`) is created through [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct) (line 1), +`ContentCreateStruct` (which extends `ContentStruct`) is created through [`ContentService::newContentCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_newContentCreateStruct), which receives the content type and the primary language for the content item. For information about translating a content item into other languages, see [Translating content](#translating-content). -[`ContentStruct::setField`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentStruct.html#method_setField) (line 2) enables you to define the field values. +[`ContentStruct::setField`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentStruct.html#method_setField) enables you to define the field values. When the field accepts a simple value, you can provide it directly, as in the example above. For some field types, for example [images](#creating-an-image), you need to provide an instance of a Value type. @@ -42,7 +42,7 @@ Therefore, when creating a content item of the Image type (or any other content the `ContentCreateStruct` is slightly more complex than in the previous example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateImageCommand.php', 47, 62) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateImageCommand.php', 39, 51) =]] ``` Value of the Image field type contains the path to the image file and other basic information based on the input file. @@ -66,7 +66,7 @@ To publish it, use [`ContentService::publishVersion`](/api/php_api/php_api_refer This method must get the [`VersionInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-VersionInfo.html) object of a draft version. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 58, 59) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 52, 53) =]] ``` ## Updating content @@ -76,7 +76,7 @@ and pass it to [`ContentService::updateContent`](/api/php_api/php_api_reference/ This method works on a draft, so to publish your changes you need to use [`ContentService::publishVersion`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html#method_publishVersion) as well: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/UpdateContentCommand.php', 45, 50) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/UpdateContentCommand.php', 33, 42) =]] ``` ## Translating content @@ -86,15 +86,15 @@ Content [translations](languages.md#language-versions) are created per version. To translate a content item to a new language, you need to update it and provide a new `initialLanguageCode`: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 50, 52) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 58, 60) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 37, 43) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 48, 51) =]] ``` You can also update content in multiple languages at once using the `setField` method's third argument. Only one language can still be set as a version's initial language: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 55, 55) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TranslateContentCommand.php', 45, 46) =]] ``` ### Deleting a translation diff --git a/docs/content_management/content_api/managing_content.md b/docs/content_management/content_api/managing_content.md index 7f0cea4010..567ea756e2 100644 --- a/docs/content_management/content_api/managing_content.md +++ b/docs/content_management/content_api/managing_content.md @@ -22,8 +22,8 @@ Creating a new location, like creating content, requires using a struct, because To add a new location to existing content you need to create a [`LocationCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-LocationCreateStruct.html) and pass it to the [`LocationService::createLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_createLocation) method: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 42, 43) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 47, 49) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 35, 36) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 40, 42) =]] ``` `LocationCreateStruct` must receive the parent location ID. @@ -32,7 +32,7 @@ It sets the `parentLocationId` property of the new location. You can also provide other properties for the location, otherwise they're set to their defaults: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 44, 46) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php', 37, 39) =]] ``` ### Changing the main location @@ -41,7 +41,7 @@ When a content item has more that one location, one location is always considere You can change the main location using [`ContentService`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentService.html), by updating the `ContentInfo` with a [`ContentUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentUpdateStruct.html) that sets the new main location: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 43, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php', 33, 39) =]] ``` ### Hiding and revealing locations @@ -49,7 +49,7 @@ You can change the main location using [`ContentService`](/api/php_api/php_api_r To hide or reveal (unhide) a location you need to make use of [`LocationService::hideLocation`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_hideLocation) or [`LocationService::unhideLocation`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_unhideLocation) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 41, 42) =]][[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 44, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/HideLocationCommand.php', 34, 41) =]] ``` See [location visibility](locations.md#location-visibility) for detailed information on the behavior of visible and hidden Locations. @@ -66,14 +66,14 @@ Content which has more locations is still available in its other locations. If you delete the [main location](#changing-the-main-location) of a content item that has more locations, another location becomes the main one. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 39, 40) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/DeleteContentCommand.php', 31, 34) =]] ``` To send the location and its subtree to Trash, use [`TrashService::trash`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-TrashService.html#method_trash). Items in Trash can be later [restored, or deleted permanently](#trash). ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 46, 47) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 36, 39) =]] ``` ### Moving and copying a subtree @@ -81,7 +81,7 @@ Items in Trash can be later [restored, or deleted permanently](#trash). You can move a location with its whole subtree using [`LocationService::moveSubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_moveSubtree): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 41, 44) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/MoveContentCommand.php', 33, 37) =]] ``` [`LocationService::copySubtree`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LocationService.html#method_copySubtree) is used in the same way, but it copies the location and its subtree instead of moving it. @@ -108,7 +108,7 @@ You must provide the method with the ID of the object in Trash. Trash location is identical to the origin location of the object. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 56, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/TrashContentCommand.php', 48, 49) =]] ``` The content item is restored under its previous location. @@ -138,14 +138,14 @@ In this case you use [`ContentTypeCreateStruct`](/api/php_api/php_api_reference/ A content type must have at least one name, in the main language, and at least one field definition. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 54, 64) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 71, 80) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 48, 58) =]][[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 65, 74) =]] ``` You can specify more details of the field definition in the create struct, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 62, 72) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 56, 67) =]] ``` ### Copying content types @@ -153,7 +153,7 @@ You can specify more details of the field definition in the create struct, for e To copy a content type, use [`ContentTypeService::copyContentType`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-ContentTypeService.html#method_copyContentType): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 83, 85) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 78, 79) =]] ``` The copy is automatically getting an identifier based on the original content type identifier and the copy's ID, for example: `copy_of_folder_21`. @@ -161,7 +161,7 @@ The copy is automatically getting an identifier based on the original content ty To change the identifier of the copy, use a [`ContentTypeUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-ContentType-ContentTypeUpdateStruct.html): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 85, 91) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php', 79, 85) =]] ``` ## Calendar events @@ -178,19 +178,19 @@ To get a list of events for a specified time period, use the `CalendarServiceInt You need to provide the method with an EventQuery, which takes a date range and a count as the minimum of parameters: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 34, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 31, 42) =]] ``` You can also get the first and last event in the list by using the `first()` and `last()` methods of an `EventCollection` (`Ibexa\Contracts\Calendar\EventCollection`): ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 46, 48) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 43, 45) =]] ``` You can process the events in a collection using the `find(Closure $predicate)`, `filter(Closure $predicate)`, `map(Closure $callback)` or `slice(int $offset, ?int $length = null)` methods of `EventCollection`, for example: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 49, 53) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 46, 50) =]] ``` ### Performing calendar actions @@ -200,5 +200,5 @@ You must pass an `Ibexa\Contracts\Calendar\EventAction\EventActionContext` insta `EventActionContext` defines events on which the action is performed, and action-specific parameters, for example, a new date: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 54, 58) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/CalendarCommand.php', 51, 55) =]] ``` diff --git a/docs/content_management/data_migration/data_migration_api.md b/docs/content_management/data_migration/data_migration_api.md index 53c247b17c..507a3e7387 100644 --- a/docs/content_management/data_migration/data_migration_api.md +++ b/docs/content_management/data_migration/data_migration_api.md @@ -11,13 +11,13 @@ You can use the PHP API to manage and run [data migrations](data_migration.md). To list all migration files available in the directory defined in configuration (by default, `src/Migrations/Ibexa`), use the `MigrationService:listMigrations()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 31, 34) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 29, 32) =]] ``` To get a single migration file by its name, use the `MigrationService:findOneByName()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 36, 37) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 34, 35) =]] ``` ## Running migration files @@ -25,7 +25,7 @@ To get a single migration file by its name, use the `MigrationService:findOneByN To run migration file(s), use either `MigrationService:executeOne()` or `MigrationService:executeAll()`: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 38, 40) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 36, 38) =]] ``` Both `executeOne()` and `executeAll()` can take an optional parameter: the login of the User that you want to execute the migrations as. @@ -35,5 +35,5 @@ Both `executeOne()` and `executeAll()` can take an optional parameter: the login To add a new migration file, use the `MigrationService:add()` method: ``` php -[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 24, 30) =]] +[[= include_file('code_samples/api/migration/src/Command/MigrationCommand.php', 22, 28) =]] ``` diff --git a/docs/multisite/languages/language_api.md b/docs/multisite/languages/language_api.md index 3f7105c26a..c7db05ce2c 100644 --- a/docs/multisite/languages/language_api.md +++ b/docs/multisite/languages/language_api.md @@ -11,7 +11,7 @@ You can manage languages configured in the system with PHP API by using [`Langua To get a list of all languages in the system use [`LanguageService::loadLanguages`:](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_loadLanguage) ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 27, 33) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 29, 35) =]] ``` ## Creating a language @@ -20,5 +20,5 @@ To create a new language, you need to create a [`LanguageCreateStruct`](/api/php Then, use [`LanguageService::createLanguage`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-LanguageService.html#method_createLanguage) and pass the `LanguageCreateStruct` to it: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 34, 38) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/AddLanguageCommand.php', 34, 39) =]] ``` diff --git a/docs/pim/price_api.md b/docs/pim/price_api.md index 019bb04b91..887e764140 100644 --- a/docs/pim/price_api.md +++ b/docs/pim/price_api.md @@ -80,7 +80,7 @@ To resolve a price of a product in the currency for the current context, use eit ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 7, 8) =]][[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 96, 100) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 87, 90) =]] ``` ## VAT @@ -89,17 +89,17 @@ To get information about the VAT categories and rates configured in the system, VAT is configured per region, so you also need to use `RegionServiceInterface` to get the relevant region object. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 41, 42) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 33, 34) =]] ``` To get information about all VAT categories configured for the selected region, use `VatServiceInterface::getVatCategories()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 43, 48) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 34, 40) =]] ``` To get a single VAT category, use `VatServiceInterface::getVatCategoryByIdentifier()` and provide it with the region object and the identifier of the VAT category: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 49, 50) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/VatCommand.php', 41, 42) =]] ``` diff --git a/docs/pim/product_api.md b/docs/pim/product_api.md index 5f76ee7ffc..5418115dea 100644 --- a/docs/pim/product_api.md +++ b/docs/pim/product_api.md @@ -21,7 +21,7 @@ month_change: false Get an individual product by using the `ProductServiceInterface::getProduct()` method: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 54, 57) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 43, 46) =]] ``` Find multiple products with `ProductServiceInterface::findProducts()`. @@ -29,7 +29,7 @@ Find multiple products with `ProductServiceInterface::findProducts()`. Provide the method with optional filter, query or Sort Clauses. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 58, 68) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 46, 57) =]] ``` See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clauses](product_sort_clauses.md) references for more information about how to use the [`ProductQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Product-ProductQuery.html) class. @@ -39,7 +39,7 @@ See [Product Search Criteria](product_search_criteria.md) and [Product Sort Clau To create, update and delete products, use the `LocalProductServiceInterface`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 79, 83) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 68, 72) =]] ``` To create a product, use `LocalProductServiceInterface::newProductCreateStruct()` to get a [`ProductCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-Product-ProductCreateStruct.html). @@ -47,13 +47,13 @@ Provide the method with the product type object and the main language code. You also need to set (at least) the code for the product and the required Field of the underlying content type, `name`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 71, 76) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 58, 65) =]] ``` To delete a product, use `LocalProductServiceInterface::deleteProduct()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 106, 107) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 95, 96) =]] ``` ### Product variants @@ -65,13 +65,13 @@ A `ProductVariantQuery` lets you define the offset and limit of the variant quer The default offset is 0, and limit is 25. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 49, 52) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 40, 43) =]] ``` From a variant ([`ProductVariantInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-ProductVariantInterface.html)), you can access the attributes that are used to generate the variant by using `ProductVariantInterface::getDiscriminatorAttributes()`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 53, 60) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 44, 51) =]] ``` #### Creating variants @@ -81,7 +81,7 @@ This method takes the product and an array of [`ProductVariantCreateStruct`](/ap `ProductVariantCreateStruct` specifies the attribute values and the code for the new variant. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 62, 68) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductVariantCommand.php', 53, 60) =]] ``` ### Product assets @@ -91,14 +91,14 @@ You can get assets assigned to a product by using [`AssetServiceInterface`](/api Use `AssetServiceInterface` to get a single asset by providing the product object and the assets's ID as parameters: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 46, 48) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 37, 40) =]] ``` To get all assets assigned to a product, use `AssetServiceInterface::findAssets()`. You can retrieve the tags (corresponding to attribute values) of assets with the `AssetInterface::getTags()` method: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 49, 58) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductAssetCommand.php', 40, 49) =]] ``` ## Product types @@ -108,13 +108,13 @@ To work with product types, use [`ProductTypeServiceInterface`](/api/php_api/php Get a product type object by using `ProductTypeServiceInterface::getProductType()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 38, 39) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 31, 32) =]] ``` You can also get a list of product types with `ProductTypeServiceInterface::findProductTypes()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 42, 47) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductTypeCommand.php', 35, 40) =]] ``` ## Product availability @@ -128,14 +128,14 @@ Get the availability object with `ProductAvailabilityServiceInterface::getAvaila You can then use `ProductAvailabilityServiceInterface::getStock()` to get the stock number for the product: ```php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 90, 95) =]] } +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 79, 84) =]] } ``` To change availability for a product, use `ProductAvailabilityServiceInterface::updateProductAvailability()` with a [`ProductAvailabilityUpdateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-Availability-ProductAvailabilityUpdateStruct.html) and provide it with the product object. The second parameter defines whether product is available, and the third whether its stock is infinite. The fourth parameter is the stock number: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 98, 101) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductCommand.php', 87, 90) =]] ``` ## Attributes @@ -146,24 +146,24 @@ To get information about product attribute groups, use the [`AttributeGroupServi `AttributeGroupServiceInterface::findAttributeGroups()` gets attribute groups, all of them or filtered with an optional [`AttributeGroupQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Values-AttributeGroup-AttributeGroupQuery.html) object: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 53, 54) =]] -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 74, 79) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 47, 48) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 68, 73) =]] ``` To create an attribute group, use `LocalAttributeGroupServiceinterface::createAttributeGroup()` and provide it with an [`AttributeGroupCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeGroup-AttributeGroupCreateStruct.html): ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 48, 52) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 42, 46) =]] ``` To get information about product attributes, use the [`AttributeDefinitionServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-AttributeDefinitionServiceInterface.html), or [`LocalAttributeDefinitionServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-LocalAttributeDefinitionServiceInterface.html) to modify attributes. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 60, 62) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 54, 56) =]] ``` To create an attribute, use `LocalAttributeGroupServiceinterface::createAttributeDefinition()` and provide it with an [`AttributeDefinitionCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ProductCatalog-Local-Values-AttributeDefinition-AttributeDefinitionCreateStruct.html): ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 65, 71) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/AttributeCommand.php', 59, 65) =]] ``` diff --git a/docs/search/search_api.md b/docs/search/search_api.md index de1c1bca69..0de5fabc5c 100644 --- a/docs/search/search_api.md +++ b/docs/search/search_api.md @@ -26,11 +26,8 @@ For example, to search for all content of a selected content type, use one Crite The following command takes the content type identifier as an argument and lists all results: -``` php hl_lines="12 14" -// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 4, 7) =]]// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 14, 18) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 37, 45) =]]} +``` php hl_lines="25 28-31" +[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php') =]] ``` [`SearchService::findContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContentInfo) (line 14) @@ -116,19 +113,14 @@ It doesn't use the `SearchService` and isn't based on indexed data. For example, the following command lists all content items under the specified parent location and sorts them by name in descending order: -``` php hl_lines="11-14" -// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 4, 9) =]] -// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 38, 49) =]] +``` php hl_lines="26 29-34" +[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php') =]] ``` The same Filter can be applied to find locations instead of content items, for example: -``` php hl_lines="15" -// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 4, 9) =]]// ... -[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 38, 49) =]] +``` php hl_lines="26 29-34" +[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php') =]] ``` !!! caution @@ -178,20 +170,16 @@ $filter You can use the `SearchService` or repository filtering in a controller, as long as you provide the required parameters. For example, in the code below, `locationId` is provided to list all children of a location by using the `SearchService`. -``` php hl_lines="22-24" -// ... -[[= include_file('code_samples/api/public_php_api/src/Controller/CustomController.php', 4, 12) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Controller/CustomController.php', 19, 35) =]] +``` php hl_lines="19-20 22 28-30" +[[= include_file('code_samples/api/public_php_api/src/Controller/CustomController.php') =]] ``` -The rendering of results is then relegated to [templates](templates.md) (lines 22-24). +The rendering of results is then relegated to [templates](templates.md). When using Repository filtering, provide the results of `ContentService::find()` as parameters to the view: -``` php hl_lines="19" -// ... -[[= include_file('code_samples/api/public_php_api/src/Controller/CustomFilterController.php', 4, 12) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Controller/CustomFilterController.php', 19, 34) =]] +``` php hl_lines="23-27" +[[= include_file('code_samples/api/public_php_api/src/Controller/CustomFilterController.php') =]] ``` ### Paginating search results @@ -199,10 +187,7 @@ When using Repository filtering, provide the results of `ContentService::find()` To paginate search or filtering results, it's recommended to use the [Pagerfanta library](https://github.com/BabDev/Pagerfanta) and [[[= product_name =]]'s adapters for it.](https://github.com/ibexa/core/blob/main/src/lib/Pagination/Pagerfanta/Pagerfanta.php) ``` php -// ... [[= include_file('code_samples/api/public_php_api/src/Controller/PaginationController.php', 8, 15) =]] // ... -[[= include_file('code_samples/api/public_php_api/src/Controller/PaginationController.php', 22, 32) =]] -[[= include_file('code_samples/api/public_php_api/src/Controller/PaginationController.php', 33, 43) =]] ``` Pagination can then be rendered for example using the following template: @@ -237,23 +222,25 @@ For more information and examples, see [PagerFanta documentation](https://www.ba For more complex searches, you need to combine multiple Criteria. You can do it using logical operators: `LogicalAnd`, `LogicalOr`, and `LogicalNot`. -``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 45, 48) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 59, 60) =]] -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 60, 63) =]] +``` php hl_lines="3-7 10" +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 30, 31) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 32, 36) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 39, 40) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 46, 51) =]] ``` This example takes three parameters from a command — `$text`, `$contentTypeId`, and `$locationId`. It then combines them using `Criterion\LogicalAnd` to search for content items -that belong to a specific subtree, have the chosen content type and contain the provided text (lines 3-6). +that belong to a specific subtree, have the chosen content type and contain the provided text. -This also shows that you can get the total number of search results using the `totalCount` property of search results (line 9). +This also shows that you can get the total number of search results using the `totalCount` property of search results. You can also nest different operators to construct more complex queries. The example below uses the `LogicalNot` operator to search for all content containing a given phrase that doesn't belong to the provided Section: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 47, 47) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 49, 52) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 36, 39) =]] + ``` ### Combining independent Criteria @@ -286,7 +273,7 @@ To sort the results of a query, use one of more [Sort Clauses](sort_clause_refer For example, to order search results by their publicationg date, from oldest to newest, and then alphabetically by content name, add the following Sort Clauses to the query: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 54, 57) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 41, 45) =]] ``` !!! tip @@ -305,7 +292,7 @@ For a list of supported Criteria and Sort Clauses, see [Search in trash referenc Searching through the trashed content items operates directly on the database, therefore you cannot use external search engines, such as Solr or Elasticsearch, and it's impossible to reindex the data. ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 38, 42) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 25, 32) =]] ``` !!! caution @@ -324,7 +311,7 @@ With aggregations you can find the count of search results or other result infor To do this, you use of the query's `$aggregations` property: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 35) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 28, 33) =]] ``` The name of the aggregation must be unique in the given query. @@ -332,13 +319,13 @@ The name of the aggregation must be unique in the given query. Access the results by using the `get()` method of the aggregation: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 40, 41) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 37, 38) =]] ``` Aggregation results contain the name of the result and the count of found items: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 43, 45) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 40, 43) =]] ``` With field aggregations you can group search results according to the value of a specific field. @@ -347,14 +334,14 @@ In this case the aggregation takes the content type identifier and the field ide The following example creates an aggregation named `selection` that groups results according to the value of the `topic` field in the `article` content type: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 36, 36) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 33, 34) =]] ``` With term aggregation you can define additional limits to the results. The following example limits the number of terms returned to 5 and only considers terms that have 10 or more results: ``` php -[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 33) =]] +[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 28, 31) =]] ``` To use a range aggregation, you must provide a `ranges` array containing a set of `Range` objects that define the borders of the specific range sets. From b13ceaee18054eaa5fd8ce3a22f13e2fea5daaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 30 Jul 2025 11:23:09 +0200 Subject: [PATCH 24/26] More fixes --- docs/commerce/cart/cart_api.md | 9 ++++----- .../order_management/order_management_api.md | 2 +- docs/commerce/payment/payment_method_api.md | 2 +- .../commerce/shipping_management/shipment_api.md | 4 ++-- .../shipping_management/shipping_method_api.md | 4 ++-- docs/pim/catalog_api.md | 8 ++++---- docs/pim/price_api.md | 16 ++++++++-------- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/docs/commerce/cart/cart_api.md b/docs/commerce/cart/cart_api.md index be299705fc..ab6d467661 100644 --- a/docs/commerce/cart/cart_api.md +++ b/docs/commerce/cart/cart_api.md @@ -80,8 +80,8 @@ $cart = $cartService->updateCartMetadata($cart, $updateMetadataStruct); To delete a cart permanently, use the `CartServiceInterface::deleteCart` method and pass the `CartInterface` object: ``` php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 63) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 122, 124) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 122, 123) =]] ``` ## Empty cart @@ -135,9 +135,8 @@ To change entry metadata, use the `CartServiceInterface::updateEntry` method and ``` php [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]] // ... - [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]] -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 109) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 108) =]] [[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 112, 120) =]] ``` @@ -185,5 +184,5 @@ To combine the contents of multiple shopping carts into a target cart, use the ` This operation is helpful when you want to consolidate items from a reorder cart and a current cart into a single order. ```php -[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 125, 137) =]] +[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 137) =]] ``` diff --git a/docs/commerce/order_management/order_management_api.md b/docs/commerce/order_management/order_management_api.md index 3e59958950..460a606cd2 100644 --- a/docs/commerce/order_management/order_management_api.md +++ b/docs/commerce/order_management/order_management_api.md @@ -36,7 +36,7 @@ To fetch multiple orders, use the [`OrderServiceInterface::findOrders`](/api/php It follows the same search query pattern as other APIs: ``` php -[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 9, 14) =]] +[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 8, 14) =]] // ... [[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 113) =]] diff --git a/docs/commerce/payment/payment_method_api.md b/docs/commerce/payment/payment_method_api.md index dbea65b7fd..15ba615304 100644 --- a/docs/commerce/payment/payment_method_api.md +++ b/docs/commerce/payment/payment_method_api.md @@ -59,7 +59,7 @@ To create a payment method, use the `PaymentMethodService::createPaymentMethod` - `options` object. ``` php -[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 51) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 70, 79) =]] +[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 51) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 69, 79) =]] ``` ## Update payment method diff --git a/docs/commerce/shipping_management/shipment_api.md b/docs/commerce/shipping_management/shipment_api.md index 23efb05c84..3d86bd4f18 100644 --- a/docs/commerce/shipping_management/shipment_api.md +++ b/docs/commerce/shipping_management/shipment_api.md @@ -16,7 +16,7 @@ From the developer's perspective, shipments are referenced with a UUID identifie To access a single shipment by using its string identifier, use the `ShipmentService::getShipmentByIdentifier` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 56, 64) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 55, 64) =]] ``` ### Get single shipment by id @@ -24,7 +24,7 @@ To access a single shipment by using its string identifier, use the `ShipmentSer To access a single shipment by using its numerical id, use the `ShipmentService::getShipment` method: ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 44, 53) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 43, 53) =]] ``` ## Get multiple shipments diff --git a/docs/commerce/shipping_management/shipping_method_api.md b/docs/commerce/shipping_management/shipping_method_api.md index 43154e3b4a..b08f787fcf 100644 --- a/docs/commerce/shipping_management/shipping_method_api.md +++ b/docs/commerce/shipping_management/shipping_method_api.md @@ -17,7 +17,7 @@ To access a shipping method by using its identifier, use the `ShippingMethodServ The method takes a string as `$identifier` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 51, 60) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 50, 60) =]] ``` ### Get shipping method by ID @@ -26,7 +26,7 @@ To access a shipping method by using its ID, use the `ShippingMethodServiceInter The method takes a string as `$id` parameter and uses a prioritized language from SiteAccess settings unless you pass another language as `forcedLanguage`. ``` php -[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 39, 48) =]] +[[= include_file('code_samples/api/commerce/src/Command/ShippingMethodCommand.php', 38, 48) =]] ``` ## Get multiple shipping methods diff --git a/docs/pim/catalog_api.md b/docs/pim/catalog_api.md index c16c54a2c5..763bba807a 100644 --- a/docs/pim/catalog_api.md +++ b/docs/pim/catalog_api.md @@ -11,7 +11,7 @@ To get information about product catalogs and manage them, use `CatalogServiceIn To get a single catalog, use `Ibexa\Contracts\ProductCatalog\CatalogServiceInterface::getCatalog()` and provide it with catalog ID, or `CatalogServiceInterface::getCatalogByIdentifier()` and pass the identifier: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 68, 70) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 58, 60) =]] ``` ## Get products in catalog @@ -20,7 +20,7 @@ To get products from a catalog, request the product query from the catalog objec Then, create a new `ProductQuery` based on it and run a product search with `ProductServiceInterface::findProduct()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 72, 78) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 62, 68) =]] ``` ## Create catalog @@ -29,7 +29,7 @@ To create a catalog, you need to prepare a `CatalogCreateStruct` that contains: Then, pass this struct to `CatalogServiceInterface::createCatalog()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 51, 66) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 48, 56) =]] ``` ## Update catalog @@ -39,5 +39,5 @@ You must pass the catalog object and a `CatalogUpdateStruct` to the method. In the following example, you update the catalog to publish it: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 80, 84) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CatalogCommand.php', 70, 74) =]] ``` diff --git a/docs/pim/price_api.md b/docs/pim/price_api.md index 887e764140..de75960938 100644 --- a/docs/pim/price_api.md +++ b/docs/pim/price_api.md @@ -12,13 +12,13 @@ To access a currency object by its code, use `CurrencyServiceInterface::getCurre To access a whole list of currencies, use `CurrencyServiceInterface::findCurrencies`. ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 42, 50) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 34, 42) =]] ``` To create a new currency, use `CurrencyServiceInterface::createCurrency()` and provide it with a `CurrencyCreateStruct` with code, number of fractional digits and a flag indicating if the currency is enabled: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 57, 60) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/CurrencyCommand.php', 50, 53) =]] ``` ## Prices @@ -28,19 +28,19 @@ To manage prices, use `ProductPriceService`. To retrieve the price of a product in the currency for the current context, use `Product::getPrice()`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 60, 63) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 50, 53) =]] ``` To retrieve the price of a product in a specific currency, use `ProductPriceService::getPriceByProductAndCurrency`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 64, 67) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 54, 57) =]] ``` To get all prices (in different currencies) for a given product, use `ProductPriceService::findPricesByProductCode`: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 78, 84) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 68, 74) =]] ``` To load price definitions that match given criteria, use `ProductPriceServiceInterface::findPrices`: @@ -48,14 +48,14 @@ To load price definitions that match given criteria, use `ProductPriceServiceInt ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 12, 16) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 85, 95) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 75, 85) =]] ``` You can also use `ProductPriceService` to create or modify existing prices. For example, to create a new price for a given currency, use `ProductPriceService::createProductPrice` and provide it with a `ProductPriceCreateStruct` object: ``` php -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 69, 75) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 61, 65) =]] ``` !!! note @@ -80,7 +80,7 @@ To resolve a price of a product in the currency for the current context, use eit ``` php [[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 7, 8) =]][[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 11, 12) =]] // ... -[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 87, 90) =]] +[[= include_file('code_samples/api/product_catalog/src/Command/ProductPriceCommand.php', 86, 90) =]] ``` ## VAT From 25923b93b043e779037f7288a9eab1df31e405bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 4 Aug 2025 13:39:25 +0200 Subject: [PATCH 25/26] Fixed new batch of errors (#2857) --- .../2dpoint_ft/src/FieldType/Point2D/Type.php | 2 +- .../2dpoint_ft/steps/step_3/Type.php | 2 +- .../2dpoint_ft/steps/step_6/Type.php | 2 +- .../src/FieldType/HelloWorld/Type.php | 2 +- .../Solr/CameraManufacturerVisitor.php | 4 ++-- .../WebinarEventTitleFulltextFieldMapper.php | 4 ++-- phpstan-baseline.neon | 18 ------------------ 7 files changed, 8 insertions(+), 26 deletions(-) diff --git a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php index 5b34101a47..2219c9ae36 100644 --- a/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php +++ b/code_samples/field_types/2dpoint_ft/src/FieldType/Point2D/Type.php @@ -32,7 +32,7 @@ public function getSettingsSchema(): array public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', Point2DType::class, [ 'required' => $definition->isRequired, 'label' => $definition->getName(), diff --git a/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php b/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php index 3619c4e028..9e0bbc346d 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_3/Type.php @@ -18,7 +18,7 @@ public function getFieldTypeIdentifier(): string public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', Point2DType::class, [ 'required' => $definition->isRequired, 'label' => $definition->getName(), diff --git a/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php b/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php index 7019b0876c..617411f67e 100644 --- a/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php +++ b/code_samples/field_types/2dpoint_ft/steps/step_6/Type.php @@ -28,7 +28,7 @@ public function getSettingsSchema(): array public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', Point2DType::class, [ 'required' => $definition->isRequired, 'label' => $definition->getName(), diff --git a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php index 09db13dd83..62e5e121ae 100644 --- a/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php +++ b/code_samples/field_types/generic_ft/src/FieldType/HelloWorld/Type.php @@ -17,7 +17,7 @@ public function getFieldTypeIdentifier(): string public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void { - $definition = $data->fieldDefinition; + $definition = $data->getFieldDefinition(); $fieldForm->add('value', HelloWorldType::class, [ 'required' => $definition->isRequired, diff --git a/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php b/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php index 97f404aa15..c4cf00e598 100644 --- a/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php +++ b/code_samples/search/custom/src/Query/Criterion/Solr/CameraManufacturerVisitor.php @@ -10,7 +10,7 @@ final class CameraManufacturerVisitor extends CriterionVisitor { - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof CameraManufacturerCriterion; } @@ -18,7 +18,7 @@ public function canVisit(CriterionInterface $criterion) /** * @param \App\Query\Criterion\CameraManufacturerCriterion $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $expressions = array_map( fn ($value): string => 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"', diff --git a/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php b/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php index 67a209dc4d..b3e07061eb 100644 --- a/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php +++ b/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php @@ -14,13 +14,13 @@ public function __construct(protected ContentHandler $contentHandler, protected { } - public function accept(Content $content) + public function accept(Content $content): bool { // ContentType with ID 42 is webinar event return $content->versionInfo->contentInfo->contentTypeId == 42; } - public function mapFields(Content $content) + public function mapFields(Content $content): array { $mainLocationId = $content->versionInfo->contentInfo->mainLocationId; $location = $this->locationHandler->load($mainLocationId); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9359f1762c..94b21757c7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -606,30 +606,12 @@ parameters: count: 1 path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php - - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php - - - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationResultExtractor.php - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationVisitor\:\:formatRangeValue\(\) has parameter \$value with no type specified\.$#' identifier: missingType.parameter count: 1 path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php - - - message: '#^Method App\\Query\\Aggregation\\Solr\\PriorityRangeAggregationVisitor\:\:visit\(\) should return array\ but returns array\\>\|string\>\.$#' - identifier: return.type - count: 1 - path: code_samples/search/custom/src/Query/Aggregation/Solr/PriorityRangeAggregationVisitor.php - - message: '#^Method App\\Query\\Criterion\\Elasticsearch\\CameraManufacturerVisitor\:\:visit\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue From b916368bea87eb067d2ec1d5af81a81ee083f842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 4 Aug 2025 16:00:49 +0200 Subject: [PATCH 26/26] Current status --- .../public_php_api/src/Command/BookmarkCommand.php | 4 ++-- .../src/Command/CreateContentCommand.php | 4 ++-- .../src/Command/CreateContentTypeCommand.php | 4 ++-- .../src/Command/CreateImageCommand.php | 4 ++-- .../src/Command/TrashContentCommand.php | 4 ++-- .../src/Command/ViewCommand.php | 12 +++++------- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php index f1fb275ec7..0125349799 100644 --- a/code_samples/api/public_php_api/src/Command/BookmarkCommand.php +++ b/code_samples/api/public_php_api/src/Command/BookmarkCommand.php @@ -20,9 +20,9 @@ public function __construct(private readonly BookmarkService $bookmarkService, p } public function __invoke( + OutputInterface $output, #[Argument(description: 'Location id')] int $locationId, - #[Option(shortcut: 'd', description: 'Delete the created bookmark?')] bool $delete, - OutputInterface $output + #[Option(shortcut: 'd', description: 'Delete the created bookmark?')] bool $delete = false ): int { $location = $this->locationService->loadLocation($locationId); diff --git a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php index 11c79e185c..cb31423c21 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentCommand.php @@ -28,11 +28,11 @@ public function __construct( } public function __invoke( + OutputInterface $output, #[Argument(description: 'Parent Location ID')] int $parentLocationId, #[Argument(description: 'Identifier of a content type with a Name and Description Field')] string $contentType, #[Argument(description: 'Content for the Name field')] string $name, - #[Option(shortcut: 'p', description: 'Do you want to publish the content item?')] bool $publish, - OutputInterface $output + #[Option(shortcut: 'p', description: 'Do you want to publish the content item?')] bool $publish = true ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); diff --git a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php index 1f434e2de3..5d529c8d08 100644 --- a/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateContentTypeCommand.php @@ -25,11 +25,11 @@ public function __construct( } public function __invoke( + OutputInterface $output, #[Argument(description: 'Content type identifier')] string $identifier, #[Argument(description: 'Content type group identifier')] string $group_identifier, #[Argument(description: 'Identifier of the CT copy')] ?string $copy_identifier, - #[Option(shortcut: 'c', description: 'Do you want to make a copy of the content type?')] bool $copy, - OutputInterface $output + #[Option(shortcut: 'c', description: 'Do you want to make a copy of the content type?')] bool $copy = false ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); diff --git a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php index 98f4b253ac..fead0ab88b 100644 --- a/code_samples/api/public_php_api/src/Command/CreateImageCommand.php +++ b/code_samples/api/public_php_api/src/Command/CreateImageCommand.php @@ -29,10 +29,10 @@ public function __construct( } public function __invoke( + OutputInterface $output, #[Argument(description: 'Content for the Name field')] string $name, #[Argument(description: 'Content for the Image field')] string $file, - #[Option(shortcut: 'p', description: 'Do you want to publish the content item?')] bool $publish, - OutputInterface $output + #[Option(shortcut: 'p', description: 'Do you want to publish the content item?')] bool $publish = true ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); diff --git a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php index 5b6bb27c74..b4976bcddd 100644 --- a/code_samples/api/public_php_api/src/Command/TrashContentCommand.php +++ b/code_samples/api/public_php_api/src/Command/TrashContentCommand.php @@ -26,10 +26,10 @@ public function __construct( } public function __invoke( + OutputInterface $output, #[Argument(description: 'Location to trash')] int $locationId, #[Argument(description: 'New Location to restore under')] ?int $newParentId, - #[Option(shortcut: 'r', description: 'Do you want to restore the content item?')] bool $restore, - OutputInterface $output + #[Option(shortcut: 'r', description: 'Do you want to restore the content item?')] bool $restore = false ): int { $user = $this->userService->loadUserByLogin('admin'); $this->permissionResolver->setCurrentUserReference($user); diff --git a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php index d54eadc079..bf8e240fd2 100644 --- a/code_samples/front/render_content_in_php/src/Command/ViewCommand.php +++ b/code_samples/front/render_content_in_php/src/Command/ViewCommand.php @@ -19,19 +19,17 @@ public function __construct(private readonly ContentViewBuilder $contentViewBuil } public function __invoke( - #[Option] int $content_id, - #[Option] int $location_id, - #[Option] string $view_type, - OutputInterface $output + OutputInterface $output, + #[Option(name: 'content_id')] int $contentId = 52, + #[Option(name: 'location_id')] int $locationId = 2, + #[Option(name: 'view_type')] string $viewType = 'embed' ): int { - $contentId = $content_id; - $locationId = $location_id; if (empty($contentId) && empty($locationId)) { throw new \InvalidArgumentException('No Content ID nor Location ID given'); } $viewParameters = [ - 'viewType' => $view_type, + 'viewType' => $viewType, '_controller' => 'ibexa_content:viewAction', ];