public function getByType($class, $need = TRUE)
{
$class = ltrim($class, '\\');
if (!empty($this->meta[self::TYPES][$class][TRUE])) {
if (count($names = $this->meta[self::TYPES][$class][TRUE]) === 1) {
return $this->getService($names[0]);
}
throw new MissingServiceException("Multiple services of type {$class} found: " . implode(', ', $names) . '.');
} elseif ($need) {
throw new MissingServiceException("Service of type {$class} not found.");
}
}
/** * @return \Nette\Security\User */ private function getUser() { if (!$this->user) { $this->user = $this->container->getByType(User::class); } return $this->user; }