From 500a0ff473ec611c44482f37e3c93ebd3c8b7f73 Mon Sep 17 00:00:00 2001 From: Davi Date: Thu, 30 Apr 2026 20:05:31 -0300 Subject: [PATCH 1/4] Update composer.json --- composer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0fc7c9b..bc5e998 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,9 @@ "name": "azuracast/example-plugin", "description": "An example AzuraCast plugin, demonstrating the capabilities and common use-cases of the plugin system.", "type": "azuracast-plugin", + "require": { + "php": ">=8.2" + }, "authors": [ { "name": "Buster Neece", @@ -12,6 +15,5 @@ "psr-4": { "Plugin\\ExamplePlugin\\": "src" } - }, - "require": {} + } } From c8f87b5b2fef8382353428583bcc03a269048ecb Mon Sep 17 00:00:00 2001 From: Davi Date: Thu, 30 Apr 2026 20:33:10 -0300 Subject: [PATCH 2/4] Refactor event listeners and route handling Updated event handling to use new class references and modified route naming. --- events.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/events.php b/events.php index 2380e03..21294c4 100644 --- a/events.php +++ b/events.php @@ -1,11 +1,16 @@ addListener( Event\BuildConsoleCommands::class, function (Event\BuildConsoleCommands $event) use ($dispatcher) { @@ -17,18 +22,19 @@ function (Event\BuildConsoleCommands $event) use ($dispatcher) { // Tell the view handler to look for templates in this directory too $dispatcher->addListener(Event\BuildView::class, function(Event\BuildView $event) { - $event->getView()->addFolder('example', __DIR__.'/templates'); + $event->getView()->addFolder('ExamplePlugin', __DIR__.'/templates'); }); // Add a new route handled exclusively by the plugin. $dispatcher->addListener(Event\BuildRoutes::class, function(Event\BuildRoutes $event) { $app = $event->getApp(); - $app->get('/example', \Plugin\ExamplePlugin\Controller\HelloWorld::class) - ->setName('example-plugin:index:index') + $app->get('/example', HelloWorld::class) + ->setName('example:index') ->add(\App\Middleware\EnableView::class); + }); // You can also add classes that implement the EventSubscriberInterface - $dispatcher->addSubscriber(new \Plugin\ExamplePlugin\EventHandler\AllTheListeners); + //$dispatcher->addSubscriber(new AllTheListeners); }; From da78f7e0a0207275b50454428d52418feedb762d Mon Sep 17 00:00:00 2001 From: Davi Date: Thu, 30 Apr 2026 20:35:46 -0300 Subject: [PATCH 3/4] Update view rendering in HelloWorld controller --- src/Controller/HelloWorld.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Controller/HelloWorld.php b/src/Controller/HelloWorld.php index 5528f79..6a94b07 100644 --- a/src/Controller/HelloWorld.php +++ b/src/Controller/HelloWorld.php @@ -5,15 +5,29 @@ namespace Plugin\ExamplePlugin\Controller; use App\Controller\SingleActionInterface; +use App\Exception\Http\InvalidRequestAttribute; +use App\View; +use DI\Container; use App\Http\Response; use App\Http\ServerRequest; use Psr\Http\Message\ResponseInterface; final class HelloWorld implements SingleActionInterface { + //use EnvironmentAwareTrait; + private Container $container; + private View $view; + + public function __construct(Container $container) + { + $this->container = $container; + $this->view = $container->get(View::class); + + } + public function __invoke(ServerRequest $request, Response $response, array $params): ResponseInterface { return $request->getView() - ->renderToResponse($response, 'example::hello_world'); + ->renderToResponse($response, 'ExamplePlugin::hello_world'); } } From 372a1744d97d17771149bf3af89eff4ecf441030 Mon Sep 17 00:00:00 2001 From: Davi Date: Thu, 30 Apr 2026 20:36:13 -0300 Subject: [PATCH 4/4] Change layout from 'minimal' to 'panel' in hello_world --- templates/hello_world.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/hello_world.phtml b/templates/hello_world.phtml index 2124f9e..066f063 100644 --- a/templates/hello_world.phtml +++ b/templates/hello_world.phtml @@ -1,4 +1,4 @@ -layout('minimal', ['title' => __('Hello World!'), 'page_class' => 'example-content']) ?> +layout('panel'); //$this->layout('minimal', ['title' => __('Hello World!'), 'page_class' => 'example-content']) ?>