AsseticBundle\ServiceFactory::__invoke PHP Method

__invoke() public method

public __invoke ( Interop\Container\ContainerInterface $locator, string $requestedName, array $options = null ) : Service
$locator Interop\Container\ContainerInterface
$requestedName string
$options array
return Service
    public function __invoke(ContainerInterface $locator, $requestedName, array $options = null)
    {
        $asseticConfig = $locator->get('AsseticConfiguration');
        if ($asseticConfig->detectBaseUrl()) {
            /** @var $request \Zend\Http\PhpEnvironment\Request */
            $request = $locator->get('Request');
            if (method_exists($request, 'getBaseUrl')) {
                $asseticConfig->setBaseUrl($request->getBaseUrl());
            }
        }
        $asseticService = new Service($asseticConfig);
        $asseticService->setAssetManager($locator->get('Assetic\\AssetManager'));
        $asseticService->setAssetWriter($locator->get('Assetic\\AssetWriter'));
        $asseticService->setFilterManager($locator->get('Assetic\\FilterManager'));
        // Cache buster is not mandatory
        if ($locator->has('AsseticCacheBuster')) {
            $asseticService->setCacheBusterStrategy($locator->get('AsseticCacheBuster'));
        }
        return $asseticService;
    }