Service entry point.

@param int $mode The runtimeEnvironment of this service instance (can be either server or client)

@author Benjamin Carl <opensource@clickalicious.de>
@return object instance of this class
@access public
171402
public function __tearup($mode = self::MODE_SERVER, $container = self::CONTAINER_PDO, array $config = [])
    {
        if ($mode === self::MODE_SERVER) {
            // register the autoloader
            OAuth2\Autoloader::register();

            // create storage container for persistence
            $storage = new OAuth2\Storage\Pdo($config);

            // create OAuth2 Server instance
            $realObject = new OAuth2\Server($storage);

        } else {
            // here we would create a client instance
        }

        self::setRealObject(
            $realObject
        );
    }
164470
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
    {
        if ($instance instanceof ActionController) {
            //We are dealing with a ControllerManager so we need to get the main service manger first
            $instance->setCommandBus($serviceLocator->getServiceLocator()->get('proophessor.command_bus'));
        }
    }
671495
public function boot()
    {
        if (true === $this->booted) {
            return $this;
        }

        if($this->isDebug()) {
            ExceptionHandler::register(true, 'UTF-8', 'PPI Framework', self::VERSION, true);
        }

        $this->serviceManager = $this->buildServiceManager();
        $this->log('debug', sprintf('Booting %s ...', $this->name));

        // Loading our Modules
        $this->getModuleManager()->loadModules();
        if ($this->debug) {
            $modules = $this->getModuleManager()->getModules();
            $this->log('debug', sprintf('All modules online (%d): "%s"', count($modules), implode('", "', $modules)));
        }

        // Lets get all the services our of our modules and start setting them in the ServiceManager
        $moduleServices = $this->serviceManager->get('ModuleDefaultListener')->getServices();
        foreach ($moduleServices as $key => $service) {
            $this->serviceManager->setFactory($key, $service);
        }

        $this->booted = true;
        if ($this->debug) {
            $this->log('debug', sprintf('%s has booted (in %.3f secs)', $this->name, microtime(true) - $this->startTime));
        }

        return $this;
    }
844818
public function withSSL(int $mode = self::SSL_AUTO): self
    {
        $this->ssl = $mode;

        return $this;
    }
1353684
protected function getService()
    {
        if (!$this->service) {
            $this->service = $this->getContainer()->get(static::CONTROLLER_ENTITY_NAME . "_service");
        }

        return $this->service;
    }
878703
protected function init($mode = 0)
    {
        // initialize syslog
        if ($this->config->get('log_driver') == 'syslog') {
            $syslog_id       = $this->config->get('syslog_id', 'roundcube');
            $syslog_facility = $this->config->get('syslog_facility', LOG_USER);
            openlog($syslog_id, LOG_ODELAY, $syslog_facility);
        }

        // connect to database
        if ($mode & self::INIT_WITH_DB) {
            $this->get_dbh();
        }

        // create plugin API and load plugins
        if ($mode & self::INIT_WITH_PLUGINS) {
            $this->plugins = rcube_plugin_api::get_instance();
        }
    }
1316766
public static function getInstance($configFile = null, $mode = self::APP_MODE_PROD) {
        $c = get_called_class();
        if (!isset(self::$_instances[$c])) {
            // Create an instance
            self::$_instances[$c] = new $c($configFile, $mode);
            // Setup application
            self::$_instances[$c]->setup();
        }

        return self::$_instances[$c];
    }
1237746
public function init()
    {
        $serviceFactory = new \OAuth\ServiceFactory();
        $serviceFactory->setHttpClient(new CurlClient());
        $this->service = $serviceFactory->createService(
            $this->getServiceName(), $this->credentials, $this->sessionStorage, $this->scopes
        );

        return $this;
    }
378259
public static function getInstance()
    {
        if (is_null(self::$instance)) {
            throw new \RuntimeException('You must first create the singleton instance with createInstance().');
        }
        self::$instance->setGlobalsFromSugar();
        self::$instance->chdirToSugarDir();

        return self::$instance;
    }
440800
public function build(): StartObservingRequest
	{
		$instance = new StartObservingRequest();
		if ($this->service === null) {
			throw new BuilderException('Property [service] is required.');
		}
		$instance->service = $this->service;
		return $instance;
	}
701360
public function begin($mode = IExpressionGroup::MODE_AND)
    {
        $parentGroup = $this->currentExpressionGroup;

        $group = $this->queryBuilderFactory->createExpressionGroup($mode, $parentGroup);
        if ($parentGroup) {
            $parentGroup->addGroup($group);
        }

        $this->currentExpressionGroup = $group;

        return $this;
    }
886574
public function setMode($mode)
    {
        Assertion::choice($mode, $this->availableModes, "Mode '{$mode}' does not exist.");
        $this->mode = $mode;

        return $this;
    }
1205980
static function begin($name = NULL, $mode = NULL)
	{
		$object = static::_instance($name);
		$name = static::instanceName($name);

		if (static::$transactions[$name]) return FALSE;
		static::$transactions[$name] = $object->begin($mode);

		return static::$transactions[$name];
	}
