|
Revision 23810, 2.1 kB
(checked in by Kris.Wallsmith, 4 years ago)
|
[1.3] set svn:eol-style property to native and svn:keywords property to Id on all .php files
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
class sfFilterChain |
|---|
| 22 |
{ |
|---|
| 23 |
protected |
|---|
| 24 |
$chain = array(), |
|---|
| 25 |
$index = -1; |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
* Loads filters configuration for a given action instance. |
|---|
| 29 |
* |
|---|
| 30 |
* @param sfComponent $actionInstance A sfComponent instance |
|---|
| 31 |
*/ |
|---|
| 32 |
public function loadConfiguration($actionInstance) |
|---|
| 33 |
{ |
|---|
| 34 |
require(sfContext::getInstance()->getConfigCache()->checkConfig('modules/'.$actionInstance->getModuleName().'/config/filters.yml')); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
* Executes the next filter in this chain. |
|---|
| 39 |
*/ |
|---|
| 40 |
public function execute() |
|---|
| 41 |
{ |
|---|
| 42 |
|
|---|
| 43 |
++$this->index; |
|---|
| 44 |
|
|---|
| 45 |
if ($this->index < count($this->chain)) |
|---|
| 46 |
{ |
|---|
| 47 |
if (sfConfig::get('sf_logging_enabled')) |
|---|
| 48 |
{ |
|---|
| 49 |
sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Executing filter "%s"', get_class($this->chain[$this->index]))))); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
$this->chain[$this->index]->execute($this); |
|---|
| 54 |
} |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
* Returns true if the filter chain contains a filter of a given class. |
|---|
| 59 |
* |
|---|
| 60 |
* @param string $class The class name of the filter |
|---|
| 61 |
* |
|---|
| 62 |
* @return boolean true if the filter exists, false otherwise |
|---|
| 63 |
*/ |
|---|
| 64 |
public function hasFilter($class) |
|---|
| 65 |
{ |
|---|
| 66 |
foreach ($this->chain as $filter) |
|---|
| 67 |
{ |
|---|
| 68 |
if ($filter instanceof $class) |
|---|
| 69 |
{ |
|---|
| 70 |
return true; |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
return false; |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
* Registers a filter with this chain. |
|---|
| 79 |
* |
|---|
| 80 |
* @param sfFilter $filter A sfFilter implementation instance. |
|---|
| 81 |
*/ |
|---|
| 82 |
public function register($filter) |
|---|
| 83 |
{ |
|---|
| 84 |
$this->chain[] = $filter; |
|---|
| 85 |
} |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|