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: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189:
<?php
namespace Nethgui\Controller\Table;
class PluggableAction extends \Nethgui\Controller\Table\AbstractAction implements \Nethgui\Module\ModuleCompositeInterface, \Nethgui\Component\DependencyInjectorAggregate
{
private $plugins;
private $innerAction;
private $pluginsPath;
private $dependencyInjector;
public function __construct(\Nethgui\Controller\Table\AbstractAction $action, $pluginsPath = NULL)
{
if (is_null($pluginsPath)) {
$id = \Nethgui\array_end(explode('\\', get_class($action)));
} else {
$id = \Nethgui\array_end(explode('/', $pluginsPath));
}
parent::__construct();
$this->innerAction = $action;
$this->plugins = new \Nethgui\Controller\Table\PluginCollector($id);
$this->plugins->setParent($action);
$this->pluginsPath = $pluginsPath;
}
public function hasAdapter()
{
return $this->innerAction->hasAdapter();
}
public function getAdapter()
{
return $this->innerAction->getAdapter();
}
public function setAdapter(\Nethgui\Adapter\AdapterInterface $adapter)
{
$this->innerAction->setAdapter($adapter);
return $this;
}
public function getIdentifier()
{
return $this->innerAction->getIdentifier();
}
public function getAttributesProvider()
{
return $this->innerAction->getAttributesProvider();
}
protected function initializeAttributes(\Nethgui\Module\ModuleAttributesInterface $base)
{
return \Nethgui\Module\CompositeModuleAttributesProvider::extendModuleAttributes($base)->extendFromComposite($this);
}
public function addChild(\Nethgui\Module\ModuleInterface $module)
{
$this->plugins->addChild($module);
return $this;
}
public function getChildren()
{
return $this->plugins->getChildren();
}
public function setPlatform(\Nethgui\System\PlatformInterface $platform)
{
parent::setPlatform($platform);
$this->plugins->setPlatform($this->getPlatform());
$this->innerAction->setPlatform($this->getPlatform());
return $this;
}
public function initialize()
{
$this->innerAction->setParent($this->getParent());
parent::initialize();
$this->innerAction->initialize();
$this->plugins->initialize();
$this->plugins->loadChildrenDirectory($this->innerAction, $this->pluginsPath);
}
public function bind(\Nethgui\Controller\RequestInterface $request)
{
$this->innerAction->bind($request);
$this->plugins->bind($request->spawnRequest($this->plugins->getIdentifier()));
}
public function validate(\Nethgui\Controller\ValidationReportInterface $report)
{
$this->innerAction->validate($report);
$this->plugins->validate($report);
}
public function process()
{
$this->plugins->process();
$this->innerAction->process();
}
public function prepareView(\Nethgui\View\ViewInterface $view)
{
$this->innerAction->prepareView($view);
$this->plugins->prepareView($view->spawnView($this->plugins, TRUE));
}
public function nextPath()
{
return $this->innerAction->nextPath();
}
public function asAuthorizationString()
{
return $this->innerAction->asAuthorizationString();
}
public function getAuthorizationAttribute($attributeName)
{
return $this->innerAction->getAuthorizationAttribute($attributeName);
}
public function setDependencyInjector($di)
{
$this->dependencyInjector = $di;
$this->plugins->setDependencyInjector($di);
return $this;
}
}