From 8c7f873c2d98ee507fee4a5993e255ce56016602 Mon Sep 17 00:00:00 2001 From: dvnc0 Date: Tue, 12 Sep 2023 01:04:08 -0400 Subject: [PATCH] working on injector --- src/App/Actions/Test_Action.php | 17 ----------------- src/App/Tasks/Task_Base.php | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 src/App/Actions/Test_Action.php diff --git a/src/App/Actions/Test_Action.php b/src/App/Actions/Test_Action.php deleted file mode 100644 index 9011e6b..0000000 --- a/src/App/Actions/Test_Action.php +++ /dev/null @@ -1,17 +0,0 @@ -Injector->resolve(Input::class, ['Printer' => $this->Printer]); - $input->get('What is the answer'); - $this->Printer->message("Test Action"); - return new Request_Response(true); - } -} diff --git a/src/App/Tasks/Task_Base.php b/src/App/Tasks/Task_Base.php index 2418c77..c4c3159 100644 --- a/src/App/Tasks/Task_Base.php +++ b/src/App/Tasks/Task_Base.php @@ -5,6 +5,7 @@ use Clyde\Core\Event_Dispatcher; use Clyde\Tasks\Task_Response; use Clyde\Tools\Printer; +use Exception; abstract class Task_Base { @@ -53,4 +54,20 @@ public function __construct(Application $Application) { * @return Task_Response */ abstract public function execute(): Task_Response; + + /** + * Call a method on the Application + * + * @param string $name Method name + * @param array $arguments Method arguments + * @return mixed + */ + public function __get(string $name) { + $method = "get{$name}"; + if (method_exists($this->Application, $method)) { + return $this->Application->$method(); + } + + throw new Exception("Method {$method} does not exist"); + } } \ No newline at end of file