setNotifier() public method

public setNotifier ( callable $notifier )
$notifier callable
Exemplo n.º 1
0
 /**
  * Adds new service definition.
  * @param  string
  * @return ServiceDefinition
  */
 public function addDefinition($name, ServiceDefinition $definition = NULL)
 {
     $this->classListNeedsRefresh = TRUE;
     if (!is_string($name) || !$name) {
         // builder is not ready for falsy names such as '0'
         throw new Nette\InvalidArgumentException(sprintf('Service name must be a non-empty string, %s given.', gettype($name)));
     }
     $name = isset($this->aliases[$name]) ? $this->aliases[$name] : $name;
     if (isset($this->definitions[$name])) {
         throw new Nette\InvalidStateException("Service '{$name}' has already been added.");
     }
     if (!$definition) {
         $definition = new ServiceDefinition();
     }
     $definition->setNotifier(function () {
         $this->classListNeedsRefresh = TRUE;
     });
     return $this->definitions[$name] = $definition;
 }