get
Get service instance.

@param string $name
@param array $parameters
@return mixed
@access public
@uses \ReflectionClass
@throws NotFoundException
541714
public function get($name, array $parameters = [])
    {
        // Shared services are preserved through whole request
        if (isset($this->shared[$name])) {
            return $this->shared[$name];
        }

        if (!$this->has($name)) {
            throw new NotFoundException('No definition found for service "' . $name . '".');
        }

        $definition = $this->definitions[$name];

        // Alias is a link to another definition
        if (isset($definition['alias'])) {
            return $this->get($definition['alias']);
        }

        // "Init" directive is a function that returns instance of service
        if (isset($definition['init'])) {
            $service_class = call_user_func($definition['init'], $this, $parameters);

            if ($service_class === false) {
                throw new NotFoundException('"Init" directive for service "' . $name . '" did not produced any object.');
            }
        } else {
            $arguments = [];

            // Array of arguments which are given to constructor method
            if (isset($definition['arguments'])) {
                $arguments = $this->resolveArrayOfArguments($definition['arguments'], $parameters);
            }

            // Service is made by static method
            if (isset($definition['static'])) {
                $service_class = call_user_func_array([$definition['class'], $definition['static']], $arguments);

                if ($service_class === false) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }
            } else {
                // Service is made by normal constructor
                try {
                    $reflection_class = new \ReflectionClass($definition['class']);
                } catch (\ReflectionException $e) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }

                $service_class = $reflection_class->newInstanceArgs($arguments);
            }
        }

        // "After" directive is a function that is called after instantiation of service object
        if (isset($definition['after'])) {
            call_user_func($definition['after'], $this, $service_class, $parameters);
        }

        // Preserve shared service
        if (isset($definition['shared']) && $definition['shared'] === true) {
            $this->shared[$name] = $service_class;
        }

        return $service_class;
    }
288369
public function get($name)
    {
        $instance = self::getInstance();
        if (!$instance->offsetExists($name)) {
            throw new \RuntimeException(sprintf('Class %s Not Found', $name));
        }

        return $instance->offsetGet($name);
    }
566659
public function getParameter($name)
    {
        if (!$name || !array_key_exists($name, $this->parameters)) {
            throw new ParameterNotFoundException($name);
        }
        return $this->parameters[$name];
    }
867271
public function get(string $name): Parameter
    {
        if (!$this->has($name)) {
            //Automatically creating constant
            $parameter = new Parameter($name);
            $this->add($parameter);

            return $parameter;
        }

        return parent::get($name);
    }
290065
public function get($name, $parameters = null)
    {
        if (isset($this->_instances[$name])) {
            return $this->_instances[$name];
        }

        if (isset($this->_definitions[$name])) {
            $definition = $this->_definitions[$name];
        } else {
            return $this->getInstance($name, $parameters, $name);
        }

        $instance = $this->getInstance($definition, $parameters, $name);

        if (is_string($definition) || !isset($definition['shared']) || $definition['shared'] === true) {
            $this->_instances[$name] = $instance;
        }

        return $instance;
    }
1130595
public function getRouteByName($name, $parameters = [])
    {
        $qb = $this->pageRepository->createQueryBuilder('p');
        $results = $qb
            ->select('p.route, p.controller, t.path, t.locale')
            ->join('p.translations', 't')
            ->andWhere($qb->expr()->eq('p.static', 0))
            ->andWhere($qb->expr()->eq('p.route', $qb->expr()->literal($name)))
            ->getQuery()
            ->getArrayResult()
        ;

        $routes = $this->transformResultsToRoutes($results);
        if (count($routes) == 1) {
            return current($routes);
        }

        return null;
    }
1222775
public function findURI(string $name, array $parameters = [])
    {
        if (array_key_exists($name, $this->route_names)) {
            $foundUri = $this->route_names[$name];
            // insert provided parameters on his slot
            foreach ($parameters as $parameter => $value) {
                $foundUri = preg_replace("/\{(".$parameter.")(\:\w+)?\}/i", $value, $foundUri);
            }
            return $foundUri;
        }

        return null;
    }
