本文整理汇总了PHP中CAccessControlFilter::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP CAccessControlFilter::filter方法的具体用法?PHP CAccessControlFilter::filter怎么用?PHP CAccessControlFilter::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAccessControlFilter
的用法示例。
在下文中一共展示了CAccessControlFilter::filter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterAccessControl
/**
* Denies access if the module is successfully installed.
* @param CFilterChain $filterChain
* @throws CHttpException
*/
public function filterAccessControl($filterChain)
{
$accesscontrol = YiiPlug::app()->hasAccessControlModulesInstalled();
$user = YiiPlug::app()->hasUserModulesInstalled();
if (!$accesscontrol || !$user) {
// no access control module available
$filter = new CAccessControlFilter();
$rules = $this->accessRules();
$frules = array();
foreach ($rules as $key => $values) {
$frule = array();
foreach ($values as $vkey => $value) {
if (!$accesscontrol && $vkey !== 'roles') {
// do not have accesscontrol module
// skip role based access control (but keep other checks)
$frule[$vkey] = $value;
}
}
if ($user && $frule[0] === 'allow') {
// has user authentication module
// add authenticated user required for each action
if (isset($frule['users'])) {
$frule['users'][] = '@';
} else {
$frule['users'] = array('@');
}
}
$frules[$key] = $frule;
}
$filter->setRules($frules);
return $filter->filter($filterChain);
}
// we are in normal state, just do classic access control
return parent::filterAccessControl($filterChain);
}
示例2: filterAccessControl
public function filterAccessControl($filterChain)
{
$filter = new CAccessControlFilter();
$rules = $this->accesRulesByAction($filterChain->action);
$filter->setRules($rules);
$filter->filter($filterChain);
}
示例3: filterAccessControl
/**
* Filter Access Control.
*
* This replicates the access control module in the base controller and lets us
* do our own special rules that insure we fail closed.
*
* @param CFilterChain $filterChain Yii passed object.
*
* @return void
*/
public function filterAccessControl($filterChain)
{
$rules = $this->accessRules();
// default deny
$rules[] = array('deny');
$filter = new CAccessControlFilter();
$filter->setRules($rules);
$filter->filter($filterChain);
}
示例4: filterAccessControl
public function filterAccessControl($filterChain)
{
$rules = $this->accessRules();
// Fallback to denying everyone
$rules[] = array('deny');
$filter = new CAccessControlFilter();
$filter->setRules($rules);
$filter->filter($filterChain);
}
示例5: filterAccessControl
public function filterAccessControl($filterChain)
{
$filter = new CAccessControlFilter();
$filter->setRules($this->accessRules());
$filter->filter($filterChain);
}