Gets an already defined service definition.

@param string $id

@return ServiceConfigurator

@throws ServiceNotFoundException if the service definition does not exist
556272
final public function get($id)
    {
        $allowParent = !$this->defaults->getChanges() && empty($this->instanceof);
        $definition = $this->container->getDefinition($id);

        return new ServiceConfigurator($this->container, $definition->getInstanceofConditionals(), $allowParent, $this, $definition, $id, array());
    }
971877
private function addService($id, Definition $definition)
    {
        $this->definitionVariables = new \SplObjectStorage();
        $this->referenceVariables = array();
        $this->variableCount = 0;

        $return = array();

        if ($definition->isSynthetic()) {
            $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
        } elseif ($class = $definition->getClass()) {
            $class = $this->container->resolveEnvPlaceholders($class);
            $return[] = sprintf('@return %s A %s instance', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
        } elseif ($definition->getFactory()) {
            $factory = $definition->getFactory();
            if (is_string($factory)) {
                $return[] = sprintf('@return object An instance returned by %s()', $factory);
            } elseif (is_array($factory) && (is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) {
                if (is_string($factory[0]) || $factory[0] instanceof Reference) {
                    $return[] = sprintf('@return object An instance returned by %s::%s()', (string) $factory[0], $factory[1]);
                } elseif ($factory[0] instanceof Definition) {
                    $return[] = sprintf('@return object An instance returned by %s::%s()', $factory[0]->getClass(), $factory[1]);
                }
            }
        }

        if ($definition->isDeprecated()) {
            if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
                $return[] = '';
            }

            $return[] = sprintf('@deprecated %s', $definition->getDeprecationMessage($id));
        }

        $return = str_replace("\n     * \n", "\n     *\n", implode("\n     * ", $return));
        $return = $this->container->resolveEnvPlaceholders($return);

        $doc = '';
        if ($definition->isShared()) {
            $doc .= <<<'EOF'

     *
     * This service is shared.
     * This method always returns the same instance of the service.
EOF;
        }

        if (!$definition->isPublic()) {
            $doc .= <<<'EOF'

     *
     * This service is private.
     * If you want to be able to request this service from the container directly,
     * make it public, otherwise you might end up with broken code.
EOF;
        }

        if ($definition->isAutowired()) {
            $doc = <<<EOF

     *
     * This service is autowired.
EOF;
        }

        if ($definition->isLazy()) {
            $lazyInitialization = '$lazyLoad = true';
            $lazyInitializationDoc = "\n     * @param bool    \$lazyLoad whether to try lazy-loading the service with a proxy\n     *";
        } else {
            $lazyInitialization = '';
            $lazyInitializationDoc = '';
        }

        // with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
        $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
        $visibility = $isProxyCandidate ? 'public' : 'protected';
        $methodName = $this->generateMethodName($id);
        $code = <<<EOF

    /*{$this->docStar}
     * Gets the '$id' service.$doc
     *$lazyInitializationDoc
     * $return
     */
    {$visibility} function {$methodName}($lazyInitialization)
    {

EOF;

        $code .= $isProxyCandidate ? $this->getProxyDumper()->getProxyFactoryCode($definition, $id, $methodName) : '';

        if ($definition->isSynthetic()) {
            $code .= sprintf("        throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n    }\n", $id);
        } else {
            if ($definition->isDeprecated()) {
                $code .= sprintf("        @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id)));
            }

            $code .=
                $this->addServiceInclude($id, $definition).
                $this->addServiceLocalTempVariables($id, $definition).
                $this->addServiceInlinedDefinitions($id, $definition).
                $this->addServiceInstance($id, $definition).
                $this->addServiceInlinedDefinitionsSetup($id, $definition).
                $this->addServiceProperties($id, $definition).
                $this->addServiceMethodCalls($id, $definition).
                $this->addServiceConfigurator($id, $definition).
                $this->addServiceReturn($id, $definition)
            ;
        }

        $this->definitionVariables = null;
        $this->referenceVariables = null;

        return $code;
    }
807257
public function getOrFail($id)
    {
        if (!$this->storage->offsetExists($id)) {
            throw new ResourceNotFoundException("Model with id #$id not found.");
        }
        return $this->deserializeFromStorage($this->storage->offsetGet($id));
    }
716891
public function get($id)
    {
        if ($this->has($id)) {
            $args = func_num_args() > 1 ? func_get_arg(1) : [];
            $this->resolve($args);
            return $this->getInstance($id, $args);
        } else {
            throw new NotFoundException(
                Message::get(Message::DI_SERVICE_NOTFOUND, $id),
                Message::DI_SERVICE_NOTFOUND
            );
        }
    }
313905
protected function serviceFromDefinition($id, $args)
    {
        // create the service object
        $service = $this->createServiceObject($id, $args);

        // run predefined methods if any
        $this->runDefinedMethods($id, $service);

        // decorate the service if DecorateExtension loaded
        $this->decorateService($service);

        return $service;
    }
289640
public function get($id)
    {
        if ($this->has($id)) {

            // prepare constructor arguments and scope
            list($args, $scope, $sid) = $this->prepareArguments(
                $id,
                func_get_args()
            );

            // try get from pool first
            if (empty($args) && isset($this->pool[$sid])) {
                // get service from the pool
                return $this->pool[$sid];

            // not in pool, create the service
            } else {
                // circular detection
                $this->checkCircularMark($id);

                // create service base on definition
                $service = $this->serviceFromDefinition($id, $args);

                // remove circular detection mark
                $this->removeCircularMark($id);

                // store service in the pool
                if (static::SCOPE_SINGLE !== $scope) {
                    $this->pool[$sid] = $service;
                }

                return $service;
            }
        } else {
            throw new NotFoundException(
                Message::get(Message::SERVICE_ID_NOT_FOUND, $id),
                Message::SERVICE_ID_NOT_FOUND
            );
        }
    }
880546
private function getServiceOrParameter($id)
    {
        if (array_key_exists($id, $this->aliases)) {
            return $this->offsetGet($this->aliases[$id]);
        }

        if (array_key_exists($id, $this->values)) {
            return $this->values[$id];
        }

        if (array_key_exists($id, $this->definitions)) {
            return $this->values[$id] = $this->build($this->definitions[$id]);
        }

        throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
    }
1083629
public function get($id, $args = null) {
		if (isset($args[2])) {
			$args = func_get_args();
			array_shift($args);
		}
		
		if (isset($this->_definitions[$id])) {
			return $this->_definitions[$id]->getService($args);
		}
		
		$locator = $this->getLocatorByServiceId($id);
		
		if ($locator !== null) {
			return $locator->get($id, $args);
		}
			
		throw new Exceptions\ServiceNotFound('Unable to found the service "' . $id . '"');
	}
830223
private function getUserById($id)
    {
        $user = $this->userService->findUserById($id);

        if (empty($user)) {
            throw $this->createNotFoundException('user not found');
        }

        return $user;
    }
564797
public function getInstance($id)
    {
        if (!\in_array($id, $this->adminServiceIds, true)) {
            $msg = sprintf('Admin service "%s" not found in admin pool.', $id);
            $shortest = -1;
            $closest = null;
            $alternatives = [];
            foreach ($this->adminServiceIds as $adminServiceId) {
                $lev = levenshtein($id, $adminServiceId);
                if ($lev <= $shortest || $shortest < 0) {
                    $closest = $adminServiceId;
                    $shortest = $lev;
                }
                if ($lev <= \strlen($adminServiceId) / 3 || false !== strpos($adminServiceId, $id)) {
                    $alternatives[$adminServiceId] = $lev;
                }
            }
            if (null !== $closest) {
                asort($alternatives);
                unset($alternatives[$closest]);
                $msg = sprintf(
                    'Admin service "%s" not found in admin pool. Did you mean "%s" or one of those: [%s]?',
                    $id,
                    $closest,
                    implode(', ', array_keys($alternatives))
                );
            }
            throw new \InvalidArgumentException($msg);
        }

        $admin = $this->container->get($id);

        if (!$admin instanceof AdminInterface) {
            throw new InvalidArgumentException(sprintf('Found service "%s" is not a valid admin service', $id));
        }

        return $admin;
    }
1139330
public function getById($id)
    {
        if (!isset($this->pluginInstances[$id])) {
            $class = $this->getPluginClass($id);
            if (!class_exists($class)) {
                $this->pluginInstances[$id] = false;
            } else {
                $this->pluginInstances[$id] = new $class(['wei' => $this->wei]);
            }
        }

        return $this->pluginInstances[$id];
    }
97899
public function extend(string $id) : DefinitionInterface
    {
        if ($this->providers->provides($id)) {
            $this->providers->register($id);
        }

        if ($this->definitions->has($id)) {
            return $this->definitions->getDefinition($id);
        }

        throw new NotFoundException(
            sprintf('Unable to extend alias (%s) as it is not being managed as a definition', $id)
        );
    }
1038939
public function get($serviceId)
    {
        if (!$this->has($serviceId)) {
            throw NotFoundException::constructWithThingNotFound($serviceId);
        }
        return $this->symfonyServiceContainer->get($serviceId);
    }
1291313
public function getAlias($id)
    {
        $id = (string) $id;

        if (!isset($this->aliasDefinitions[$id])) {
            throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id));
        }

        return $this->aliasDefinitions[$id];
    }
379575
public function getNew(string $id)
    {
        $definition = $this->raw($id);

        if (is_callable($definition)) {
            $service = call_user_func($definition, $this);
        } else {
            $service = $definition;
        }

        if (isset($this->extensionQueues[$id])) {
            $service = $this->extensionQueues[$id]->getService($service);
        }

        return $service;
    }
1357871
public function initDefinition($id) {
		$reflection = $this->getReflectionById($id);
		$args       = $this->getArguments();
		
		$definition = new Definition\ClassDefinition($reflection, $args);
		
		if ($this->isFactory()) {
			$definition->setFactoryMode();
		}
		
		return $definition;
	}
936634
public function get($id, $args = null) {
		if (isset($this->checkedIds[$id]) && ! $this->checkedIds[$id]) {
			throw new Exceptions\ServiceNotFound('Unable to found the service "' . $id . '"');
		}
		
		$args = $this->resolveArgs(func_get_args());
		
		try {
			$service = ($args === null)
				? $this->getService($id)
				: $this->getServiceByArgs($id, $args);
		}
		catch (Exceptions\ServiceNotFound $exception) {
			$this->checkedIds[$id] = false;
			throw $exception;
		}
		
		$this->checkedIds[$id] = true;
		return $service;
	}