Interceptor handler
@param  object $class
@param  array $serviceConfig
@return object
504138
protected function encapsulate($class, $serviceConfig)
    {
        $encapsulators = $this->encapsulatorFactory->getEncapsulators();

        foreach ($encapsulators as $encapsulator) {
            $class = $encapsulator->encapsulate($this, $class, $serviceConfig);
        }

        return $class;
    }
441786
public <T> T getService (Class<T> sclass)
    {
        if (_bstrap == null) {
            return null;
        }
        int scount = _bstrap.services.size();
        for (int ii = 0; ii < scount; ii++) {
            InvocationService<?> service = _bstrap.services.get(ii);
            if (sclass.isInstance(service)) {
                return sclass.cast(service);
            }
        }
        return null;
    }
624837
public static function generalServiceManager(Iterable $serviceConfig = NULL, $selfRefNames= []) {
        if(!static::$serviceManager) {
            if(is_null($serviceConfig))
                throw new ServiceException(sprintf("First call of %s must pass a service configuration", __METHOD__), 13);

            /** @var ServiceManager $man */
            $man = static::$serviceManager = new static($serviceConfig);
            $man->selfReferenceNames = array_merge($man->selfReferenceNames, $selfRefNames);

            if($n = self::getGlobalVariableName())
                $GLOBALS[$n] = $man;
        }
        return static::$serviceManager;
    }
249250
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config             = $serviceLocator->get('config');
        $sessionOptions     = $serviceLocator->get(SessionOptions::class);
        $sessionConfig      = $config['uthando_session_manager']['config_options'] ?? [];
        /** @var SessionConfig $sessionConfigClass */
        $sessionConfigClass = $sessionOptions->getSessionConfigClass();
        $sessionConfigClass = new $sessionConfigClass() ;

        $sessionConfigClass->setOptions($sessionConfig);

        return $sessionConfigClass;
    }
1325222
private function intercept(array &$interceptors, &$request, &$method, &$metadata, &$options, callable $callback)
    {
        /** @var Client\Interceptors\Base $i */
        $i = array_shift($interceptors);
        if ($i) {
            $i->setRequest($request);
            $i->setMethod($method);
            $i->setMetadata($metadata);
            $client = $this->getClient();
            $i->setStub($client);
            return $i->call(function () use (
                &$i,
                &$interceptors,
                &$method,
                &$request,
                &$metadata,
                &$options,
                &$callback
            ) {
                $metadata = $i->getMetadata();
                $request = $i->getRequest();
                if (count($interceptors) > 0) {
                    return $this->intercept($interceptors, $request, $method, $metadata, $options, $callback);
                } else {
                    return $callback();
                }
            });
        } else {
            return $callback();
        }
    }
123732
protected function instantiateController($class)
    {
        $refCls = new \ReflectionClass($class);
        if ($refCls->implementsInterface(ExtensionInterface::class)) {
            Deprecated::warn('Using Extension class name', 3.3, 'Use controller object in route definition or make the controller a service and use the service name instead.');

            /** @var \Bolt\Extension\ResolvedExtension[] $extensions */
            $extensions = $this->app['extensions']->all();

            foreach ($extensions as $extension) {
                if ($class === get_class($extension)) {
                    return $extension;
                }
            }
        }

        return parent::instantiateController($class);
    }
321112
private function selectEvenHandlers(string $handlerClass): iterable
    {
        $reflection = new ReflectionClass($handlerClass);
        foreach ($reflection->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC) as $method) {
            if ($this->isEventHandlerMethod($method) === true) {
                $eventClass = $method->getParameters()[0]->getClass()->getName();
                $subscriber = [$handlerClass, $method->getName()];
                yield $eventClass => $subscriber;
            }
        }
    }
1123077
protected function classIsEventSubscriber($class)
    {
        $reflectionClass = new \ReflectionClass($class);
        $interfaces = $reflectionClass->getInterfaceNames();
        foreach ($interfaces as $interface) {
            if ($interface == 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface') {
                return true;
            }
        }

        return false;
    }
835076
protected function convertExceptionToServiceException(Exception $e): ServiceException
    {
        $exception = get_class($e);
        $conversion = $this->container['config']->get('exception.conversion', []);

        if (isset($conversion[$exception])) {
            return new $conversion[$exception]($e->getMessage(), $e->getCode(), $e);
        } /*else if (in_array($exception, $conversion, true)) {
            return new ServiceException($e->getMessage(), 400, $e);
        }*/ else {
            $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 400;

            return new ServiceException($e->getMessage(), $statusCode, $e);
        }
    }
378942
public function &getRequest($requestClass = '')
    {
        if (!is_string($requestClass) || $requestClass === '') {
            $requestClass = $this->getConfig()->get('Request.class', null, 'Teleport\Request\CLIRequest');
        }
        if (!$this->request instanceof $requestClass) {
            $this->request = new $requestClass();
        }
        return $this->request;
    }
845852
public function getService($serviceClass, $clientCustomerId = null, $credentials = null)
    {
        $adwordsServices = new AdWordsServices();

        $session = $this->session($clientCustomerId, $credentials);

        return $adwordsServices->get($session, $serviceClass);
    }
1137644
public function addSubscriberService($serviceId, $class)
    {
        foreach ($class::getSubscribedEvents() as $eventName => $params) {
            if (is_string($params)) {
                $this->addListenerService($eventName, array($serviceId, $params), 0);
            } elseif (is_string($params[0])) {
                $this->addListenerService($eventName, array($serviceId, $params[0]), isset($params[1]) ? $params[1] : 0);
            } else {
                foreach ($params as $listener) {
                    $this->addListenerService($eventName, array($serviceId, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
                }
            }
        }
    }
343332
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /**
         * @var array                              $config
         * @var \RouteGuard\Service\InstanceLoader $loader
         */
        $config      = $serviceLocator->get('config');
        $guardConfig = isset($config['guards']) ? $config['guards'] : [];
        $loader      = $serviceLocator->get('RouteGuard\Service\InstanceLoader');
        $service     = new RouteGuard($guardConfig, $loader);

        return $service;
    }
619207
public void registerServiceClass(Class serviceClass) {

		registeredServiceClasses.put(serviceClass.getSimpleName(), serviceClass);

		// make it possible to select options in configuration editor
		Settings.Services.addAvailableOption(serviceClass.getSimpleName());
	}
1175350
public function registerService($service, $class)
    {
        $this[$service] = function ($app) use ($class) {
                $inst = new $class;
                if ($inst instanceof FactoryInterface) {
                    return $inst->create($app);
                } else {
                    return $inst;
                }
            };
    }
923038
public function getService($serviceClass)
    {
        $dfpServices = new DfpServices();

        $session = $this->session();

        return $dfpServices->get($session, $serviceClass);
    }
12199
public function tap($object=null, $interceptor=null) {
    list($object, $interceptor) = self::_wrapArgs(func_get_args(), 2);
    
    $interceptor($object);
    return self::_wrap($object);
  }