Set up anything required for the driver.

Called when the driver is used for the first time.
Checks `core is-installed`, and the version number.

@throws \RuntimeException
493679
public function bootstrap()
    {
        $version = '';

        preg_match('#^WP-CLI (.*)$#', $this->wpcli('cli', 'version')['stdout'], $match);
        if (! empty($match)) {
            $version = array_pop($match);
        }

        if (! version_compare($version, '1.5.0', '>=')) {
            throw new RuntimeException('[W100] Your WP-CLI is too old; version 1.5.0 or newer is required.');
        }

        $status = $this->wpcli('core', 'is-installed')['exit_code'];
        if ($status !== 0) {
            throw new RuntimeException('[W101] WordPress does not seem to be installed. Check "path" and/or "alias" settings in behat.yml.');
        }

        putenv('WP_CLI_STRICT_ARGS_MODE=1');

        $this->is_bootstrapped = true;
    }
240078
protected function runtime()
    {
        $filesystem = app(Filesystem::class);
        $files      = $filesystem->glob(storage_path('license') . '/*.key');
        if (!empty($files)) {
            app('antares.memory')->make('runtime')->push('instance_key', $filesystem->get($files[0]));
        }
    }
1087030
protected function installDriversIfEnabled(): void
    {
        $reflection = new \ReflectionClass($this);
        $reader = new AnnotationReader();

        $annotation = $reader->getClassAnnotation($reflection, Drivers::class);

        if (empty($annotation)) {
            return;
        }

        foreach ($annotation->install as $driver) {
            $this->{$driver} = $this->drivers->get($driver);
        }
    }
1306724
public function initialize()
    {
        if (null !== $this->collection) {
            return;
        }

        if (empty($this->dbOptions['database'])) {
            throw new \RuntimeException('The option "database" must be set');
        }
        if (empty($this->dbOptions['collection'])) {
            throw new \RuntimeException('The option "collection" must be set');
        }

        $this->collection = $this
            ->mongo
            ->selectDB($this->dbOptions['database'])
            ->selectCollection($this->dbOptions['collection']);
    }
1005141
private function checkDir() : void
    {
        $dir = dirname($this->path);
        if (!is_dir($dir)) {
            if (file_exists($dir)) {
                throw new \RuntimeException($dir . ' exists and is not a directory.');
            }
            if (!@mkdir($dir, 0755, true)) {
                throw new \RuntimeException($dir . ' does not exist and could not be created.');
            }
        }
    }
1243661
protected function init()
	{
		if (isset($this->template) === false)
		{
			throw new \RuntimeException('Template property does not exist.');
		}

		if (empty($this->template) === false and is_string($this->template))
		{
			$this->template = $this->view($this->template);
		}
	}
448022
protected function init() {		
	    if(Apc::isAvailable()) {
		    $driver = new Apc();
		} else {
			if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
				// We may not have permission - especially during setup, before we instruct
				// the user to "chmod 777 /data"
				@mkdir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache');
			}
			if (is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
			    $driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache'));
			} else {
				// No cache available, let's just use a basic one :-(
				$driver = new Ephemeral();
			}
		}		

		$this->cache = new \Stash\Pool($driver);		
		$this->is_init = true;
	}
350776
public function init()
    {
        $stream = @fopen($this->config['url'], 'a');
        if (!$stream) {
            throw new \RuntimeException(sprintf("Couldn't open resource '%s'", $this->config['url']));
        }

        $this->stream = $stream;

        if (!empty($this->config['lock']) && $this->config['lock'] === true && stream_supports_lock($this->stream)) {
            $this->useLocks = true;
        }
    }
886293
public function iniciar()
    {
        if ($this->iniciado) {
            return true;
        }

        if (!$this->adaptador->abrir($this->nombre)) {
            throw new \RuntimeException('Hubo un error inicializando el adaptador de sesión.');
        }

        if (!$this->id) {
            $this->id = $this->generarId();
        }

        $this->datos = $this->adaptador->leer($this->id);

        return $this->iniciado = true;
    }
677450
private function validate()
    {
        if (!class_exists($this->class)) {
            throw new \RuntimeException(sprintf('Class %s does not exist, is this the correct namespace?', $this->class));
        }
        if (!in_array($this->method, get_class_methods($this->class))) {
            throw new \RuntimeException(sprintf('The method "%s" does not exist in "%s" class.', $this->method, $this->class));
        }
    }
54066
public function initialize()
    {
        if ($this->isActive()) {
            throw new RuntimeException('Process is already active');
        }

        $handle = $this->getFileResource();

        if (! @flock($handle, (LOCK_EX | LOCK_NB))) {
            throw new RuntimeException('Could not lock pidfile');
        }

        if (-1 === @fseek($handle, 0)) {
            throw new RuntimeException('Could not seek pidfile cursor');
        }

        if (! @ftruncate($handle, 0)) {
            throw new RuntimeException('Could not truncate pidfile');
        }

        if (! @fwrite($handle, $this->control->info()->getId().PHP_EOL)) {
            throw new RuntimeException('Could not write on pidfile');
        }
    }
