protected static function createKernel(array $options) { static::$tmpPath = sys_get_temp_dir() . '/be_simple_sso_auth_bundle_tests'; static::$configFile = __DIR__ . '/../Resources/config/' . $options['sso_server_name'] . '.yml'; if (file_exists(static::$tmpPath)) { $fs = new Filesystem(); $fs->remove(static::$tmpPath); } $kernel = new AppKernel(static::$tmpPath, static::$configFile, isset($options['environment']) ? $options['environment'] : 'test', isset($options['debug']) ? $options['debug'] : true); HttpClient::setKernel($kernel); return $kernel; }
protected static function checkConfig() { if (static::$configFileNeedsChecking) { if (null === static::$configFile) { static::$configFile = dirname(dirname(__FILE__)) . '/config.php'; } if (file_exists(static::$configFile)) { include static::$configFile; } static::$configFileNeedsChecking = false; // successful or no, don't try again } }
protected static function setConfig() { if (static::$configFile !== static::setConfigFile()) { static::$config = null; static::$configFile = null; } if (static::$configFile === null) { static::$configFile = static::setConfigFile(); } if (static::$config === null) { static::doSetConfig(); } }
/** * @param Event $event * @return string */ public static function getConfigFile(Event $event) { $extras = $event->getComposer()->getPackage()->getExtra(); if (isset($extras['chansig-router-parameters'])) { $configs = $extras['chansig-router-parameters']; if (!is_array($configs)) { throw new \InvalidArgumentException('The extra.chansig-router-parameters setting must be an array.'); } if (isset($configs['config-file'])) { if (!is_string($configs['config-file'])) { throw new \InvalidArgumentException('The extra.chansig-router-parameters.config-file setting must be a string.'); } static::$configFile = $configs['config-file']; } } $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); return realpath(sprintf('%s/../', $vendorDir)) . DIRECTORY_SEPARATOR . static::$configFile; }