Otagowane serwisy przykład

class CustomerChecker implements ActionCheckerInterface
{
    private $checkers = [];

    public function __construct(iterable $checkers)
    {
        $this->checkers = $checkers;
    }

    public function isEligible(ActionInterface $action): bool
    {
        foreach ($this->checkers as $checker) {
            if (false === $checker->isEligible($action)) {
                return false;
            }
        }

        return true;
    }
}
    Enp\Bundle\Promotion\ActionBundle\Checker\CustomerChecker:
        autowire: true
        arguments:
            - !tagged enp_promotion.action.customer_checker

    Enp\Bundle\Promotion\ActionBundle\Checker\CustomerPermissionChecker:
        autowire: true
        tags:
            - { name: enp_promotion.action.customer_checker }

 

Komentarze wyłączone