Skip to content

Commit

Permalink
Downgrade Application to EventsCapableInterface
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksei Khudiakov <[email protected]>
  • Loading branch information
Xerkus committed Dec 9, 2023
1 parent f017f2e commit 6b7cd1c
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Laminas\Mvc;

use Laminas\EventManager\EventManagerAwareInterface;
use Laminas\EventManager\EventManagerInterface;
use Laminas\EventManager\EventsCapableInterface;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\RequestInterface;
use Laminas\Stdlib\ResponseInterface;
Expand Down Expand Up @@ -39,8 +39,7 @@
* if you wish to setup your own listeners and/or workflow; alternately, you
* can simply extend the class to override such behavior.
*/
class Application implements
EventManagerAwareInterface
class Application implements EventsCapableInterface
{
public const ERROR_CONTROLLER_CANNOT_DISPATCH = 'error-controller-cannot-dispatch';
public const ERROR_CONTROLLER_NOT_FOUND = 'error-controller-not-found';
Expand Down Expand Up @@ -68,8 +67,7 @@ class Application implements
*/
protected $event;

/** @var EventManagerInterface */
protected $events;
protected EventManagerInterface $events;

/** @var RequestInterface */
protected $request;
Expand All @@ -79,11 +77,11 @@ class Application implements

public function __construct(
protected ServiceManager $serviceManager,
?EventManagerInterface $events = null,
EventManagerInterface $events,
?RequestInterface $request = null,
?ResponseInterface $response = null
) {
$this->setEventManager($events ?: $serviceManager->get('EventManager'));
$this->setEventManager($events);
$this->request = $request ?: $serviceManager->get('Request');
$this->response = $response ?: $serviceManager->get('Response');

Expand Down Expand Up @@ -173,27 +171,17 @@ public function getMvcEvent()

/**
* Set the event manager instance
*
* @return Application
*/
public function setEventManager(EventManagerInterface $eventManager)
protected function setEventManager(EventManagerInterface $eventManager): void
{
$eventManager->setIdentifiers([
self::class,
static::class,
]);
$this->events = $eventManager;
return $this;
}

/**
* Retrieve the event manager
*
* Lazy-loads an EventManager instance if none registered.
*
* @return EventManagerInterface
*/
public function getEventManager()
public function getEventManager(): EventManagerInterface
{
return $this->events;
}
Expand Down

0 comments on commit 6b7cd1c

Please sign in to comment.