OneLogin_Saml2_Settings::__construct PHP Method

__construct() public method

Initializes the settings: - Sets the paths of the different folders - Loads settings info from settings file or array/object provided
public __construct ( array | object | null $settings = null, $spValidationOnly = false )
$settings array | object | null SAML Toolkit Settings
    public function __construct($settings = null, $spValidationOnly = false)
    {
        $this->_spValidationOnly = $spValidationOnly;
        $this->_loadPaths();
        if (!isset($settings)) {
            if (!$this->_loadSettingsFromFile()) {
                throw new OneLogin_Saml2_Error('Invalid file settings: %s', OneLogin_Saml2_Error::SETTINGS_INVALID, array(implode(', ', $this->_errors)));
            }
            $this->_addDefaultValues();
        } else {
            if (is_array($settings)) {
                if (!$this->_loadSettingsFromArray($settings)) {
                    throw new OneLogin_Saml2_Error('Invalid array settings: %s', OneLogin_Saml2_Error::SETTINGS_INVALID, array(implode(', ', $this->_errors)));
                }
            } else {
                if ($settings instanceof OneLogin_Saml2_Settings) {
                    throw new Exception('Only instances of OneLogin_Saml_Settings are supported.');
                } else {
                    if (!$this->_loadSettingsFromArray($settings->getValues())) {
                        throw new OneLogin_Saml2_Error('Invalid array settings: %s', OneLogin_Saml2_Error::SETTINGS_INVALID, array(implode(', ', $this->_errors)));
                    }
                }
            }
        }
        $this->formatIdPCert();
        $this->formatSPCert();
        $this->formatSPKey();
    }

Usage Example

 public function __construct($config)
 {
     $settings = array('sp' => array('entityId' => $config['sp']['entity_id'], 'assertionConsumerService' => array('url' => $config['sp']['acs'], 'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'), 'singleLogoutService' => array('url' => $config['sp']['sls'], 'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'), 'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified'));
     parent::__construct($settings, true);
 }