/**
  * {@inherit}
  *
  * {@inherit}
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('config')[self::TICKER_SERVICE_NAME];
     $callbackManager = new CallbackManager($container);
     if (!isset($config['hop']['callback'])) {
         throw new CallbackException("The necessary parameter \"hop/callback\" does not exist.");
     }
     if (!isset($config['tick']['callback'])) {
         throw new CallbackException("The necessary parameter \"tick/callback\" does not exist.");
     }
     /** @var \zaboy\scheduler\Callback\Interfaces\CallbackInterface $hopCallback */
     $hopCallback = $callbackManager->get($config['hop']['callback']);
     /** @var \zaboy\scheduler\Callback\Interfaces\CallbackInterface $tickCallback */
     $tickCallback = $callbackManager->get($config['tick']['callback']);
     $ticker = new Ticker($tickCallback, $hopCallback, $config);
     return $ticker;
 }
Beispiel #2
0
 protected function prepareCallbackServiceName($callbackServiceName)
 {
     if (is_callable($callbackServiceName)) {
         if (is_string($callbackServiceName) && $this->callbackManager->has($callbackServiceName)) {
             throw new CallbackException('Specified service name is ambiguous:
                 both service name and callable are exist');
         }
         $callbackServiceName = $this->serializeCallback($callbackServiceName);
     } elseif (is_string($callbackServiceName) && !$this->callbackManager->has($callbackServiceName)) {
         throw new CallbackException('Specified callback "' . $callbackServiceName . '" doesn\'t exist');
     }
     return $callbackServiceName;
 }