1169702
protected function setup($mode)
    {
        $this->mode = $mode;

        // Set up runtime options. Will be passed to all
        // subclasses.
        $options = ['fetchmode' => $this->fetchMode];

        if ($this->oldVersion) {
            $options['svn_path'] = $this->getSvnPath();
        } else {
            $options['binaryPath'] = $this->getSvnPath();
        }

        // Pass array of subcommands we need to factory
        $this->svn = VersionControl_SVN::factory($mode, $options);

        if (get_parent_class($this->svn) !== 'VersionControl_SVN_Command') {
            $this->oldVersion = true;
            $this->svn->use_escapeshellcmd = false;
        }

        if (!empty($this->repositoryUrl)) {
            $this->svnArgs = [$this->repositoryUrl];
        } else {
            if (!empty($this->workingCopy)) {
                if (is_dir($this->workingCopy)) {
                    $this->svnArgs = [$this->workingCopy];
                } else {
                    if ($mode == 'info') {
                        if (is_file($this->workingCopy)) {
                            $this->svnArgs = [$this->workingCopy];
                        } else {
                            throw new BuildException("'" . $this->workingCopy . "' is not a directory nor a file");
                        }
                    } else {
                        throw new BuildException("'" . $this->workingCopy . "' is not a directory");
                    }
                }
            }
        }
    }
112312
public function createService(ServiceLocatorInterface $serviceLocator)
    {

        $pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
        $plugins = new $pluginManagerClass;
        $plugins->setServiceLocator($serviceLocator);
        $configuration    = $serviceLocator->get('Config');

        if (isset($configuration['di']) && $serviceLocator->has('Di')) {
            $di = $serviceLocator->get('Di');
            $plugins->addAbstractFactory(
                new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI)
            );
        }

        foreach ($this->defaultHelperMapClasses as $configClass) {
            if (is_string($configClass) && class_exists($configClass)) {
                $config = new $configClass;
            }

            if (!$config instanceof ConfigInterface) {
                throw new Exception\RuntimeException(sprintf(
                    'Invalid service manager configuration class provided; received "%s", expected class implementing %s',
                    $configClass,
                    'Zend\ServiceManager\ConfigInterface'
                ));
            }

            $config->configureServiceManager($plugins);
        }

        // Configure URL view helper with router
        $plugins->setFactory('url', function($sm) use($serviceLocator) {
            $helper = new ViewHelper\Url;
            $helper->setRouter($serviceLocator->get('Router'));

            $match = $serviceLocator->get('application')
                ->getMvcEvent()
                ->getRouteMatch();

            if ($match instanceof RouteMatch) {

                $helper->setRouteMatch($match);
            }

            return $helper;
        });

        $plugins->setFactory('basepath', function($sm) use($serviceLocator) {
            $config = $serviceLocator->get('Config');
            $config = $config['view_manager'];
            $basePathHelper = new ViewHelper\BasePath;
            if (isset($config['base_path'])) {
                $basePath = $config['base_path'];
            } else {
                $basePath = $serviceLocator->get('Request')->getBasePath();
            }
            $basePathHelper->setBasePath($basePath);
            return $basePathHelper;
        });

        /**
         * Configure doctype view helper with doctype from configuration, if available.
         *
         * Other view helpers depend on this to decide which spec to generate their tags
         * based on. This is why it must be set early instead of later in the layout phtml.
         */
        $plugins->setFactory('doctype', function($sm) use($serviceLocator) {
            $config = $serviceLocator->get('Config');
            $config = $config['view_manager'];
            $doctypeHelper = new ViewHelper\Doctype;
            if (isset($config['doctype'])) {
                $doctypeHelper->setDoctype($config['doctype']);
            }
            return $doctypeHelper;
        });

        return $plugins;
    }
1299181
public function start()
    {
        $routeMethodSep = '>';
        $storage = $this->routeService->getStorage();
        foreach ($storage as $match => $route) {
            if (($matched = $this->matchHttpRequest($match)) !== false) {
                if (!in_array($this->request->getMethod(), $route->methods)) {
                    throw new MethodNotAllowedException();
                }
                $this->request->withAttributes($matched);

                $middleWares = new MiddleWares($this->getMiddleWareFromRoute($route));
                $decorators = $route->decorators;

                if (\is_string($route->callback)) {
                    if (strpos($route->callback, $routeMethodSep) !== false) {
                        list($controller, $method) = explode($routeMethodSep, $route->callback);
                        return $this->connectMiddlewares($controller, $method, $middleWares, $decorators);
                    }
                }

                return $this->connectMiddlewares($route->callback, '__invoke', $middleWares, $decorators);
            }
        }

        throw new NotFoundException();
    }
1246715
public function fetch($mode = \PDO::FETCH_CLASS)
    {
        $run = null;
        try {
            $run = $this->sth->fetch($mode);
        } catch (\PDOException $e) {
            $this->errorInfo('', $e->getMessage());
            throw $e;
        }
        yield $run;
    }