|
Revision 7791, 1.7 kB
(checked in by fabien, 5 years ago)
|
updated Sean Kerr email address
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id Rev Date
|
| 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 |
* Executes the next filter in this chain. |
|---|
| 29 |
*/ |
|---|
| 30 |
public function execute() |
|---|
| 31 |
{ |
|---|
| 32 |
|
|---|
| 33 |
++$this->index; |
|---|
| 34 |
|
|---|
| 35 |
if ($this->index < count($this->chain)) |
|---|
| 36 |
{ |
|---|
| 37 |
if (sfConfig::get('sf_logging_enabled')) |
|---|
| 38 |
{ |
|---|
| 39 |
sfContext::getInstance()->getLogger()->info(sprintf('{sfFilter} executing filter "%s"', get_class($this->chain[$this->index]))); |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
$this->chain[$this->index]->execute($this); |
|---|
| 44 |
} |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
* Returns true if the filter chain contains a filter of a given class. |
|---|
| 49 |
* |
|---|
| 50 |
* @param string The class name of the filter |
|---|
| 51 |
* |
|---|
| 52 |
* @return boolean true if the filter exists, false otherwise |
|---|
| 53 |
*/ |
|---|
| 54 |
public function hasFilter($class) |
|---|
| 55 |
{ |
|---|
| 56 |
foreach ($this->chain as $filter) |
|---|
| 57 |
{ |
|---|
| 58 |
if ($filter instanceof $class) |
|---|
| 59 |
{ |
|---|
| 60 |
return true; |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
return false; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
* Registers a filter with this chain. |
|---|
| 69 |
* |
|---|
| 70 |
* @param sfFilter A sfFilter implementation instance. |
|---|
| 71 |
*/ |
|---|
| 72 |
public function register($filter) |
|---|
| 73 |
{ |
|---|
| 74 |
$this->chain[] = $filter; |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|