Gdn_AuthenticationProviderModel::getDefault PHP 메소드

getDefault() 공개 정적인 메소드

Return the default provider.
public static getDefault ( ) : array
리턴 array
    public static function getDefault()
    {
        if (self::$default === null) {
            $Rows = self::getWhereStatic(array('IsDefault' => 1));
            if (empty($Rows)) {
                self::$default = false;
            } else {
                self::$default = array_pop($Rows);
            }
        }
        return self::$default;
    }

Usage Example

예제 #1
0
    /**
     * Check the default provider to see if it overrides one of the entry methods and then redirect.
     *
     * @param string $Type One of the following.
     *  - SignIn
     *  - Register
     *  - SignOut (not complete)
     * @param string $Target
     * @param string $TransientKey
     */
    protected function checkOverride($Type, $Target, $TransientKey = null)
    {
        if (!$this->Request->get('override', true)) {
            return;
        }
        $Provider = Gdn_AuthenticationProviderModel::getDefault();
        if (!$Provider) {
            return;
        }
        $this->EventArguments['Target'] = $Target;
        $this->EventArguments['DefaultProvider'] =& $Provider;
        $this->EventArguments['TransientKey'] = $TransientKey;
        $this->fireEvent("Override{$Type}");
        $Url = $Provider[$Type . 'Url'];
        if ($Url) {
            switch ($Type) {
                case 'Register':
                case 'SignIn':
                    // When the other page comes back it needs to go through /sso to force a sso check.
                    $Target = '/sso?target=' . urlencode($Target);
                    break;
                case 'SignOut':
                    $Cookie = c('Garden.Cookie.Name');
                    if (strpos($Url, '?') === false) {
                        $Url .= '?vfcookie=' . urlencode($Cookie);
                    } else {
                        $Url .= '&vfcookie=' . urlencode($Cookie);
                    }
                    // Check to sign out here.
                    $SignedOut = !Gdn::session()->isValid();
                    if (!$SignedOut && (Gdn::session()->validateTransientKey($TransientKey) || $this->Form->isPostBack())) {
                        Gdn::session()->end();
                        $SignedOut = true;
                    }
                    // Sign out is a bit of a tricky thing so we configure the way it works.
                    $SignoutType = c('Garden.SSO.Signout');
                    switch ($SignoutType) {
                        case 'redirect-only':
                            // Just redirect to the url.
                            break;
                        case 'post-only':
                            $this->setData('Method', 'POST');
                            break;
                        case 'post':
                            // Post to the url after signing out here.
                            if (!$SignedOut) {
                                return;
                            }
                            $this->setData('Method', 'POST');
                            break;
                        case 'none':
                            return;
                        case 'redirect':
                        default:
                            if (!$SignedOut) {
                                return;
                            }
                            break;
                    }
                    break;
                default:
                    throw new Exception("Unknown entry type {$Type}.");
            }
            $Url = str_ireplace('{target}', rawurlencode(url($Target, true)), $Url);
            if ($this->deliveryType() == DELIVERY_TYPE_ALL && strcasecmp($this->data('Method'), 'POST') != 0) {
                redirectUrl($Url, 302);
            } else {
                $this->setData('Url', $Url);
                $Script = <<<EOT
<script type="text/javascript">
   window.location = "{$Url}";
</script>
EOT;
                $this->render('Redirect', 'Utility');
                die;
            }
        }
    }
All Usage Examples Of Gdn_AuthenticationProviderModel::getDefault