当前位置: 首页>>代码示例>>PHP>>正文


PHP CFilterChain::add方法代码示例

本文整理汇总了PHP中CFilterChain::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CFilterChain::add方法的具体用法?PHP CFilterChain::add怎么用?PHP CFilterChain::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFilterChain的用法示例。


在下文中一共展示了CFilterChain::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * CFilterChain factory method.
  * This method creates a CFilterChain instance.
  * @param CController the controller who executes the action.
  * @param CAction the action being filtered by this chain.
  * @param array list of filters to be applied to the action.
  */
 public static function create($controller, $action, $filters)
 {
     $chain = new CFilterChain($controller, $action);
     $actionID = $action->getId();
     foreach ($filters as $filter) {
         if (is_string($filter)) {
             if (($pos = strpos($filter, '+')) !== false || ($pos = strpos($filter, '-')) !== false) {
                 $matched = preg_match("/\\b{$actionID}\\b/i", substr($filter, $pos + 1)) > 0;
                 if (($filter[$pos] === '+') === $matched) {
                     $chain->add(CInlineFilter::create($controller, trim(substr($filter, 0, $pos))));
                 }
             } else {
                 $chain->add(CInlineFilter::create($controller, $filter));
             }
         } else {
             if (is_array($filter)) {
                 if (!isset($filter[0])) {
                     throw new CException(Yii::t('yii', 'The first element in a filter configuration must be the filter class.'));
                 }
                 $filterClass = $filter[0];
                 unset($filter[0]);
                 if (($pos = strpos($filterClass, '+')) !== false || ($pos = strpos($filterClass, '-')) !== false) {
                     $matched = preg_match("/\\b{$actionID}\\b/i", substr($filterClass, $pos + 1)) > 0;
                     if (($filterClass[$pos] === '+') === $matched) {
                         $filterClass = trim(substr($filterClass, 0, $pos));
                     } else {
                         continue;
                     }
                 }
                 $filter['class'] = $filterClass;
                 $chain->add(Yii::createComponent($filter));
             } else {
                 $chain->add($filter);
             }
         }
     }
     return $chain;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:45,代码来源:CFilterChain.php

示例2: create

 public static function create($controller, $action, $filters)
 {
     $chain = new CFilterChain($controller, $action);
     $actionID = $action->getId();
     foreach ($filters as $filter) {
         if (is_string($filter)) {
             if (($pos = strpos($filter, '+')) !== false || ($pos = strpos($filter, '-')) !== false) {
                 $matched = preg_match("/\\b{$actionID}\\b/i", substr($filter, $pos + 1)) > 0;
                 if (($filter[$pos] === '+') === $matched) {
                     $filter = CInlineFilter::create($controller, trim(substr($filter, 0, $pos)));
                 }
             } else {
                 $filter = CInlineFilter::create($controller, $filter);
             }
         } elseif (is_array($filter)) {
             $filterClass = $filter[0];
             unset($filter[0]);
             //开始解析过滤器配置
             if (($pos = strpos($filterClass, '+')) !== false || ($pos = strpos($filterClass, '-')) !== false) {
                 preg_match("/\\b{$actionID}\\b/i", substr($filterClass, $pos + 1), $a);
                 $matched = preg_match("/\\b{$actionID}\\b/i", substr($filterClass, $pos + 1)) > 0;
                 //如果是filterName+action,创建一个过滤器,否则忽略
                 if (($filterClass[$pos] === '+') === $matched) {
                     //解析出过滤器的类名
                     $filterClass = trim(substr($filterClass, 0, $pos));
                 } else {
                     continue;
                 }
             }
             $filter['class'] = $filterClass;
             $filter = Yii::createComponent($filter);
         }
         if (is_object($filter)) {
             $filter->init();
             $chain->add($filter);
             //list添加过滤器
         }
     }
     return $chain;
 }
开发者ID:RandomCivil,项目名称:tiny-yii,代码行数:40,代码来源:CFilterChain.php

示例3: create

	public static function create($controller,$action,$filters)
	{
		$chain=new CFilterChain($controller,$action);
		$actionID=$action->getId();
		foreach($filters as $filter)
		{
			if(is_string($filter))  // filterName [+|- action1 action2]
			{
				if(($pos=strpos($filter,'+'))!==false || ($pos=strpos($filter,'-'))!==false)
				{
					$matched=preg_match("/\b{$actionID}\b/i",substr($filter,$pos+1))>0;
					if(($filter[$pos]==='+')===$matched)
						$filter=CInlineFilter::create($controller,trim(substr($filter,0,$pos)));
				}
				else
					$filter=CInlineFilter::create($controller,$filter);
			}
			else if(is_array($filter))  // array('path.to.class [+|- action1, action2]','param1'=>'value1',...)
			{
				if(!isset($filter[0]))
					throw new CException(Yii::t('yii','The first element in a filter configuration must be the filter class.'));
				$filterClass=$filter[0];
				unset($filter[0]);
				if(($pos=strpos($filterClass,'+'))!==false || ($pos=strpos($filterClass,'-'))!==false)
				{
					$matched=preg_match("/\b{$actionID}\b/i",substr($filterClass,$pos+1))>0;
					if(($filterClass[$pos]==='+')===$matched)
						$filterClass=trim(substr($filterClass,0,$pos));
					else
						continue;
				}
				$filter['class']=$filterClass;
				$filter=Yii::createComponent($filter);
			}
			if(is_object($filter))
			{
				$filter->init();
				$chain->add($filter);
			}
		}
		return $chain;
	}
开发者ID:rhl4ttr,项目名称:hello-world,代码行数:42,代码来源:yiilite.php


注:本文中的CFilterChain::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。