/** * Returns the config of current auth provider. * * @param string $authProvider Name of the auth provider you wish to use to process the login. * If you don't set it, the first registered provider will be used. * * @throws FirewallException * @return ConfigObject */ private function getAuthProviderConfig($authProvider) { // have we already fetched the auth config if ($this->authProviderConfig) { return $this->authProviderConfig; } if ($authProvider == '') { // get the first auth provider from the list $providers = $this->getConfig()->get('AuthenticationProviders', []); $authProvider = $providers[0]; } $this->authProviderConfig = Security::getConfig()->get('AuthenticationProviders.' . $authProvider, new ConfigObject()); // merge the internal driver // merge only if driver is not set and it matches the internal auth provider name if (!$this->authProviderConfig->get('Driver', false) && isset(self::$authProviders[$authProvider])) { $this->authProviderConfig->mergeWith(['Driver' => self::$authProviders[$authProvider]]); } // make sure the requested auth provider is assigned to the current firewall if (!in_array($authProvider, $this->getConfig()->get('AuthenticationProviders', [])->toArray())) { throw new FirewallException('Authentication provider "' . $authProvider . '" is not defined on "' . $this->getFirewallKey() . '" firewall.'); } // check that we have the driver if (!$this->authProviderConfig->get('Driver', false)) { throw new FirewallException('Unable to detect configuration for authentication provider "' . $authProvider . '".'); } $this->authProviderName = $authProvider; return $this->authProviderConfig; }
/** * Returns an instance of MessageInterface based on current bridge. * * @param $mailer * * @param ConfigObject $config * * @return \Webiny\Component\Mailer\MessageInterface * @throws MailerException * @throws \Webiny\Component\StdLib\Exception\Exception */ public static function getMessage($mailer, ConfigObject $config = null) { // Do it this way to avoid merging into the original mailer config $mailerConfig = Mailer::getConfig()->get($mailer)->toArray(); $mailerConfig = new ConfigObject($mailerConfig); if ($config) { $mailerConfig->mergeWith($config); } $lib = self::getLibrary($mailer); /** @var MailerInterface $libInstance */ $libInstance = self::factory($lib, '\\Webiny\\Component\\Mailer\\Bridge\\MailerInterface'); $instance = $libInstance::getMessage($mailerConfig); if (!self::isInstanceOf($instance, '\\Webiny\\Component\\Mailer\\Bridge\\MessageInterface')) { throw new MailerException(MailerException::MESSAGE_INTERFACE); } return $instance; }
/** * Loads all the configurations from a specific environment. * * @param string $environment Environment name. * * @return ConfigObject * @throws \Webiny\Component\Config\ConfigException */ private function loadConfigurations($environment) { $configs = new ConfigObject([]); $configFolder = $this->applicationAbsolutePath . 'App/Config/' . $environment; $h = scandir($configFolder); foreach ($h as $configFile) { if (strpos($configFile, 'yaml') === false) { continue; } $configs->mergeWith($this->config()->yaml($configFolder . DIRECTORY_SEPARATOR . $configFile)); } return $configs; }