3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Db\TableGateway\Feature
;
12 use Zend\Db\TableGateway\AbstractTableGateway
;
16 const APPLY_HALT
= 'halt';
18 protected $tableGateway = null;
21 * @var AbstractFeature[]
23 protected $features = array();
28 protected $magicSpecifications = array();
30 public function __construct(array $features = array())
33 $this->addFeatures($features);
37 public function setTableGateway(AbstractTableGateway
$tableGateway)
39 $this->tableGateway
= $tableGateway;
40 foreach ($this->features
as $feature) {
41 $feature->setTableGateway($this->tableGateway
);
46 public function getFeatureByClassName($featureClassName)
49 foreach ($this->features
as $potentialFeature) {
50 if ($potentialFeature instanceof $featureClassName) {
51 $feature = $potentialFeature;
58 public function addFeatures(array $features)
60 foreach ($features as $feature) {
61 $this->addFeature($feature);
66 public function addFeature(AbstractFeature
$feature)
68 $this->features
[] = $feature;
69 $feature->setTableGateway($feature);
73 public function apply($method, $args)
75 foreach ($this->features
as $feature) {
76 if (method_exists($feature, $method)) {
77 $return = call_user_func_array(array($feature, $method), $args);
78 if ($return === self
::APPLY_HALT
) {
86 * @param string $property
89 public function canCallMagicGet($property)
95 * @param string $property
98 public function callMagicGet($property)
105 * @param string $property
108 public function canCallMagicSet($property)
118 public function callMagicSet($property, $value)
125 * @param string $method
128 public function canCallMagicCall($method)
134 * @param string $method
135 * @param array $arguments
138 public function callMagicCall($method, $arguments)