798676
public static function setup(): void
    {
        $aComponents          = Components::available();
        self::$aContainers    = [];
        self::$aLoadedHelpers = [];
        $aDiscoveredServices  = [
            'nails/common' => self::findServicesForComponent('nails/common'),
        ];

        foreach ($aComponents as $oComponent) {
            $aDiscoveredServices[$oComponent->slug] = self::findServicesForComponent($oComponent->slug);
        }

        $aDiscoveredServices['app'] = self::findServicesForApp();
        $aDiscoveredServices        = array_filter($aDiscoveredServices);

        foreach ($aDiscoveredServices as $sComponentName => $aComponentServices) {

            //  Properties
            if (!empty($aComponentServices['properties'])) {
                if (empty(self::$aContainers[$sComponentName]['properties'])) {
                    self::$aContainers[$sComponentName]['properties'] = new Container();
                }
                foreach ($aComponentServices['properties'] as $sKey => $mValue) {
                    self::$aContainers[$sComponentName]['properties'][$sKey] = $mValue;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * SERVICES
             * All services are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['services'])) {
                if (empty(self::$aContainers[$sComponentName]['services'])) {
                    self::$aContainers[$sComponentName]['services'] = new Container();
                }
                foreach ($aComponentServices['services'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['services'][$sKey] = function () use ($sKey, $cCallable) {
                        return $cCallable;
                    };;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * MODELS
             * All models are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['models'])) {
                if (empty(self::$aContainers[$sComponentName]['models'])) {
                    self::$aContainers[$sComponentName]['models'] = new Container();
                }
                foreach ($aComponentServices['models'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['models'][$sKey] = function () use ($cCallable) {
                        return $cCallable;
                    };
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['factories'])) {
                if (empty(self::$aContainers[$sComponentName]['factories'])) {
                    self::$aContainers[$sComponentName]['factories'] = new Container();
                }
                foreach ($aComponentServices['factories'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['factories'][$sKey] = self::$aContainers[$sComponentName]['factories']
                        ->factory($cWrapper);
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['resources'])) {
                if (empty(self::$aContainers[$sComponentName]['resources'])) {
                    self::$aContainers[$sComponentName]['resources'] = new Container();
                }
                foreach ($aComponentServices['resources'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['resources'][$sKey] = self::$aContainers[$sComponentName]['resources']
                        ->factory($cWrapper);
                }
            }
        }
    }
302474
private function initializeCache()
    {
        // get driver
        if (!($driver = $this->config->get('CompilerCacheDriver', false))) {
            // default driver
            if ($this->isDevelopment()) {
                $driver = self::DEV_CACHE_DRIVER;
            } else {
                $driver = self::PROD_CACHE_DRIVER;
            }
        }

        // create driver instance
        try {
            $instance = $this->factory($driver, CacheDriverInterface::class);
            $this->cacheInstance = new Cache($instance);
        } catch (Exception $e) {
            throw $e;
        }
    }
790096
private function config()
    {
        if (realpath($this->configPath) !== false) {
            $json = file_get_contents($this->configPath);
            $this->config = json_decode($json);
            $this->config->rootDir = $this->rootDir;
        } else {
            throw new \RuntimeException('Framework not initialized yet. Consider running composer install');
        }
    }
431565
public function prepareProcess()
    {
        $phpFinder = new PhpExecutableFinder();
        if (false === $php = $phpFinder->find()) {
            throw new \RuntimeException('Unable to find the PHP executable.');
        }
        $this->phpBin = $php;
        $this->process = new Process(null);
    }
76664
public static function configure(): void
    {
        $filesystem = new Filesystem();
        $config     = [
            'colors'          => '1',
            'installed_paths' => implode(',', [
                Path::VENDOR_DIR . '/hostnet/phpcs-tool/src/',
                Path::VENDOR_DIR . '/slevomat/coding-standard/SlevomatCodingStandard',
            ]),
        ];

        if (!$filesystem->exists(['phpcs.xml', 'phpcs.xml.dist'])) {
            $config['default_standard'] = 'Hostnet';
        }

        $filesystem->dumpFile(
            Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf',
            sprintf('<?php $phpCodeSnifferConfig = %s;', var_export($config, true))
        );

        $filesystem->dumpFile(__DIR__ . '/../../../HostnetPaths/ruleset.xml', self::generateHostnetPathsXml());
    }
114891
public function initializeFusionRuntime()
    {
        if ($this->fusionRuntime === null) {
            $this->loadFusion();
            $this->fusionRuntime = new Runtime($this->parsedFusion, $this->controllerContext);
        }
        if (isset($this->options['debugMode'])) {
            $this->fusionRuntime->setDebugMode($this->options['debugMode']);
        }
        if (isset($this->options['enableContentCache'])) {
            $this->fusionRuntime->setEnableContentCache($this->options['enableContentCache']);
        }
    }