744814
public function getInstance($definition, $parameters = null, $name = null)
    {
        if (is_string($definition)) {
            $params = [];
        } elseif (isset($definition['class'])) {
            $params = $definition;
            $definition = $definition['class'];
            unset($params['class'], $params['shared']);
        } elseif (isset($definition[0])) {
            $params = $definition;
            $definition = $definition[0];
            unset($params[0], $params['shared']);
        } else {
            $params = [];
        }

        if ($parameters === null) {
            if (!$params || isset($params[0])) {
                $parameters = $params;
            } else {
                $parameters = [$params];
            }
        } elseif (count($parameters) !== 0 && !isset($parameters[0])) {
            $parameters = [$parameters];
        }

        if (is_string($definition)) {
            if ($definition[0] === '@') {
                $definition = $this->alias->resolveNS($definition);
            }

            if (!class_exists($definition)) {
                throw new InvalidValueException(['`:name` component cannot be resolved: `:class` class is not exists',
                    'name' => $name,
                    'class' => $definition]);
            }
            $count = count($parameters);

            if ($count === 0) {
                $instance = new $definition();
            } elseif ($count === 1) {
                $instance = new $definition($parameters[0]);
            } elseif ($count === 2) {
                $instance = new $definition($parameters[0], $parameters[1]);
            } elseif ($count === 3) {
                $instance = new $definition($parameters[0], $parameters[1], $parameters[2]);
            } else {
                $reflection = new \ReflectionClass($definition);
                $instance = $reflection->newInstanceArgs($parameters);
            }
        } elseif ($definition instanceof \Closure) {
            $instance = call_user_func_array($definition, $parameters);
        } elseif (is_object($definition)) {
            $instance = $definition;
        } else {
            throw new NotSupportedException(['`:name` component cannot be resolved: component implement type is not supported', 'name' => $name]);
        }

        if ($instance instanceof Component || method_exists($instance, 'setDi')) {
            $instance->setDi($this);
        }

        return $instance;
    }
489407
public function getGetParameter($name)
    {
        if (!$this->hasGetParameter($name)) {
            throw new \InvalidArgumentException(sprintf('The GET request parameter "%s" does not exist.', $name));
        }

        return $this->getParameters[rawurlencode($name)];
    }
448007
public function get($name)
    {
        $item = $this->getFactory($name)->get();

        if ($item instanceof ContainerAwareInterface) {
            $item->setContainer($this);
        }

        return $item;
    }
444271
public function getPath($name, array $parameters = array())
    {
        return $this->container->get('router.url_generator')->generate($name, $parameters, false);
    }
924551
protected function service($name) {

		if(false === is_string($name)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR);
		}

		if(true === ServiceContainer :: has($name)) {
			return ServiceContainer :: get($name);
		}

		$function = Application :: get(['services', $name], false);

		if('object' === gettype($function)) {
			
			$func = $function();

			ServiceContainer :: add($name, $func);
			return $func;
		}

		return trigger_error(sprintf('Argument 1 "%s" passed to %s() is not a known service', $name, __METHOD__), E_USER_ERROR);
	}
665396
private function getProvider($name)
    {
        if ($this->providers->has($name)) {
            return $this->providers->get($name);
        }

        try {
            return $this->getOrCreateProviderFactory()->createProvider("$name");
        } catch (ObjectNotCreatedException $exception) {
            throw new ProviderNotFoundException("No such provider registered: \"$name\".", $exception);
        }
    }
1358691
public function getService($name = null)
    {
        $name = $name ?: $this->defaultService;

        if (!$name) {
            throw new \RuntimeException(sprintf(
                'You must configure a default %s service, registered %s services: "%s"',
                $this->serviceType, $this->serviceType,
                implode('", "', array_keys($this->services))
            ));
        }

        if (isset($this->services[$name])) {
            return $this->services[$name];
        }

        $this->assertServiceExists($name);
        $this->services[$name] = $this->container->get($this->serviceMap[$name]);

        return $this->services[$name];
    }
816015
public function create($name, ...$params) {
        if (!isset($this->services[$name])) throw new ServiceNotFoundException('Service "'.$name.'" not found.');
        try {
            return $this->services[$name]->resolve($factory=true, $params);
        }
        catch (\Exception $ex) {
            throw new ContainerException($ex->getMessage(), $ex->getCode(), $ex);
        }
    }
746064
public function get($name, array $arguments = [])
    {
        if (array_key_exists($name, $this->reflections) === false) {
            throw new RegistryNotFoundException("$name not found registry");
        }

        $reflection = $this->reflections[$name];

        return $reflection->newInstanceArgs($arguments);
    }
758168
public function get($name) {
        if (!isset($this->services[$name])) throw new ServiceNotFoundException('Service "'.$name.'" not found.');
        try {
            return $this->services[$name]->resolve($factory=false);
        }
        catch (\Exception $ex) {
            throw new ContainerException($ex->getMessage(), $ex->getCode(), $ex);
        }
    }