for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Shopware\Core\Checkout\Customer\Rule;
use Shopware\Core\Checkout\CheckoutRuleScope;
use Shopware\Core\Framework\Rule\Rule;
use Shopware\Core\Framework\Rule\RuleConfig;
use Shopware\Core\Framework\Rule\RuleConstraints;
use Shopware\Core\Framework\Rule\RuleScope;
/**
* @package business-ops
*/
class CustomerCreatedByAdminRule extends Rule
{
* @internal
public function __construct(private bool $shouldCustomerBeCreatedByAdmin = true)
parent::__construct();
}
public function getName(): string
return 'customerCreatedByAdmin';
public function match(RuleScope $scope): bool
if (!$scope instanceof CheckoutRuleScope) {
return false;
if (!$customer = $scope->getSalesChannelContext()->getCustomer()) {
return $this->shouldCustomerBeCreatedByAdmin === (bool) $customer->getCreatedById();
public function getConstraints(): array
return [
'shouldCustomerBeCreatedByAdmin' => RuleConstraints::bool(true),
];
public function getConfig(): RuleConfig
return (new RuleConfig())
->booleanField('shouldCustomerBeCreatedByAdmin');