extension_collection_class.php
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Tiny - A PHP Framework For Web Artisans
* @author Tiny <tinylofty@gmail.com>
* @copyright Copyright(c) 2010-2014 http://www.tinyrise.com All rights reserved
* @version 1.0
*/
/**
* 扩展集
*
* @author Tiny
* @class ExtensionCollection
*/
class ExtensionCollection
{
private $extensions = array();
/**
* 添加扩展
*
* @access public
* @param Extension $extension
* @return mixed
*/
public function addExtension(Extension $extension)
{
$this->extensions[] = $extension;
}
/**
* 调用每一个扩展的brfore方法
*
* @access public
* @param mixed $obj
* @return void
*/
public function before($obj=null)
{
foreach($this->extensions as $extension)
{
$extension->before($obj);
}
}
/**
* 调用每一个扩展的after方法
*
* @access public
* @param mixed $obj
* @return void
*/
public function after($obj=null)
{
$extensions = array_reverse($this->extensions);
foreach($extensions as $extension)
{
$extension->after($obj);
}
}
}