@@ -15,81 +15,81 @@ |
||
| 15 | 15 | |
| 16 | 16 | trait CallableTrait |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * Register the values into the container |
| 20 | 20 | * |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - private function registerCallables(): void |
|
| 24 | - { |
|
| 25 | - // Validator |
|
| 26 | - $this->set(Validator::class, function($di) { |
|
| 27 | - return new Validator($di->g(ConfigManager::class), $di->g(Translator::class)); |
|
| 28 | - }); |
|
| 29 | - // Callable objects registry |
|
| 30 | - $this->set(ComponentRegistry::class, function($di) { |
|
| 31 | - return new ComponentRegistry($di->g(ComponentContainer::class)); |
|
| 32 | - }); |
|
| 33 | - // Callable class plugin |
|
| 34 | - $this->set(CallableClassPlugin::class, function($di) { |
|
| 35 | - $sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.class'); |
|
| 36 | - return new CallableClassPlugin($sPrefix, $di->getLogger(), |
|
| 37 | - $di->g(ComponentContainer::class), $di->g(ComponentRegistry::class), |
|
| 38 | - $di->g(Translator::class), $di->g(TemplateEngine::class), |
|
| 39 | - $di->g(Validator::class)); |
|
| 40 | - }); |
|
| 41 | - // Callable dir plugin |
|
| 42 | - $this->set(CallableDirPlugin::class, function($di) { |
|
| 43 | - return new CallableDirPlugin($di->g(ComponentContainer::class), |
|
| 44 | - $di->g(ComponentRegistry::class), $di->g(Translator::class)); |
|
| 45 | - }); |
|
| 46 | - // Callable function plugin |
|
| 47 | - $this->set(CallableFunctionPlugin::class, function($di) { |
|
| 48 | - $sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.function'); |
|
| 49 | - $bDebug = $di->g(ConfigManager::class)->getOption('core.debug.on', false); |
|
| 50 | - return new CallableFunctionPlugin($sPrefix, $bDebug, |
|
| 51 | - $di->g(Container::class), $di->g(TemplateEngine::class), |
|
| 52 | - $di->g(Translator::class), $di->g(Validator::class)); |
|
| 53 | - }); |
|
| 54 | - } |
|
| 23 | +private function registerCallables(): void |
|
| 24 | +{ |
|
| 25 | +// Validator |
|
| 26 | +$this->set(Validator::class, function($di) { |
|
| 27 | +return new Validator($di->g(ConfigManager::class), $di->g(Translator::class)); |
|
| 28 | +}); |
|
| 29 | +// Callable objects registry |
|
| 30 | +$this->set(ComponentRegistry::class, function($di) { |
|
| 31 | +return new ComponentRegistry($di->g(ComponentContainer::class)); |
|
| 32 | +}); |
|
| 33 | +// Callable class plugin |
|
| 34 | +$this->set(CallableClassPlugin::class, function($di) { |
|
| 35 | +$sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.class'); |
|
| 36 | +return new CallableClassPlugin($sPrefix, $di->getLogger(), |
|
| 37 | + $di->g(ComponentContainer::class), $di->g(ComponentRegistry::class), |
|
| 38 | + $di->g(Translator::class), $di->g(TemplateEngine::class), |
|
| 39 | + $di->g(Validator::class)); |
|
| 40 | +}); |
|
| 41 | +// Callable dir plugin |
|
| 42 | +$this->set(CallableDirPlugin::class, function($di) { |
|
| 43 | +return new CallableDirPlugin($di->g(ComponentContainer::class), |
|
| 44 | + $di->g(ComponentRegistry::class), $di->g(Translator::class)); |
|
| 45 | +}); |
|
| 46 | +// Callable function plugin |
|
| 47 | +$this->set(CallableFunctionPlugin::class, function($di) { |
|
| 48 | +$sPrefix = $di->g(ConfigManager::class)->getOption('core.prefix.function'); |
|
| 49 | +$bDebug = $di->g(ConfigManager::class)->getOption('core.debug.on', false); |
|
| 50 | +return new CallableFunctionPlugin($sPrefix, $bDebug, |
|
| 51 | + $di->g(Container::class), $di->g(TemplateEngine::class), |
|
| 52 | + $di->g(Translator::class), $di->g(Validator::class)); |
|
| 53 | +}); |
|
| 54 | +} |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * Get the callable registry |
| 58 | 58 | * |
| 59 | 59 | * @return ComponentRegistry |
| 60 | 60 | */ |
| 61 | - public function getComponentRegistry(): ComponentRegistry |
|
| 62 | - { |
|
| 63 | - return $this->g(ComponentRegistry::class); |
|
| 64 | - } |
|
| 61 | +public function getComponentRegistry(): ComponentRegistry |
|
| 62 | +{ |
|
| 63 | +return $this->g(ComponentRegistry::class); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Get the callable function plugin |
| 68 | 68 | * |
| 69 | 69 | * @return CallableFunctionPlugin |
| 70 | 70 | */ |
| 71 | - public function getCallableFunctionPlugin(): CallableFunctionPlugin |
|
| 72 | - { |
|
| 73 | - return $this->g(CallableFunctionPlugin::class); |
|
| 74 | - } |
|
| 71 | +public function getCallableFunctionPlugin(): CallableFunctionPlugin |
|
| 72 | +{ |
|
| 73 | +return $this->g(CallableFunctionPlugin::class); |
|
| 74 | +} |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | +/** |
|
| 77 | 77 | * Get the callable class plugin |
| 78 | 78 | * |
| 79 | 79 | * @return CallableClassPlugin |
| 80 | 80 | */ |
| 81 | - public function getCallableClassPlugin(): CallableClassPlugin |
|
| 82 | - { |
|
| 83 | - return $this->g(CallableClassPlugin::class); |
|
| 84 | - } |
|
| 81 | +public function getCallableClassPlugin(): CallableClassPlugin |
|
| 82 | +{ |
|
| 83 | +return $this->g(CallableClassPlugin::class); |
|
| 84 | +} |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * Get the callable dir plugin |
| 88 | 88 | * |
| 89 | 89 | * @return CallableDirPlugin |
| 90 | 90 | */ |
| 91 | - public function getCallableDirPlugin(): CallableDirPlugin |
|
| 92 | - { |
|
| 93 | - return $this->g(CallableDirPlugin::class); |
|
| 94 | - } |
|
| 91 | +public function getCallableDirPlugin(): CallableDirPlugin |
|
| 92 | +{ |
|
| 93 | +return $this->g(CallableDirPlugin::class); |
|
| 94 | +} |
|
| 95 | 95 | } |
@@ -16,104 +16,104 @@ |
||
| 16 | 16 | |
| 17 | 17 | trait AppTrait |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - private $sJsLibVersion = 'jaxon_javascript_library_version'; |
|
| 22 | +private $sJsLibVersion = 'jaxon_javascript_library_version'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * Register the values into the container |
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | - private function registerApp(): void |
|
| 30 | - { |
|
| 31 | - // Config Manager |
|
| 32 | - $this->set(ConfigEventManager::class, function($di) { |
|
| 33 | - return new ConfigEventManager($di->g(Container::class)); |
|
| 34 | - }); |
|
| 35 | - $this->set(ConfigManager::class, function($di) { |
|
| 36 | - $aDefaultOptions = require(__DIR__ . '/../../../config/lib.php'); |
|
| 37 | - return new ConfigManager($aDefaultOptions, $di->g(Translator::class), |
|
| 38 | - $di->g(ConfigReader::class), $di->g(ConfigSetter::class), |
|
| 39 | - $di->g(ConfigEventManager::class)); |
|
| 40 | - }); |
|
| 29 | +private function registerApp(): void |
|
| 30 | +{ |
|
| 31 | +// Config Manager |
|
| 32 | +$this->set(ConfigEventManager::class, function($di) { |
|
| 33 | +return new ConfigEventManager($di->g(Container::class)); |
|
| 34 | +}); |
|
| 35 | +$this->set(ConfigManager::class, function($di) { |
|
| 36 | +$aDefaultOptions = require(__DIR__ . '/../../../config/lib.php'); |
|
| 37 | +return new ConfigManager($aDefaultOptions, $di->g(Translator::class), |
|
| 38 | + $di->g(ConfigReader::class), $di->g(ConfigSetter::class), |
|
| 39 | + $di->g(ConfigEventManager::class)); |
|
| 40 | +}); |
|
| 41 | 41 | |
| 42 | - // Jaxon App |
|
| 43 | - $this->set(AppInterface::class, fn() => new App()); |
|
| 44 | - // Jaxon App bootstrap |
|
| 45 | - $this->set(Bootstrap::class, function($di) { |
|
| 46 | - return new Bootstrap($di->g(ConfigManager::class), |
|
| 47 | - $di->g(PackageManager::class), $di->g(CallbackManager::class)); |
|
| 48 | - }); |
|
| 49 | - // The javascript library version |
|
| 50 | - $this->set($this->sJsLibVersion, function($di) { |
|
| 51 | - $xRequest = $di->getRequest(); |
|
| 52 | - $aParams = $xRequest->getMethod() === 'POST' ? |
|
| 53 | - $xRequest->getParsedBody() : $xRequest->getQueryParams(); |
|
| 54 | - return $aParams['jxnv'] ?? '3.3.0'; |
|
| 55 | - }); |
|
| 56 | - } |
|
| 42 | +// Jaxon App |
|
| 43 | +$this->set(AppInterface::class, fn() => new App()); |
|
| 44 | +// Jaxon App bootstrap |
|
| 45 | +$this->set(Bootstrap::class, function($di) { |
|
| 46 | +return new Bootstrap($di->g(ConfigManager::class), |
|
| 47 | + $di->g(PackageManager::class), $di->g(CallbackManager::class)); |
|
| 48 | +}); |
|
| 49 | +// The javascript library version |
|
| 50 | +$this->set($this->sJsLibVersion, function($di) { |
|
| 51 | +$xRequest = $di->getRequest(); |
|
| 52 | +$aParams = $xRequest->getMethod() === 'POST' ? |
|
| 53 | + $xRequest->getParsedBody() : $xRequest->getQueryParams(); |
|
| 54 | +return $aParams['jxnv'] ?? '3.3.0'; |
|
| 55 | +}); |
|
| 56 | +} |
|
| 57 | 57 | |
| 58 | - /** |
|
| 58 | +/** |
|
| 59 | 59 | * Register the event handlers |
| 60 | 60 | * |
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | - private function setEventHandlers(): void |
|
| 64 | - { |
|
| 65 | - $xEventManager = $this->g(ConfigEventManager::class); |
|
| 66 | - $xEventManager->addLibConfigListener(Translator::class); |
|
| 67 | - } |
|
| 63 | +private function setEventHandlers(): void |
|
| 64 | +{ |
|
| 65 | +$xEventManager = $this->g(ConfigEventManager::class); |
|
| 66 | +$xEventManager->addLibConfigListener(Translator::class); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Get the App instance |
| 71 | 71 | * |
| 72 | 72 | * @return AppInterface |
| 73 | 73 | */ |
| 74 | - public function getApp(): AppInterface |
|
| 75 | - { |
|
| 76 | - return $this->g(AppInterface::class); |
|
| 77 | - } |
|
| 74 | +public function getApp(): AppInterface |
|
| 75 | +{ |
|
| 76 | +return $this->g(AppInterface::class); |
|
| 77 | +} |
|
| 78 | 78 | |
| 79 | - /** |
|
| 79 | +/** |
|
| 80 | 80 | * Get the App bootstrap |
| 81 | 81 | * |
| 82 | 82 | * @return Bootstrap |
| 83 | 83 | */ |
| 84 | - public function getBootstrap(): Bootstrap |
|
| 85 | - { |
|
| 86 | - return $this->g(Bootstrap::class); |
|
| 87 | - } |
|
| 84 | +public function getBootstrap(): Bootstrap |
|
| 85 | +{ |
|
| 86 | +return $this->g(Bootstrap::class); |
|
| 87 | +} |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | +/** |
|
| 90 | 90 | * Get the config manager |
| 91 | 91 | * |
| 92 | 92 | * @return ConfigManager |
| 93 | 93 | */ |
| 94 | - public function config(): ConfigManager |
|
| 95 | - { |
|
| 96 | - return $this->g(ConfigManager::class); |
|
| 97 | - } |
|
| 94 | +public function config(): ConfigManager |
|
| 95 | +{ |
|
| 96 | +return $this->g(ConfigManager::class); |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * Get the javascript library version |
| 101 | 101 | * |
| 102 | 102 | * @return string |
| 103 | 103 | */ |
| 104 | - public function getJsLibVersion(): string |
|
| 105 | - { |
|
| 106 | - return $this->g($this->sJsLibVersion); |
|
| 107 | - } |
|
| 104 | +public function getJsLibVersion(): string |
|
| 105 | +{ |
|
| 106 | +return $this->g($this->sJsLibVersion); |
|
| 107 | +} |
|
| 108 | 108 | |
| 109 | - /** |
|
| 109 | +/** |
|
| 110 | 110 | * Get the default request URI |
| 111 | 111 | * |
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | - public function getRequestUri(): string |
|
| 115 | - { |
|
| 116 | - return $this->config()->getOption('core.request.uri', |
|
| 117 | - $this->getParameterReader()->uri()); |
|
| 118 | - } |
|
| 114 | +public function getRequestUri(): string |
|
| 115 | +{ |
|
| 116 | +return $this->config()->getOption('core.request.uri', |
|
| 117 | +$this->getParameterReader()->uri()); |
|
| 118 | +} |
|
| 119 | 119 | } |
@@ -15,64 +15,64 @@ |
||
| 15 | 15 | |
| 16 | 16 | trait ResponseTrait |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * Register the values into the container |
| 20 | 20 | * |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - private function registerResponses(): void |
|
| 24 | - { |
|
| 25 | - // Global Response |
|
| 26 | - $this->set(Response::class, function($di) { |
|
| 27 | - return new Response($di->g(ResponseManager::class), $di->g(PluginManager::class)); |
|
| 28 | - }); |
|
| 29 | - // Response Manager |
|
| 30 | - $this->set(ResponseManager::class, function($di) { |
|
| 31 | - $sEncoding = trim($di->g(ConfigManager::class)->getOption('core.encoding', '')); |
|
| 32 | - return new ResponseManager($di->g(Container::class), $di->g(Translator::class), $sEncoding); |
|
| 33 | - }); |
|
| 34 | - } |
|
| 23 | +private function registerResponses(): void |
|
| 24 | +{ |
|
| 25 | +// Global Response |
|
| 26 | +$this->set(Response::class, function($di) { |
|
| 27 | +return new Response($di->g(ResponseManager::class), $di->g(PluginManager::class)); |
|
| 28 | +}); |
|
| 29 | +// Response Manager |
|
| 30 | +$this->set(ResponseManager::class, function($di) { |
|
| 31 | +$sEncoding = trim($di->g(ConfigManager::class)->getOption('core.encoding', '')); |
|
| 32 | +return new ResponseManager($di->g(Container::class), $di->g(Translator::class), $sEncoding); |
|
| 33 | +}); |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Get the response manager |
| 38 | 38 | * |
| 39 | 39 | * @return ResponseManager |
| 40 | 40 | */ |
| 41 | - public function getResponseManager(): ResponseManager |
|
| 42 | - { |
|
| 43 | - return $this->g(ResponseManager::class); |
|
| 44 | - } |
|
| 41 | +public function getResponseManager(): ResponseManager |
|
| 42 | +{ |
|
| 43 | +return $this->g(ResponseManager::class); |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * Get the global Response object |
| 48 | 48 | * |
| 49 | 49 | * @return Response |
| 50 | 50 | */ |
| 51 | - public function getResponse(): Response |
|
| 52 | - { |
|
| 53 | - return $this->g(Response::class); |
|
| 54 | - } |
|
| 51 | +public function getResponse(): Response |
|
| 52 | +{ |
|
| 53 | +return $this->g(Response::class); |
|
| 54 | +} |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * Create a new Jaxon response |
| 58 | 58 | * |
| 59 | 59 | * @return Response |
| 60 | 60 | */ |
| 61 | - public function newResponse(): Response |
|
| 62 | - { |
|
| 63 | - return new Response($this->g(ResponseManager::class), $this->g(PluginManager::class)); |
|
| 64 | - } |
|
| 61 | +public function newResponse(): Response |
|
| 62 | +{ |
|
| 63 | +return new Response($this->g(ResponseManager::class), $this->g(PluginManager::class)); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Create a new reponse for a Jaxon component |
| 68 | 68 | * |
| 69 | 69 | * @param JxnCall $xJxnCall |
| 70 | 70 | * |
| 71 | 71 | * @return NodeResponse |
| 72 | 72 | */ |
| 73 | - public function newNodeResponse(JxnCall $xJxnCall): NodeResponse |
|
| 74 | - { |
|
| 75 | - return new NodeResponse($this->g(ResponseManager::class), |
|
| 76 | - $this->g(PluginManager::class), $xJxnCall); |
|
| 77 | - } |
|
| 73 | +public function newNodeResponse(JxnCall $xJxnCall): NodeResponse |
|
| 74 | +{ |
|
| 75 | +return new NodeResponse($this->g(ResponseManager::class), |
|
| 76 | +$this->g(PluginManager::class), $xJxnCall); |
|
| 77 | +} |
|
| 78 | 78 | } |
@@ -18,78 +18,78 @@ |
||
| 18 | 18 | |
| 19 | 19 | trait ViewTrait |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * Register the values into the container |
| 23 | 23 | * |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | - private function registerViews(): void |
|
| 27 | - { |
|
| 28 | - // Jaxon template view |
|
| 29 | - $this->set(TemplateView::class, function($di) { |
|
| 30 | - return new TemplateView($di->g(TemplateEngine::class)); |
|
| 31 | - }); |
|
| 32 | - // View Renderer |
|
| 33 | - $this->set(ViewRenderer::class, function($di) { |
|
| 34 | - $xViewRenderer = new ViewRenderer($di->g(Container::class)); |
|
| 35 | - // Add the default view renderer |
|
| 36 | - $xViewRenderer->addRenderer('jaxon', function($di) { |
|
| 37 | - return $di->g(TemplateView::class); |
|
| 38 | - }); |
|
| 39 | - $sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 40 | - $sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 41 | - // By default, render pagination templates with Jaxon. |
|
| 42 | - $xViewRenderer->addNamespace('jaxon', $sTemplateDir, '.php', 'jaxon'); |
|
| 43 | - $xViewRenderer->addNamespace('pagination', $sPaginationDir, '.php', 'jaxon'); |
|
| 44 | - return $xViewRenderer; |
|
| 45 | - }); |
|
| 26 | +private function registerViews(): void |
|
| 27 | +{ |
|
| 28 | +// Jaxon template view |
|
| 29 | +$this->set(TemplateView::class, function($di) { |
|
| 30 | +return new TemplateView($di->g(TemplateEngine::class)); |
|
| 31 | +}); |
|
| 32 | +// View Renderer |
|
| 33 | +$this->set(ViewRenderer::class, function($di) { |
|
| 34 | +$xViewRenderer = new ViewRenderer($di->g(Container::class)); |
|
| 35 | +// Add the default view renderer |
|
| 36 | +$xViewRenderer->addRenderer('jaxon', function($di) { |
|
| 37 | + return $di->g(TemplateView::class); |
|
| 38 | +}); |
|
| 39 | +$sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 40 | +$sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 41 | +// By default, render pagination templates with Jaxon. |
|
| 42 | +$xViewRenderer->addNamespace('jaxon', $sTemplateDir, '.php', 'jaxon'); |
|
| 43 | +$xViewRenderer->addNamespace('pagination', $sPaginationDir, '.php', 'jaxon'); |
|
| 44 | +return $xViewRenderer; |
|
| 45 | +}); |
|
| 46 | 46 | |
| 47 | - // By default there is no dialog library registry. |
|
| 48 | - $this->set(LibraryRegistryInterface::class, function($di) { |
|
| 49 | - return null; |
|
| 50 | - }); |
|
| 51 | - // Dialog command |
|
| 52 | - $this->set(DialogCommand::class, function($di) { |
|
| 53 | - return new DialogCommand($di->g(LibraryRegistryInterface::class)); |
|
| 54 | - }); |
|
| 55 | - // Pagination renderer |
|
| 56 | - $this->set(RendererInterface::class, function($di) { |
|
| 57 | - return new Renderer($di->g(ViewRenderer::class)); |
|
| 58 | - }); |
|
| 47 | +// By default there is no dialog library registry. |
|
| 48 | +$this->set(LibraryRegistryInterface::class, function($di) { |
|
| 49 | +return null; |
|
| 50 | +}); |
|
| 51 | +// Dialog command |
|
| 52 | +$this->set(DialogCommand::class, function($di) { |
|
| 53 | +return new DialogCommand($di->g(LibraryRegistryInterface::class)); |
|
| 54 | +}); |
|
| 55 | +// Pagination renderer |
|
| 56 | +$this->set(RendererInterface::class, function($di) { |
|
| 57 | +return new Renderer($di->g(ViewRenderer::class)); |
|
| 58 | +}); |
|
| 59 | 59 | |
| 60 | - // Helpers for HTML custom attributes formatting |
|
| 61 | - $this->set(HtmlAttrHelper::class, function($di) { |
|
| 62 | - return new HtmlAttrHelper($di->g(ComponentContainer::class)); |
|
| 63 | - }); |
|
| 64 | - } |
|
| 60 | +// Helpers for HTML custom attributes formatting |
|
| 61 | +$this->set(HtmlAttrHelper::class, function($di) { |
|
| 62 | +return new HtmlAttrHelper($di->g(ComponentContainer::class)); |
|
| 63 | +}); |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Get the view renderer |
| 68 | 68 | * |
| 69 | 69 | * @return ViewRenderer |
| 70 | 70 | */ |
| 71 | - public function getViewRenderer(): ViewRenderer |
|
| 72 | - { |
|
| 73 | - return $this->g(ViewRenderer::class); |
|
| 74 | - } |
|
| 71 | +public function getViewRenderer(): ViewRenderer |
|
| 72 | +{ |
|
| 73 | +return $this->g(ViewRenderer::class); |
|
| 74 | +} |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | +/** |
|
| 77 | 77 | * Get the custom attributes helper |
| 78 | 78 | * |
| 79 | 79 | * @return HtmlAttrHelper |
| 80 | 80 | */ |
| 81 | - public function getHtmlAttrHelper(): HtmlAttrHelper |
|
| 82 | - { |
|
| 83 | - return $this->g(HtmlAttrHelper::class); |
|
| 84 | - } |
|
| 81 | +public function getHtmlAttrHelper(): HtmlAttrHelper |
|
| 82 | +{ |
|
| 83 | +return $this->g(HtmlAttrHelper::class); |
|
| 84 | +} |
|
| 85 | 85 | |
| 86 | - /** |
|
| 86 | +/** |
|
| 87 | 87 | * Get the dialog command |
| 88 | 88 | * |
| 89 | 89 | * @return DialogCommand |
| 90 | 90 | */ |
| 91 | - public function getDialogCommand(): DialogCommand |
|
| 92 | - { |
|
| 93 | - return $this->g(DialogCommand::class); |
|
| 94 | - } |
|
| 91 | +public function getDialogCommand(): DialogCommand |
|
| 92 | +{ |
|
| 93 | +return $this->g(DialogCommand::class); |
|
| 94 | +} |
|
| 95 | 95 | } |
@@ -14,78 +14,78 @@ |
||
| 14 | 14 | |
| 15 | 15 | trait UtilTrait |
| 16 | 16 | { |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * Register the values into the container |
| 19 | 19 | * |
| 20 | 20 | * @return void |
| 21 | 21 | */ |
| 22 | - private function registerUtils(): void |
|
| 23 | - { |
|
| 24 | - // Translator |
|
| 25 | - $this->set(Translator::class, function($di) { |
|
| 26 | - $xTranslator = new Translator(); |
|
| 27 | - $sResourceDir = rtrim(trim($di->g('jaxon.core.dir.translation')), '/\\'); |
|
| 28 | - // Load the debug translations |
|
| 29 | - $xTranslator->loadTranslations($sResourceDir . '/en/errors.php', 'en'); |
|
| 30 | - $xTranslator->loadTranslations($sResourceDir . '/fr/errors.php', 'fr'); |
|
| 31 | - $xTranslator->loadTranslations($sResourceDir . '/es/errors.php', 'es'); |
|
| 32 | - // Load the config translations |
|
| 33 | - $xTranslator->loadTranslations($sResourceDir . '/en/config.php', 'en'); |
|
| 34 | - $xTranslator->loadTranslations($sResourceDir . '/fr/config.php', 'fr'); |
|
| 35 | - $xTranslator->loadTranslations($sResourceDir . '/es/config.php', 'es'); |
|
| 36 | - // Load the labels translations |
|
| 37 | - $xTranslator->loadTranslations($sResourceDir . '/en/labels.php', 'en'); |
|
| 38 | - $xTranslator->loadTranslations($sResourceDir . '/fr/labels.php', 'fr'); |
|
| 39 | - $xTranslator->loadTranslations($sResourceDir . '/es/labels.php', 'es'); |
|
| 40 | - return $xTranslator; |
|
| 41 | - }); |
|
| 22 | +private function registerUtils(): void |
|
| 23 | +{ |
|
| 24 | +// Translator |
|
| 25 | +$this->set(Translator::class, function($di) { |
|
| 26 | +$xTranslator = new Translator(); |
|
| 27 | +$sResourceDir = rtrim(trim($di->g('jaxon.core.dir.translation')), '/\\'); |
|
| 28 | +// Load the debug translations |
|
| 29 | +$xTranslator->loadTranslations($sResourceDir . '/en/errors.php', 'en'); |
|
| 30 | +$xTranslator->loadTranslations($sResourceDir . '/fr/errors.php', 'fr'); |
|
| 31 | +$xTranslator->loadTranslations($sResourceDir . '/es/errors.php', 'es'); |
|
| 32 | +// Load the config translations |
|
| 33 | +$xTranslator->loadTranslations($sResourceDir . '/en/config.php', 'en'); |
|
| 34 | +$xTranslator->loadTranslations($sResourceDir . '/fr/config.php', 'fr'); |
|
| 35 | +$xTranslator->loadTranslations($sResourceDir . '/es/config.php', 'es'); |
|
| 36 | +// Load the labels translations |
|
| 37 | +$xTranslator->loadTranslations($sResourceDir . '/en/labels.php', 'en'); |
|
| 38 | +$xTranslator->loadTranslations($sResourceDir . '/fr/labels.php', 'fr'); |
|
| 39 | +$xTranslator->loadTranslations($sResourceDir . '/es/labels.php', 'es'); |
|
| 40 | +return $xTranslator; |
|
| 41 | +}); |
|
| 42 | 42 | |
| 43 | - // Config reader |
|
| 44 | - $this->set(ConfigReader::class, function($di) { |
|
| 45 | - return new ConfigReader($di->g(ConfigSetter::class)); |
|
| 46 | - }); |
|
| 47 | - // Config setter |
|
| 48 | - $this->set(ConfigSetter::class, function() { |
|
| 49 | - return new ConfigSetter(); |
|
| 50 | - }); |
|
| 51 | - // Template engine |
|
| 52 | - $this->set(TemplateEngine::class, function($di) { |
|
| 53 | - $xTemplateEngine = new TemplateEngine(); |
|
| 54 | - $sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 55 | - $sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 56 | - $xTemplateEngine->addNamespace('jaxon', $sTemplateDir, '.php'); |
|
| 57 | - $xTemplateEngine->addNamespace('pagination', $sPaginationDir, '.php'); |
|
| 58 | - $xTemplateEngine->setDefaultNamespace('jaxon'); |
|
| 59 | - return $xTemplateEngine; |
|
| 60 | - }); |
|
| 61 | - // URI detector |
|
| 62 | - $this->set(UriDetector::class, function() { |
|
| 63 | - return new UriDetector(); |
|
| 64 | - }); |
|
| 43 | +// Config reader |
|
| 44 | +$this->set(ConfigReader::class, function($di) { |
|
| 45 | +return new ConfigReader($di->g(ConfigSetter::class)); |
|
| 46 | +}); |
|
| 47 | +// Config setter |
|
| 48 | +$this->set(ConfigSetter::class, function() { |
|
| 49 | +return new ConfigSetter(); |
|
| 50 | +}); |
|
| 51 | +// Template engine |
|
| 52 | +$this->set(TemplateEngine::class, function($di) { |
|
| 53 | +$xTemplateEngine = new TemplateEngine(); |
|
| 54 | +$sTemplateDir = rtrim(trim($di->g('jaxon.core.dir.template')), '/\\'); |
|
| 55 | +$sPaginationDir = $sTemplateDir . DIRECTORY_SEPARATOR . 'pagination'; |
|
| 56 | +$xTemplateEngine->addNamespace('jaxon', $sTemplateDir, '.php'); |
|
| 57 | +$xTemplateEngine->addNamespace('pagination', $sPaginationDir, '.php'); |
|
| 58 | +$xTemplateEngine->setDefaultNamespace('jaxon'); |
|
| 59 | +return $xTemplateEngine; |
|
| 60 | +}); |
|
| 61 | +// URI detector |
|
| 62 | +$this->set(UriDetector::class, function() { |
|
| 63 | +return new UriDetector(); |
|
| 64 | +}); |
|
| 65 | 65 | |
| 66 | - // Temp cache for Jaxon components |
|
| 67 | - $this->set(Stash::class, function() { |
|
| 68 | - return new Stash(); |
|
| 69 | - }); |
|
| 70 | - } |
|
| 66 | +// Temp cache for Jaxon components |
|
| 67 | +$this->set(Stash::class, function() { |
|
| 68 | +return new Stash(); |
|
| 69 | +}); |
|
| 70 | +} |
|
| 71 | 71 | |
| 72 | - /** |
|
| 72 | +/** |
|
| 73 | 73 | * Get the template engine |
| 74 | 74 | * |
| 75 | 75 | * @return TemplateEngine |
| 76 | 76 | */ |
| 77 | - public function getTemplateEngine(): TemplateEngine |
|
| 78 | - { |
|
| 79 | - return $this->g(TemplateEngine::class); |
|
| 80 | - } |
|
| 77 | +public function getTemplateEngine(): TemplateEngine |
|
| 78 | +{ |
|
| 79 | +return $this->g(TemplateEngine::class); |
|
| 80 | +} |
|
| 81 | 81 | |
| 82 | - /** |
|
| 82 | +/** |
|
| 83 | 83 | * Get the temp cache for Jaxon components |
| 84 | 84 | * |
| 85 | 85 | * @return Stash |
| 86 | 86 | */ |
| 87 | - public function getStash(): Stash |
|
| 88 | - { |
|
| 89 | - return $this->g(Stash::class); |
|
| 90 | - } |
|
| 87 | +public function getStash(): Stash |
|
| 88 | +{ |
|
| 89 | +return $this->g(Stash::class); |
|
| 90 | +} |
|
| 91 | 91 | } |
@@ -20,99 +20,99 @@ |
||
| 20 | 20 | |
| 21 | 21 | trait RequestTrait |
| 22 | 22 | { |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Register the values into the container |
| 25 | 25 | * |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - private function registerRequests(): void |
|
| 29 | - { |
|
| 30 | - // The parameter reader |
|
| 31 | - $this->set(ParameterReader::class, function($di) { |
|
| 32 | - return new ParameterReader($di->g(Container::class), $di->g(Translator::class), |
|
| 33 | - $di->g(ConfigManager::class), $di->g(UriDetector::class)); |
|
| 34 | - }); |
|
| 35 | - // Callback Manager |
|
| 36 | - $this->set(CallbackManager::class, function($di) { |
|
| 37 | - return new CallbackManager($di->g(ResponseManager::class)); |
|
| 38 | - }); |
|
| 39 | - // By default, register a null upload handler |
|
| 40 | - $this->set(UploadHandlerInterface::class, function() { |
|
| 41 | - return null; |
|
| 42 | - }); |
|
| 43 | - // Request Handler |
|
| 44 | - $this->set(RequestHandler::class, function($di) { |
|
| 45 | - return new RequestHandler($di->g(Container::class), $di->g(PluginManager::class), |
|
| 46 | - $di->g(ResponseManager::class), $di->g(CallbackManager::class), |
|
| 47 | - $di->g(DatabagPlugin::class)); |
|
| 48 | - }); |
|
| 49 | - // Requests and calls Factory |
|
| 50 | - $this->set(CallFactory::class, function($di) { |
|
| 51 | - return new CallFactory($di->g(ComponentContainer::class), $di->g(DialogCommand::class)); |
|
| 52 | - }); |
|
| 53 | - // Factory for function parameters |
|
| 54 | - $this->set(ParameterFactory::class, function() { |
|
| 55 | - return new ParameterFactory(); |
|
| 56 | - }); |
|
| 57 | - } |
|
| 28 | +private function registerRequests(): void |
|
| 29 | +{ |
|
| 30 | +// The parameter reader |
|
| 31 | +$this->set(ParameterReader::class, function($di) { |
|
| 32 | +return new ParameterReader($di->g(Container::class), $di->g(Translator::class), |
|
| 33 | + $di->g(ConfigManager::class), $di->g(UriDetector::class)); |
|
| 34 | +}); |
|
| 35 | +// Callback Manager |
|
| 36 | +$this->set(CallbackManager::class, function($di) { |
|
| 37 | +return new CallbackManager($di->g(ResponseManager::class)); |
|
| 38 | +}); |
|
| 39 | +// By default, register a null upload handler |
|
| 40 | +$this->set(UploadHandlerInterface::class, function() { |
|
| 41 | +return null; |
|
| 42 | +}); |
|
| 43 | +// Request Handler |
|
| 44 | +$this->set(RequestHandler::class, function($di) { |
|
| 45 | +return new RequestHandler($di->g(Container::class), $di->g(PluginManager::class), |
|
| 46 | + $di->g(ResponseManager::class), $di->g(CallbackManager::class), |
|
| 47 | + $di->g(DatabagPlugin::class)); |
|
| 48 | +}); |
|
| 49 | +// Requests and calls Factory |
|
| 50 | +$this->set(CallFactory::class, function($di) { |
|
| 51 | +return new CallFactory($di->g(ComponentContainer::class), $di->g(DialogCommand::class)); |
|
| 52 | +}); |
|
| 53 | +// Factory for function parameters |
|
| 54 | +$this->set(ParameterFactory::class, function() { |
|
| 55 | +return new ParameterFactory(); |
|
| 56 | +}); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * Get the js call factory |
| 61 | 61 | * |
| 62 | 62 | * @return CallFactory |
| 63 | 63 | */ |
| 64 | - public function getCallFactory(): CallFactory |
|
| 65 | - { |
|
| 66 | - return $this->g(CallFactory::class); |
|
| 67 | - } |
|
| 64 | +public function getCallFactory(): CallFactory |
|
| 65 | +{ |
|
| 66 | +return $this->g(CallFactory::class); |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Get the js call parameter factory |
| 71 | 71 | * |
| 72 | 72 | * @return ParameterFactory |
| 73 | 73 | */ |
| 74 | - public function getParameterFactory(): ParameterFactory |
|
| 75 | - { |
|
| 76 | - return $this->g(ParameterFactory::class); |
|
| 77 | - } |
|
| 74 | +public function getParameterFactory(): ParameterFactory |
|
| 75 | +{ |
|
| 76 | +return $this->g(ParameterFactory::class); |
|
| 77 | +} |
|
| 78 | 78 | |
| 79 | - /** |
|
| 79 | +/** |
|
| 80 | 80 | * Get the request handler |
| 81 | 81 | * |
| 82 | 82 | * @return RequestHandler |
| 83 | 83 | */ |
| 84 | - public function getRequestHandler(): RequestHandler |
|
| 85 | - { |
|
| 86 | - return $this->g(RequestHandler::class); |
|
| 87 | - } |
|
| 84 | +public function getRequestHandler(): RequestHandler |
|
| 85 | +{ |
|
| 86 | +return $this->g(RequestHandler::class); |
|
| 87 | +} |
|
| 88 | 88 | |
| 89 | - /** |
|
| 89 | +/** |
|
| 90 | 90 | * Get the upload handler |
| 91 | 91 | * |
| 92 | 92 | * @return UploadHandlerInterface|null |
| 93 | 93 | */ |
| 94 | - public function getUploadHandler(): ?UploadHandlerInterface |
|
| 95 | - { |
|
| 96 | - return $this->g(UploadHandlerInterface::class); |
|
| 97 | - } |
|
| 94 | +public function getUploadHandler(): ?UploadHandlerInterface |
|
| 95 | +{ |
|
| 96 | +return $this->g(UploadHandlerInterface::class); |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * Get the callback manager |
| 101 | 101 | * |
| 102 | 102 | * @return CallbackManager |
| 103 | 103 | */ |
| 104 | - public function getCallbackManager(): CallbackManager |
|
| 105 | - { |
|
| 106 | - return $this->g(CallbackManager::class); |
|
| 107 | - } |
|
| 104 | +public function getCallbackManager(): CallbackManager |
|
| 105 | +{ |
|
| 106 | +return $this->g(CallbackManager::class); |
|
| 107 | +} |
|
| 108 | 108 | |
| 109 | - /** |
|
| 109 | +/** |
|
| 110 | 110 | * Get the parameter reader |
| 111 | 111 | * |
| 112 | 112 | * @return ParameterReader |
| 113 | 113 | */ |
| 114 | - public function getParameterReader(): ParameterReader |
|
| 115 | - { |
|
| 116 | - return $this->g(ParameterReader::class); |
|
| 117 | - } |
|
| 114 | +public function getParameterReader(): ParameterReader |
|
| 115 | +{ |
|
| 116 | +return $this->g(ParameterReader::class); |
|
| 117 | +} |
|
| 118 | 118 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | interface RendererInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * Render an array of pagination links |
| 21 | 21 | * |
| 22 | 22 | * @param Page[] $aPages |
@@ -25,5 +25,5 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string; |
|
| 28 | +public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string; |
|
| 29 | 29 | } |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | class Renderer implements RendererInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * The constructor. |
| 26 | 26 | * |
| 27 | 27 | * @param ViewRenderer $xRenderer |
| 28 | 28 | */ |
| 29 | - public function __construct(private ViewRenderer $xRenderer) |
|
| 30 | - { |
|
| 31 | - $this->xRenderer = $xRenderer; |
|
| 32 | - } |
|
| 29 | +public function __construct(private ViewRenderer $xRenderer) |
|
| 30 | +{ |
|
| 31 | +$this->xRenderer = $xRenderer; |
|
| 32 | +} |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @param Page $xPage |
| 36 | 36 | * |
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | - private function renderPage(Page $xPage): string |
|
| 40 | - { |
|
| 41 | - return $this->xRenderer->render("pagination::links/{$xPage->sType}", [ |
|
| 42 | - 'page' => $xPage->nNumber, |
|
| 43 | - 'text' => $xPage->sText, |
|
| 44 | - ])->__toString(); |
|
| 45 | - } |
|
| 39 | +private function renderPage(Page $xPage): string |
|
| 40 | +{ |
|
| 41 | +return $this->xRenderer->render("pagination::links/{$xPage->sType}", [ |
|
| 42 | +'page' => $xPage->nNumber, |
|
| 43 | +'text' => $xPage->sText, |
|
| 44 | +])->__toString(); |
|
| 45 | +} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * Render an array of pagination links |
| 49 | 49 | * |
| 50 | 50 | * @param Page[] $aPages |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string |
|
| 57 | - { |
|
| 58 | - return trim($this->xRenderer->render('pagination::wrapper', [ |
|
| 59 | - 'links' => array_map(fn($xPage) => $this->renderPage($xPage), $aPages), |
|
| 60 | - 'prev' => $this->renderPage($xPrevPage), |
|
| 61 | - 'next' => $this->renderPage($xNextPage), |
|
| 62 | - ])->__toString()); |
|
| 63 | - } |
|
| 56 | +public function render(array $aPages, Page $xPrevPage, Page $xNextPage): string |
|
| 57 | +{ |
|
| 58 | +return trim($this->xRenderer->render('pagination::wrapper', [ |
|
| 59 | +'links' => array_map(fn($xPage) => $this->renderPage($xPage), $aPages), |
|
| 60 | +'prev' => $this->renderPage($xPrevPage), |
|
| 61 | +'next' => $this->renderPage($xNextPage), |
|
| 62 | +])->__toString()); |
|
| 63 | +} |
|
| 64 | 64 | } |
@@ -13,25 +13,25 @@ |
||
| 13 | 13 | |
| 14 | 14 | class Page |
| 15 | 15 | { |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @var string |
| 18 | 18 | */ |
| 19 | - public $sType; |
|
| 19 | +public $sType; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - public $sText; |
|
| 24 | +public $sText; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - public $nNumber; |
|
| 29 | +public $nNumber; |
|
| 30 | 30 | |
| 31 | - public function __construct(string $sType, string $sText, int $nNumber) |
|
| 32 | - { |
|
| 33 | - $this->sType = $sType; |
|
| 34 | - $this->sText = $sText; |
|
| 35 | - $this->nNumber = $nNumber; |
|
| 36 | - } |
|
| 31 | +public function __construct(string $sType, string $sText, int $nNumber) |
|
| 32 | +{ |
|
| 33 | +$this->sType = $sType; |
|
| 34 | +$this->sText = $sText; |
|
| 35 | +$this->nNumber = $nNumber; |
|
| 36 | +} |
|
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |