@@ -6,26 +6,26 @@ |
||
| 6 | 6 | |
| 7 | 7 | trait HelperTrait |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * @var ComponentHelper |
| 11 | 11 | */ |
| 12 | - private $xHelper; |
|
| 12 | +private $xHelper; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * @param ComponentHelper $xHelper |
| 16 | 16 | * |
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | - private function setHelper(ComponentHelper $xHelper): void |
|
| 20 | - { |
|
| 21 | - $this->xHelper = $xHelper; |
|
| 22 | - } |
|
| 19 | +private function setHelper(ComponentHelper $xHelper): void |
|
| 20 | +{ |
|
| 21 | +$this->xHelper = $xHelper; |
|
| 22 | +} |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @return ComponentHelper |
| 26 | 26 | */ |
| 27 | - protected function helper(): ComponentHelper |
|
| 28 | - { |
|
| 29 | - return $this->xHelper; |
|
| 30 | - } |
|
| 27 | +protected function helper(): ComponentHelper |
|
| 28 | +{ |
|
| 29 | +return $this->xHelper; |
|
| 30 | +} |
|
| 31 | 31 | } |
@@ -7,49 +7,49 @@ |
||
| 7 | 7 | |
| 8 | 8 | trait NodeResponseTrait |
| 9 | 9 | { |
| 10 | - /** |
|
| 10 | +/** |
|
| 11 | 11 | * @var NodeResponse |
| 12 | 12 | */ |
| 13 | - protected $nodeResponse = null; |
|
| 13 | +protected $nodeResponse = null; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 15 | +/** |
|
| 16 | 16 | * @var string |
| 17 | 17 | */ |
| 18 | - protected $overrides = ''; |
|
| 18 | +protected $overrides = ''; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 20 | +/** |
|
| 21 | 21 | * @param Container $di |
| 22 | 22 | * |
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | - private function setNodeResponse(Container $di): void |
|
| 26 | - { |
|
| 27 | - // Each component must have its own reponse object. |
|
| 28 | - // A component can override another one. In this case, |
|
| 29 | - // its response is attached to the overriden component DOM node. |
|
| 30 | - $this->nodeResponse = $di->newNodeResponse($this->rq($this->overrides ?: '')); |
|
| 31 | - } |
|
| 25 | +private function setNodeResponse(Container $di): void |
|
| 26 | +{ |
|
| 27 | +// Each component must have its own reponse object. |
|
| 28 | +// A component can override another one. In this case, |
|
| 29 | +// its response is attached to the overriden component DOM node. |
|
| 30 | +$this->nodeResponse = $di->newNodeResponse($this->rq($this->overrides ?: '')); |
|
| 31 | +} |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * Get the component response |
| 35 | 35 | * |
| 36 | 36 | * @return NodeResponse |
| 37 | 37 | */ |
| 38 | - final protected function node(): NodeResponse |
|
| 39 | - { |
|
| 40 | - return $this->nodeResponse; |
|
| 41 | - } |
|
| 38 | +final protected function node(): NodeResponse |
|
| 39 | +{ |
|
| 40 | +return $this->nodeResponse; |
|
| 41 | +} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * Set the component item. |
| 45 | 45 | * |
| 46 | 46 | * @param string $item |
| 47 | 47 | * |
| 48 | 48 | * @return self |
| 49 | 49 | */ |
| 50 | - final public function item(string $item): self |
|
| 51 | - { |
|
| 52 | - $this->node()->item($item); |
|
| 53 | - return $this; |
|
| 54 | - } |
|
| 50 | +final public function item(string $item): self |
|
| 51 | +{ |
|
| 52 | +$this->node()->item($item); |
|
| 53 | +return $this; |
|
| 54 | +} |
|
| 55 | 55 | } |
@@ -6,38 +6,38 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Stash |
| 8 | 8 | { |
| 9 | - /** |
|
| 9 | +/** |
|
| 10 | 10 | * @var array |
| 11 | 11 | */ |
| 12 | - private array $values = []; |
|
| 12 | +private array $values = []; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * @param string $key |
| 16 | 16 | * @param mixed $value |
| 17 | 17 | * |
| 18 | 18 | * @return void |
| 19 | 19 | */ |
| 20 | - public function set(string $key, mixed $value): void |
|
| 21 | - { |
|
| 22 | - $this->values[$key] = $value; |
|
| 23 | - } |
|
| 20 | +public function set(string $key, mixed $value): void |
|
| 21 | +{ |
|
| 22 | +$this->values[$key] = $value; |
|
| 23 | +} |
|
| 24 | 24 | |
| 25 | - /** |
|
| 25 | +/** |
|
| 26 | 26 | * @param string $key |
| 27 | 27 | * @param mixed $default |
| 28 | 28 | * |
| 29 | 29 | * @return mixed |
| 30 | 30 | */ |
| 31 | - public function get(string $key, mixed $default = null): mixed |
|
| 32 | - { |
|
| 33 | - $value = $this->values[$key] ?? $default; |
|
| 34 | - if(is_callable($value)) |
|
| 35 | - { |
|
| 36 | - $value = $value(); |
|
| 37 | - // Save the value returned by the callback in the stash. |
|
| 38 | - $this->values[$key] = $value; |
|
| 39 | - } |
|
| 31 | +public function get(string $key, mixed $default = null): mixed |
|
| 32 | +{ |
|
| 33 | +$value = $this->values[$key] ?? $default; |
|
| 34 | +if(is_callable($value)) |
|
| 35 | +{ |
|
| 36 | +$value = $value(); |
|
| 37 | +// Save the value returned by the callback in the stash. |
|
| 38 | +$this->values[$key] = $value; |
|
| 39 | +} |
|
| 40 | 40 | |
| 41 | - return $value; |
|
| 42 | - } |
|
| 41 | +return $value; |
|
| 42 | +} |
|
| 43 | 43 | } |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | |
| 17 | 17 | class AfterData extends HookData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - protected function getType(): string |
|
| 23 | - { |
|
| 24 | - return 'after'; |
|
| 25 | - } |
|
| 22 | +protected function getType(): string |
|
| 23 | +{ |
|
| 24 | +return 'after'; |
|
| 25 | +} |
|
| 26 | 26 | } |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | |
| 17 | 17 | class BeforeData extends HookData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - protected function getType(): string |
|
| 23 | - { |
|
| 24 | - return 'before'; |
|
| 25 | - } |
|
| 22 | +protected function getType(): string |
|
| 23 | +{ |
|
| 24 | +return 'before'; |
|
| 25 | +} |
|
| 26 | 26 | } |
@@ -21,71 +21,71 @@ |
||
| 21 | 21 | |
| 22 | 22 | abstract class HookData extends AbstractData |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $aCalls = []; |
|
| 27 | +protected $aCalls = []; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - abstract protected function getType(): string; |
|
| 32 | +abstract protected function getType(): string; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | - public function getName(): string |
|
| 38 | - { |
|
| 39 | - return '__' . $this->getType(); |
|
| 40 | - } |
|
| 37 | +public function getName(): string |
|
| 38 | +{ |
|
| 39 | +return '__' . $this->getType(); |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - /** |
|
| 42 | +/** |
|
| 43 | 43 | * @return mixed |
| 44 | 44 | */ |
| 45 | - public function getValue(): mixed |
|
| 46 | - { |
|
| 47 | - return $this->aCalls; |
|
| 48 | - } |
|
| 45 | +public function getValue(): mixed |
|
| 46 | +{ |
|
| 47 | +return $this->aCalls; |
|
| 48 | +} |
|
| 49 | 49 | |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * @param string $sMethod |
| 52 | 52 | * |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - protected function validateMethod(string $sMethod): void |
|
| 56 | - { |
|
| 57 | - if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sMethod) > 0) |
|
| 58 | - { |
|
| 59 | - return; |
|
| 60 | - } |
|
| 61 | - $sType = $this->getType(); |
|
| 62 | - throw new SetupException("$sMethod is not a valid \"call\" value for $sType."); |
|
| 63 | - } |
|
| 55 | +protected function validateMethod(string $sMethod): void |
|
| 56 | +{ |
|
| 57 | +if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sMethod) > 0) |
|
| 58 | +{ |
|
| 59 | +return; |
|
| 60 | +} |
|
| 61 | +$sType = $this->getType(); |
|
| 62 | +throw new SetupException("$sMethod is not a valid \"call\" value for $sType."); |
|
| 63 | +} |
|
| 64 | 64 | |
| 65 | - /** |
|
| 65 | +/** |
|
| 66 | 66 | * @param string $sMethod |
| 67 | 67 | * @param array $aParams |
| 68 | 68 | * |
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | - public function addCall(string $sMethod, array $aParams): void |
|
| 72 | - { |
|
| 73 | - $this->validateMethod($sMethod); |
|
| 71 | +public function addCall(string $sMethod, array $aParams): void |
|
| 72 | +{ |
|
| 73 | +$this->validateMethod($sMethod); |
|
| 74 | 74 | |
| 75 | - $this->aCalls[$sMethod] = $aParams; |
|
| 76 | - } |
|
| 75 | +$this->aCalls[$sMethod] = $aParams; |
|
| 76 | +} |
|
| 77 | 77 | |
| 78 | - /** |
|
| 78 | +/** |
|
| 79 | 79 | * @inheritDoc |
| 80 | 80 | */ |
| 81 | - public function encode(string $sVarName): array |
|
| 82 | - { |
|
| 83 | - $aCalls = []; |
|
| 84 | - foreach($this->aCalls as $sMethod => $aParams) |
|
| 85 | - { |
|
| 86 | - $sParams = addslashes(json_encode($aParams)); |
|
| 87 | - $aCalls[] = "{$sVarName}->addCall('$sMethod', json_decode(\"$sParams\", true));"; |
|
| 88 | - } |
|
| 89 | - return $aCalls; |
|
| 90 | - } |
|
| 81 | +public function encode(string $sVarName): array |
|
| 82 | +{ |
|
| 83 | +$aCalls = []; |
|
| 84 | +foreach($this->aCalls as $sMethod => $aParams) |
|
| 85 | +{ |
|
| 86 | +$sParams = addslashes(json_encode($aParams)); |
|
| 87 | +$aCalls[] = "{$sVarName}->addCall('$sMethod', json_decode(\"$sParams\", true));"; |
|
| 88 | +} |
|
| 89 | +return $aCalls; |
|
| 90 | +} |
|
| 91 | 91 | } |
@@ -16,12 +16,12 @@ |
||
| 16 | 16 | |
| 17 | 17 | abstract class AbstractData |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Generate the PHP code to populate a Metadata object |
| 21 | 21 | * |
| 22 | 22 | * @param string $sVarName |
| 23 | 23 | * |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | - abstract public function encode(string $sVarName): array; |
|
| 26 | +abstract public function encode(string $sVarName): array; |
|
| 27 | 27 | } |
@@ -45,49 +45,49 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | class PluginManager |
| 47 | 47 | { |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * Request plugins, indexed by name |
| 50 | 50 | * |
| 51 | 51 | * @var array<string> |
| 52 | 52 | */ |
| 53 | - private $aRegistryPlugins = []; |
|
| 53 | +private $aRegistryPlugins = []; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * Request handlers, indexed by name |
| 57 | 57 | * |
| 58 | 58 | * @var array<string> |
| 59 | 59 | */ |
| 60 | - private $aRequestHandlers = []; |
|
| 60 | +private $aRequestHandlers = []; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 62 | +/** |
|
| 63 | 63 | * Response plugins, indexed by name |
| 64 | 64 | * |
| 65 | 65 | * @var array<string> |
| 66 | 66 | */ |
| 67 | - private $aResponsePlugins = []; |
|
| 67 | +private $aResponsePlugins = []; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * The constructor |
| 71 | 71 | * |
| 72 | 72 | * @param Container $di |
| 73 | 73 | * @param CodeGenerator $xCodeGenerator |
| 74 | 74 | * @param Translator $xTranslator |
| 75 | 75 | */ |
| 76 | - public function __construct(private Container $di, |
|
| 77 | - private CodeGenerator $xCodeGenerator, private Translator $xTranslator) |
|
| 78 | - {} |
|
| 76 | +public function __construct(private Container $di, |
|
| 77 | +private CodeGenerator $xCodeGenerator, private Translator $xTranslator) |
|
| 78 | +{} |
|
| 79 | 79 | |
| 80 | - /** |
|
| 80 | +/** |
|
| 81 | 81 | * Get the request plugins |
| 82 | 82 | * |
| 83 | 83 | * @return array<class-string> |
| 84 | 84 | */ |
| 85 | - public function getRequestHandlers(): array |
|
| 86 | - { |
|
| 87 | - return $this->aRequestHandlers; |
|
| 88 | - } |
|
| 85 | +public function getRequestHandlers(): array |
|
| 86 | +{ |
|
| 87 | +return $this->aRequestHandlers; |
|
| 88 | +} |
|
| 89 | 89 | |
| 90 | - /** |
|
| 90 | +/** |
|
| 91 | 91 | * Register a plugin |
| 92 | 92 | * |
| 93 | 93 | * @param class-string $sClassName The plugin class |
@@ -97,40 +97,40 @@ discard block |
||
| 97 | 97 | * @return int |
| 98 | 98 | * @throws SetupException |
| 99 | 99 | */ |
| 100 | - private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int |
|
| 101 | - { |
|
| 102 | - // Any plugin must implement the PluginInterface interface. |
|
| 103 | - if(!in_array(PluginInterface::class, $aInterfaces)) |
|
| 104 | - { |
|
| 105 | - $sMessage = $this->xTranslator->trans('errors.register.invalid', [ |
|
| 106 | - 'name' => $sClassName, |
|
| 107 | - ]); |
|
| 108 | - throw new SetupException($sMessage); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // Response plugin. |
|
| 112 | - if(in_array(ResponsePluginInterface::class, $aInterfaces)) |
|
| 113 | - { |
|
| 114 | - $this->aResponsePlugins[$sPluginName] = $sClassName; |
|
| 115 | - return 1; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // Request plugin. |
|
| 119 | - $nCount = 0; |
|
| 120 | - if(in_array(CallableRegistryInterface::class, $aInterfaces)) |
|
| 121 | - { |
|
| 122 | - $this->aRegistryPlugins[$sPluginName] = $sClassName; |
|
| 123 | - $nCount++; |
|
| 124 | - } |
|
| 125 | - if(in_array(RequestHandlerInterface::class, $aInterfaces)) |
|
| 126 | - { |
|
| 127 | - $this->aRequestHandlers[$sPluginName] = $sClassName; |
|
| 128 | - $nCount++; |
|
| 129 | - } |
|
| 130 | - return $nCount; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 100 | +private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int |
|
| 101 | +{ |
|
| 102 | +// Any plugin must implement the PluginInterface interface. |
|
| 103 | +if(!in_array(PluginInterface::class, $aInterfaces)) |
|
| 104 | +{ |
|
| 105 | +$sMessage = $this->xTranslator->trans('errors.register.invalid', [ |
|
| 106 | + 'name' => $sClassName, |
|
| 107 | +]); |
|
| 108 | +throw new SetupException($sMessage); |
|
| 109 | +} |
|
| 110 | + |
|
| 111 | +// Response plugin. |
|
| 112 | +if(in_array(ResponsePluginInterface::class, $aInterfaces)) |
|
| 113 | +{ |
|
| 114 | +$this->aResponsePlugins[$sPluginName] = $sClassName; |
|
| 115 | +return 1; |
|
| 116 | +} |
|
| 117 | + |
|
| 118 | +// Request plugin. |
|
| 119 | +$nCount = 0; |
|
| 120 | +if(in_array(CallableRegistryInterface::class, $aInterfaces)) |
|
| 121 | +{ |
|
| 122 | +$this->aRegistryPlugins[$sPluginName] = $sClassName; |
|
| 123 | +$nCount++; |
|
| 124 | +} |
|
| 125 | +if(in_array(RequestHandlerInterface::class, $aInterfaces)) |
|
| 126 | +{ |
|
| 127 | +$this->aRequestHandlers[$sPluginName] = $sClassName; |
|
| 128 | +$nCount++; |
|
| 129 | +} |
|
| 130 | +return $nCount; |
|
| 131 | +} |
|
| 132 | + |
|
| 133 | +/** |
|
| 134 | 134 | * Register a plugin |
| 135 | 135 | * |
| 136 | 136 | * Below is a table for priorities and their description: |
@@ -145,34 +145,34 @@ discard block |
||
| 145 | 145 | * @return void |
| 146 | 146 | * @throws SetupException |
| 147 | 147 | */ |
| 148 | - public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000): void |
|
| 149 | - { |
|
| 150 | - $aInterfaces = class_implements($sClassName); |
|
| 151 | - $nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces); |
|
| 152 | - |
|
| 153 | - // Any plugin can implement the CodeGeneratorInterface interface. |
|
| 154 | - if(in_array(CodeGeneratorInterface::class, $aInterfaces)) |
|
| 155 | - { |
|
| 156 | - $this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority); |
|
| 157 | - $nCount++; |
|
| 158 | - } |
|
| 159 | - // The class is not a valid plugin. |
|
| 160 | - if($nCount === 0) |
|
| 161 | - { |
|
| 162 | - $sMessage = $this->xTranslator->trans('errors.register.invalid', [ |
|
| 163 | - 'name' => $sClassName, |
|
| 164 | - ]); |
|
| 165 | - throw new SetupException($sMessage); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // Register the plugin in the DI container, if necessary |
|
| 169 | - if(!$this->di->has($sClassName)) |
|
| 170 | - { |
|
| 171 | - $this->di->auto($sClassName); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 148 | +public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000): void |
|
| 149 | +{ |
|
| 150 | +$aInterfaces = class_implements($sClassName); |
|
| 151 | +$nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces); |
|
| 152 | + |
|
| 153 | +// Any plugin can implement the CodeGeneratorInterface interface. |
|
| 154 | +if(in_array(CodeGeneratorInterface::class, $aInterfaces)) |
|
| 155 | +{ |
|
| 156 | +$this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority); |
|
| 157 | +$nCount++; |
|
| 158 | +} |
|
| 159 | +// The class is not a valid plugin. |
|
| 160 | +if($nCount === 0) |
|
| 161 | +{ |
|
| 162 | +$sMessage = $this->xTranslator->trans('errors.register.invalid', [ |
|
| 163 | + 'name' => $sClassName, |
|
| 164 | +]); |
|
| 165 | +throw new SetupException($sMessage); |
|
| 166 | +} |
|
| 167 | + |
|
| 168 | +// Register the plugin in the DI container, if necessary |
|
| 169 | +if(!$this->di->has($sClassName)) |
|
| 170 | +{ |
|
| 171 | +$this->di->auto($sClassName); |
|
| 172 | +} |
|
| 173 | +} |
|
| 174 | + |
|
| 175 | +/** |
|
| 176 | 176 | * Find the specified response plugin by name or class name |
| 177 | 177 | * |
| 178 | 178 | * @template R of ResponsePluginInterface |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return ($sName is class-string ? R : ResponsePluginInterface)|null |
| 182 | 182 | */ |
| 183 | - public function getResponsePlugin(string $sName): ?ResponsePluginInterface |
|
| 184 | - { |
|
| 185 | - return $this->di->h($sName) ? $this->di->g($sName) : |
|
| 186 | - (!isset($this->aResponsePlugins[$sName]) ? null : |
|
| 187 | - $this->di->g($this->aResponsePlugins[$sName])); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 183 | +public function getResponsePlugin(string $sName): ?ResponsePluginInterface |
|
| 184 | +{ |
|
| 185 | +return $this->di->h($sName) ? $this->di->g($sName) : |
|
| 186 | +(!isset($this->aResponsePlugins[$sName]) ? null : |
|
| 187 | +$this->di->g($this->aResponsePlugins[$sName])); |
|
| 188 | +} |
|
| 189 | + |
|
| 190 | +/** |
|
| 191 | 191 | * Register a callable function or class |
| 192 | 192 | * |
| 193 | 193 | * Call the request plugin with the $sType defined as name. |
@@ -199,46 +199,46 @@ discard block |
||
| 199 | 199 | * @return void |
| 200 | 200 | * @throws SetupException |
| 201 | 201 | */ |
| 202 | - public function registerCallable(string $sType, string $sCallable, $xOptions = []): void |
|
| 203 | - { |
|
| 204 | - if(isset($this->aRegistryPlugins[$sType]) && |
|
| 205 | - ($xPlugin = $this->di->g($this->aRegistryPlugins[$sType]))) |
|
| 206 | - { |
|
| 207 | - $xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions)); |
|
| 208 | - return; |
|
| 209 | - } |
|
| 210 | - throw new SetupException($this->xTranslator->trans('errors.register.plugin', |
|
| 211 | - ['name' => $sType, 'callable' => $sCallable])); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 202 | +public function registerCallable(string $sType, string $sCallable, $xOptions = []): void |
|
| 203 | +{ |
|
| 204 | +if(isset($this->aRegistryPlugins[$sType]) && |
|
| 205 | +($xPlugin = $this->di->g($this->aRegistryPlugins[$sType]))) |
|
| 206 | +{ |
|
| 207 | +$xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions)); |
|
| 208 | +return; |
|
| 209 | +} |
|
| 210 | +throw new SetupException($this->xTranslator->trans('errors.register.plugin', |
|
| 211 | +['name' => $sType, 'callable' => $sCallable])); |
|
| 212 | +} |
|
| 213 | + |
|
| 214 | +/** |
|
| 215 | 215 | * Register the Jaxon request plugins |
| 216 | 216 | * |
| 217 | 217 | * @return void |
| 218 | 218 | * @throws SetupException |
| 219 | 219 | */ |
| 220 | - public function registerPlugins(): void |
|
| 221 | - { |
|
| 222 | - // Request plugins |
|
| 223 | - $this->registerPlugin(CallableClassPlugin::class, Jaxon::CALLABLE_CLASS, 101); |
|
| 224 | - $this->registerPlugin(CallableFunctionPlugin::class, Jaxon::CALLABLE_FUNCTION, 102); |
|
| 225 | - $this->registerPlugin(CallableDirPlugin::class, Jaxon::CALLABLE_DIR, 103); |
|
| 226 | - |
|
| 227 | - // Response plugins |
|
| 228 | - $this->registerPlugin(ScriptPlugin::class, ScriptPlugin::NAME, 700); |
|
| 229 | - $this->registerPlugin(DataBagPlugin::class, DataBagPlugin::NAME, 700); |
|
| 230 | - $this->registerPlugin(DialogPlugin::class, DialogPlugin::NAME, 750); |
|
| 231 | - $this->registerPlugin(PaginatorPlugin::class, PaginatorPlugin::NAME, 800); |
|
| 232 | - $this->registerPlugin(PsrPlugin::class, PsrPlugin::NAME, 850); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 220 | +public function registerPlugins(): void |
|
| 221 | +{ |
|
| 222 | +// Request plugins |
|
| 223 | +$this->registerPlugin(CallableClassPlugin::class, Jaxon::CALLABLE_CLASS, 101); |
|
| 224 | +$this->registerPlugin(CallableFunctionPlugin::class, Jaxon::CALLABLE_FUNCTION, 102); |
|
| 225 | +$this->registerPlugin(CallableDirPlugin::class, Jaxon::CALLABLE_DIR, 103); |
|
| 226 | + |
|
| 227 | +// Response plugins |
|
| 228 | +$this->registerPlugin(ScriptPlugin::class, ScriptPlugin::NAME, 700); |
|
| 229 | +$this->registerPlugin(DataBagPlugin::class, DataBagPlugin::NAME, 700); |
|
| 230 | +$this->registerPlugin(DialogPlugin::class, DialogPlugin::NAME, 750); |
|
| 231 | +$this->registerPlugin(PaginatorPlugin::class, PaginatorPlugin::NAME, 800); |
|
| 232 | +$this->registerPlugin(PsrPlugin::class, PsrPlugin::NAME, 850); |
|
| 233 | +} |
|
| 234 | + |
|
| 235 | +/** |
|
| 236 | 236 | * Get the parameter reader |
| 237 | 237 | * |
| 238 | 238 | * @return ParameterReader |
| 239 | 239 | */ |
| 240 | - public function getParameterReader(): ParameterReader |
|
| 241 | - { |
|
| 242 | - return $this->di->g(ParameterReader::class); |
|
| 243 | - } |
|
| 240 | +public function getParameterReader(): ParameterReader |
|
| 241 | +{ |
|
| 242 | +return $this->di->g(ParameterReader::class); |
|
| 243 | +} |
|
| 244 | 244 | } |
@@ -30,16 +30,16 @@ |
||
| 30 | 30 | |
| 31 | 31 | abstract class AbstractRequestPlugin extends AbstractPlugin implements CallableRegistryInterface, RequestHandlerInterface |
| 32 | 32 | { |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * @var Target |
| 35 | 35 | */ |
| 36 | - protected $xTarget = null; |
|
| 36 | +protected $xTarget = null; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @inheritDoc |
| 40 | 40 | */ |
| 41 | - public function getTarget(): ?Target |
|
| 42 | - { |
|
| 43 | - return $this->xTarget; |
|
| 44 | - } |
|
| 41 | +public function getTarget(): ?Target |
|
| 42 | +{ |
|
| 43 | +return $this->xTarget; |
|
| 44 | +} |
|
| 45 | 45 | } |