Symfony\Component\DependencyInjection\Definition::isShared PHP Method

isShared() public method

Whether this service is shared.
public isShared ( ) : boolean
return boolean
    public function isShared()
    {
        return $this->shared;
    }

Usage Example

Example #1
0
    /**
     * {@inheritdoc}
     */
    public function getProxyFactoryCode(Definition $definition, $id)
    {
        $instantiation = 'return';
        if ($definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
            $instantiation .= " \$this->services['{$id}'] =";
        } elseif ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== ($scope = $definition->getScope(false))) {
            $instantiation .= " \$this->services['{$id}'] = \$this->scopedServices['{$scope}']['{$id}'] =";
        }
        $methodName = 'get' . Container::camelize($id) . 'Service';
        $proxyClass = $this->getProxyClassName($definition);
        return <<<EOF
        if (\$lazyLoad) {

            {$instantiation} new {$proxyClass}(
                function (&\$wrappedInstance, \\ProxyManager\\Proxy\\LazyLoadingInterface \$proxy) {
                    \$wrappedInstance = \$this->{$methodName}(false);

                    \$proxy->setProxyInitializer(null);

                    return true;
                }
            );
        }


EOF;
    }
All Usage Examples Of Symfony\Component\DependencyInjection\Definition::isShared