From 35e60c3ff6c16c8b3832c2217ae6016429616adf Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Fri, 3 Mar 2023 22:08:37 -0300 Subject: [PATCH] Objects interfaces and other minor changes --- system/engine/abstracthelper.php | 6 ++- system/engine/autoload.php | 4 ++ system/engine/controller.php | 24 +++++++++--- system/engine/interfaces/common/registers.php | 39 +++++++++++++++++++ system/engine/interfaces/controller.php | 23 +++++++++++ system/engine/interfaces/helper.php | 17 ++++++++ system/engine/interfaces/model.php | 20 ++++++++++ system/engine/model.php | 7 +++- system/engine/registry.php | 2 +- system/engine/restful.php | 3 ++ system/language/autoload.php | 8 +++- system/session/autoload.php | 20 ++++++++++ 12 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 system/engine/interfaces/common/registers.php create mode 100644 system/engine/interfaces/controller.php create mode 100644 system/engine/interfaces/helper.php create mode 100644 system/engine/interfaces/model.php diff --git a/system/engine/abstracthelper.php b/system/engine/abstracthelper.php index 693fde6..ae93fc6 100644 --- a/system/engine/abstracthelper.php +++ b/system/engine/abstracthelper.php @@ -8,6 +8,8 @@ namespace Phacil\Framework; +use Phacil\Framework\Registry; + /** * Abstract class for helpers * @@ -15,7 +17,7 @@ namespace Phacil\Framework; * @abstract * @api */ -abstract class AbstractHelper { +abstract class AbstractHelper implements \Phacil\Framework\Interfaces\Helper { /** * @@ -45,7 +47,7 @@ abstract class AbstractHelper { /** * - * @return object + * {@inheritdoc} */ static public function getInstance() { diff --git a/system/engine/autoload.php b/system/engine/autoload.php index 12f4499..d47166c 100644 --- a/system/engine/autoload.php +++ b/system/engine/autoload.php @@ -86,6 +86,10 @@ 'traits\\action', 'interfaces\\databases', 'interfaces\\serializer', + 'interfaces\\common\\registers', + 'interfaces\\controller', + 'interfaces\\helper', + 'interfaces\\model', 'exception', 'render', 'debug', diff --git a/system/engine/controller.php b/system/engine/controller.php index 62e0b7b..2d8bf62 100644 --- a/system/engine/controller.php +++ b/system/engine/controller.php @@ -8,7 +8,8 @@ namespace Phacil\Framework; -use \Phacil\Framework\Config; +use Phacil\Framework\Config; +use Phacil\Framework\Registry; /** * Extend this class to create interation with your module controller to Phacil engine controller. @@ -35,7 +36,7 @@ use \Phacil\Framework\Config; * @since 0.1.0 * @api */ -abstract class Controller { +abstract class Controller implements \Phacil\Framework\Interfaces\Controller { /** * * @var Registry @@ -135,7 +136,7 @@ abstract class Controller { /** * - * @return object + * {@inheritdoc} */ static public function getInstance() { $class = get_called_class(); @@ -143,9 +144,8 @@ abstract class Controller { } /** - * * @param string $key - * @return Registry + * @return object * @final */ final public function __get($key) { @@ -156,6 +156,20 @@ abstract class Controller { return $this->registry->get($key); } + /** + * @param string $key + * @return object + * @final + * @todo Not yet... + */ + /* final public function __call($key, array $arguments) { + if (!$this->registry) { + $this->__getRegistryClass(); + } + + return $this->registry->get($key); + } */ + /** * * @param string $key diff --git a/system/engine/interfaces/common/registers.php b/system/engine/interfaces/common/registers.php new file mode 100644 index 0000000..a806b6f --- /dev/null +++ b/system/engine/interfaces/common/registers.php @@ -0,0 +1,39 @@ +getName()); break; + case 'POST': default: try { $data = (Request::POST($value->getName())) ?: Request::INPUT($value->getName()); diff --git a/system/language/autoload.php b/system/language/autoload.php index b33c74a..f6d6fa6 100644 --- a/system/language/autoload.php +++ b/system/language/autoload.php @@ -1,4 +1,10 @@ data[$key] ?? null; + } + + /** + * + * @param string $key + * @param mixed $value + * @return $this + */ + public function setData($key, $value) { + $this->data[$key] = $value; + return $this; + } }