SimpleSAML_Configuration::getInstance PHP Method

getInstance() public static method

This function retrieves a configuration file by its instance name. The instance name is initialized by the init function, or by copyFromBase function. If no configuration file with the given instance name is found, an exception will be thrown.
public static getInstance ( string $instancename = 'simplesaml' ) : SimpleSAML_Configuration
$instancename string The instance name of the configuration file. Deprecated.
return SimpleSAML_Configuration The configuration object.
    public static function getInstance($instancename = 'simplesaml')
    {
        assert('is_string($instancename)');
        // check if the instance exists already
        if (array_key_exists($instancename, self::$instance)) {
            return self::$instance[$instancename];
        }
        if ($instancename === 'simplesaml') {
            try {
                return self::getConfig();
            } catch (SimpleSAML\Error\ConfigurationError $e) {
                throw \SimpleSAML\Error\CriticalConfigurationError::fromException($e);
            }
        }
        throw new \SimpleSAML\Error\CriticalConfigurationError('Configuration with name ' . $instancename . ' is not initialized.');
    }

Usage Example

コード例 #1
0
ファイル: Abstract.php プロジェクト: baszoetekouw/janus
    protected function _mailTechnicalContact($tag, sspmod_janus_Cron_Logger $logger)
    {
        $errorHtml = $this->_getHtmlForMessages($logger->getNamespacedErrors(), 'errors');
        $warningHtml = $this->_getHtmlForMessages($logger->getNamespacedWarnings(), 'warnings');
        $noticeHtml = $this->_getHtmlForMessages($logger->getNamespacedNotices(), 'notices');
        $config = SimpleSAML_Configuration::getInstance();
        $time = date(DATE_RFC822);
        $url = SimpleSAML_Utilities::selfURL();
        $message = <<<MESSAGE
<h1>Cron report</h1>
<p>Cron ran at {$time}</p>
<p>URL: <tt>{$url}</tt></p>
<p>Tag: {$tag}</p>
<h2>Errors</h2>
{$errorHtml}
<h2>Warnings</h2>
{$warningHtml}
<h2>Notices</h2>
{$noticeHtml}
MESSAGE;
        $toAddress = $config->getString('technicalcontact_email', '*****@*****.**');
        if ($toAddress == '*****@*****.**') {
            SimpleSAML_Logger::error('Cron - Could not send email. [technicalcontact_email] not set in config.');
        } else {
            $email = new SimpleSAML_XHTML_EMail($toAddress, 'JANUS cron report', '*****@*****.**');
            $email->setBody($message);
            $email->send();
        }
    }
All Usage Examples Of SimpleSAML_Configuration::getInstance