Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
use Ibexa\Contracts\Core\Collection\ArrayMap;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
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
{
protected static $defaultName = 'app:action-configuration-create';

private ActionConfigurationServiceInterface $actionConfigurationService;

private PermissionResolver $permissionResolver;
Expand All @@ -39,12 +41,13 @@ public function __construct(
ActionServiceInterface $actionService,
ActionTypeRegistryInterface $actionTypeRegistry
) {
parent::__construct();
$this->actionConfigurationService = $actionConfigurationService;
$this->permissionResolver = $permissionResolver;
$this->userService = $userService;
$this->actionService = $actionService;
$this->actionTypeRegistry = $actionTypeRegistry;

parent::__construct();
}

protected function configure(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
use Ibexa\Contracts\Core\Repository\Values\Filter\Filter;
use Ibexa\Core\FieldType\Image\Value;
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
{
protected static $defaultName = 'app:add-alt-text';

private const IMAGE_FIELD_IDENTIFIER = 'image';

private ContentService $contentService;
Expand All @@ -53,13 +55,14 @@ public function __construct(
ActionServiceInterface $actionService,
IOBinarydataHandler $binaryDataHandler
) {
parent::__construct();
$this->contentService = $contentService;
$this->permissionResolver = $permissionResolver;
$this->userService = $userService;
$this->fieldTypeService = $fieldTypeService;
$this->actionService = $actionService;
$this->binaryDataHandler = $binaryDataHandler;

parent::__construct();
}

protected function configure(): void
Expand Down
10 changes: 5 additions & 5 deletions code_samples/api/commerce/src/Command/CartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
use Ibexa\Contracts\ProductCatalog\CurrencyServiceInterface;
use Ibexa\Contracts\ProductCatalog\ProductServiceInterface;
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
{
private PermissionResolver $permissionResolver;
Expand Down Expand Up @@ -58,11 +62,7 @@ public function __construct(
$this->reorderService = $reorderService;
$this->cartResolver = $cartResolver;

parent::__construct('doc:cart');
}

public function configure(): void
{
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
8 changes: 6 additions & 2 deletions code_samples/api/commerce/src/Command/OrderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
use Ibexa\Contracts\OrderManagement\Value\Struct\OrderCreateStruct;
use Ibexa\Contracts\OrderManagement\Value\Struct\OrderUpdateStruct;
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
{
private PermissionResolver $permissionResolver;
Expand All @@ -42,14 +46,14 @@ public function __construct(
$this->permissionResolver = $permissionResolver;
$this->userService = $userService;

parent::__construct('doc:order');
parent::__construct();
}

public function configure(): void
{
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$currentUser = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($currentUser);
Expand Down
10 changes: 8 additions & 2 deletions code_samples/api/commerce/src/Command/PaymentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
use Ibexa\Contracts\Payment\PaymentMethodServiceInterface;
use Ibexa\Contracts\Payment\PaymentServiceInterface;
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
{
private PermissionResolver $permissionResolver;
Expand All @@ -45,14 +49,14 @@ public function __construct(
$this->orderService = $orderService;
$this->paymentMethodService = $paymentMethodService;

parent::__construct('doc:payment');
parent::__construct();
}

public function configure(): void
{
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$currentUser = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($currentUser);
Expand All @@ -67,6 +71,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$paymentIdentifier = '4ac4b8a0-eed8-496d-87d9-32a960a10629';
$payment = $this->paymentService->getPaymentByIdentifier($paymentIdentifier);

$context = $payment->getContext();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$context seems not used between this set and its override at line 97 (below // Create a new payment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it doesn't make a lot of sense in the context of the Command - I've included it to improve the doc a bit:

Please compare:
https://ez-systems-developer-documentation--2748.com.readthedocs.build/en/2748/commerce/payment/extend_payment/#attach-custom-data-to-payments
and
https://doc.ibexa.co/en/latest/commerce/payment/extend_payment/#attach-custom-data-to-payments

I could add the getContext line somewhere else and then "glue" 2 includes together, I just prefered having it in one include as I think it's easier to maintain

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's tricky!
I didn't see that extend_payment.md uses it in reverse order…
Maybe a comment in the cut-out line to explain why it's there?

Suggested change
$context = $payment->getContext();
$context = $payment->getContext();
// Will be overridden later but used to illustrate `getContext()`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 79c5c1a - I'll wait for the "check code samples" job to make sure I did it right

$output->writeln(sprintf('Your payment for transaction has status %s', $payment->getStatus()));

// Query for payments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
use Ibexa\Contracts\Payment\PaymentMethod\Query\Criterion\Type;
use Ibexa\Contracts\Payment\PaymentMethodServiceInterface;
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
{
private PermissionResolver $permissionResolver;
Expand All @@ -35,10 +39,10 @@ public function __construct(
$this->permissionResolver = $permissionResolver;
$this->userService = $userService;

parent::__construct('doc:paymentMethod');
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$currentUser = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($currentUser);
Expand Down
6 changes: 5 additions & 1 deletion code_samples/api/commerce/src/Command/ShipmentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
use Ibexa\Contracts\Shipping\ShipmentServiceInterface;
use Ibexa\Contracts\Shipping\ShippingMethodServiceInterface;
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
{
private PermissionResolver $permissionResolver;
Expand All @@ -46,7 +50,7 @@ public function __construct(
$this->shippingMethodService = $shippingMethodService;
$this->orderService = $orderService;

parent::__construct('doc:shipment');
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
use Ibexa\Contracts\Shipping\Value\ShippingMethod\ShippingMethodQuery;
use Ibexa\ProductCatalog\Local\Repository\Values\Region;
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
{
private PermissionResolver $permissionResolver;
Expand All @@ -38,7 +42,7 @@ public function __construct(
$this->userService = $userService;
$this->regionService = $regionService;

parent::__construct('doc:shippingMethod');
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
9 changes: 7 additions & 2 deletions code_samples/api/migration/src/Command/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@

use Ibexa\Migration\MigrationService;
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
{
private MigrationService $migrationService;

public function __construct(MigrationService $migrationService)
{
$this->migrationService = $migrationService;
parent::__construct('doc:migration');

parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$string_with_migration_content = '';
$this->migrationService->add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
use Ibexa\Contracts\ProductCatalog\AttributeTypeServiceInterface;
use Ibexa\Contracts\ProductCatalog\Local\LocalAttributeDefinitionServiceInterface;
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
{
private AttributeGroupServiceInterface $attributeGroupService;
Expand Down Expand Up @@ -46,7 +50,7 @@ public function __construct(
$this->userService = $userService;
$this->permissionResolver = $permissionResolver;

parent::__construct('doc:attributes');
parent::__construct();
}

public function configure(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
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\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
{
private UserService $userService;
Expand All @@ -38,7 +42,8 @@ public function __construct(
$this->permissionResolver = $permissionResolver;
$this->productService = $productService;
$this->catalogService = $catalogService;
parent::__construct('doc:catalog');

parent::__construct();
}

public function configure(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
use Ibexa\Contracts\ProductCatalog\CurrencyServiceInterface;
use Ibexa\Contracts\ProductCatalog\Values\Currency\CurrencyCreateStruct;
use Ibexa\Contracts\ProductCatalog\Values\Currency\CurrencyUpdateStruct;
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
{
private CurrencyServiceInterface $currencyService;
Expand All @@ -23,11 +27,10 @@ final class CurrencyCommand extends Command
public function __construct(CurrencyServiceInterface $currencyService, UserService $userService, PermissionResolver $permissionResolver)
{
$this->currencyService = $currencyService;

$this->userService = $userService;
$this->permissionResolver = $permissionResolver;

parent::__construct('doc:currency');
parent::__construct();
}

public function configure(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Contracts\ProductCatalog\AssetServiceInterface;
use Ibexa\Contracts\ProductCatalog\ProductServiceInterface;
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
{
private UserService $userService;
Expand All @@ -33,7 +37,8 @@ public function __construct(
$this->permissionResolver = $permissionResolver;
$this->productService = $productService;
$this->assetService = $assetService;
parent::__construct('doc:assets');

parent::__construct();
}

public function configure(): void
Expand Down
Loading
Loading