Coduo\TuTu\Request\ChainMatchingPolicy::addMatchingPolicy PHP Method

addMatchingPolicy() public method

public addMatchingPolicy ( Coduo\TuTu\Request\MatchingPolicy $matchingPolicy )
$matchingPolicy Coduo\TuTu\Request\MatchingPolicy
    public function addMatchingPolicy(MatchingPolicy $matchingPolicy)
    {
        $this->matchingPolicies[] = $matchingPolicy;
    }

Usage Example

Example #1
0
 private function registerRequestMatchingPolicy()
 {
     $this->container->setDefinition('request.matching_policy.method', function ($container) {
         return new MethodMatchingPolicy();
     }, ['matching_policy']);
     $this->container->setDefinition('request.matching_policy.route', function ($container) {
         return new RouteMatchingPolicy();
     }, ['matching_policy']);
     $this->container->setDefinition('request.matching_policy.parameter', function ($container) {
         return new ParameterMatchingPolicy($container->getService('php_matcher'));
     }, ['matching_policy']);
     $this->container->setDefinition('request.matching_policy.headers', function ($container) {
         return new HeadersMatchingPolicy($container->getService('php_matcher'));
     }, ['matching_policy']);
     $this->container->setDefinition('request.matching_policy.body', function ($container) {
         return new BodyMatchingPolicy($container->getService('php_matcher'));
     }, ['matching_policy']);
     $this->container->setDefinition('request.matching_policy', function ($container) {
         $matchingPolicy = new ChainMatchingPolicy();
         $matchingPolicies = $container->getServicesByTag('matching_policy');
         foreach ($matchingPolicies as $policy) {
             $matchingPolicy->addMatchingPolicy($policy);
         }
         return $matchingPolicy;
     });
 }