getMatcherForMatchType() public method

public getMatcherForMatchType ( $matchType ) : Thruway\Subscription\MatcherInterface | boolean
$matchType
return Thruway\Subscription\MatcherInterface | boolean
Esempio n. 1
0
 /**
  * @param $args
  * @throws \Exception
  */
 public function addStateHandler($args)
 {
     $uri = isset($args[0]->uri) ? $args[0]->uri : null;
     $handlerUri = isset($args[0]->handler_uri) ? $args[0]->handler_uri : null;
     $options = isset($args[0]->options) && is_object($args[0]->options) ? $args[0]->options : new \stdClass();
     $matchType = SubscribeMessage::getMatchTypeFromOption($options);
     $matcher = $this->broker->getMatcherForMatchType($matchType);
     if ($uri === null) {
         throw new \Exception("No uri set for state handler registration.");
     }
     if ($handlerUri === null) {
         throw new \Exception("No handler uri set for state handler registration.");
     }
     if ($matcher === false) {
         throw new \Exception("State handler match type \"" . $matchType . "\" is not registered.");
     }
     $stateHandlerRegistration = new StateHandlerRegistration($this->getSession(), $handlerUri, $uri, $options, $matcher);
     $this->stateHandlerRegistrations[] = $stateHandlerRegistration;
     $this->mapNewStateHandlerRegistration($stateHandlerRegistration);
 }