Nette\DI\Container::findByType PHP Метод

findByType() публичный Метод

Gets the service names of the specified type.
public findByType ( $class ) : string[]
Результат string[]
    public function findByType($class)
    {
        $class = ltrim($class, '\\');
        return empty($this->meta[self::TYPES][$class]) ? [] : array_merge(...array_values($this->meta[self::TYPES][$class]));
    }

Usage Example

 /**
  * Creates new presenter instance.
  *
  * @param  string presenter class name
  * @return Application\IPresenter
  */
 public function createPresenter($class)
 {
     $callInjects = $this->alwaysCallInjects;
     $services = array_keys($this->container->findByTag('nette.presenter'), $class);
     if (count($services) > 1) {
         throw new Application\InvalidPresenterException("Multiple services of type {$class} found: " . implode(', ', $services) . '.');
     } elseif (count($services)) {
         $presenter = $this->container->createService($services[0]);
         $callInjects = FALSE;
     } elseif (count($services = $this->container->findByType($class)) === 1) {
         $presenter = $this->container->createService($services[0]);
     } else {
         $presenter = $this->container->createInstance($class);
         $callInjects = TRUE;
     }
     if (!$presenter instanceof Application\IPresenter) {
         throw new UnexpectedValueException("Unable to create create presenter, returned value is not Nette\\Application\\IPresenter type.");
     }
     if ($callInjects) {
         $this->container->callInjects($presenter);
     }
     if ($presenter instanceof Application\UI\Presenter && $presenter->invalidLinkMode === NULL) {
         $presenter->invalidLinkMode = $this->invalidLinkMode;
     }
     return $presenter;
 }
All Usage Examples Of Nette\DI\Container::findByType