Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.
Prev Previous commit
Next Next commit
Use short array syntax
  • Loading branch information
neeckeloo committed Jul 17, 2015
commit 472b8a6f4498795496604b4a93f20ac84d2bf3cd
26 changes: 15 additions & 11 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace ZF\ApiProblem;

use Zend\Loader\StandardAutoloader;
use Zend\Mvc\ResponseSender\SendResponseEvent;
use Zend\Mvc\MvcEvent;
use ZF\ApiProblem\Listener\SendApiProblemResponseListener;

/**
* ZF2 module
Expand All @@ -21,11 +23,13 @@ class Module
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array('namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/',
))
);
return [
StandardAutoloader::class => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/',
]
]
];
}

/**
Expand All @@ -43,21 +47,21 @@ public function getConfig()
*
* Attaches a render event.
*
* @param \Zend\Mvc\MvcEvent $e
* @param MvcEvent $e
*/
public function onBootstrap($e)
public function onBootstrap(MvcEvent $e)
{
$app = $e->getTarget();
$serviceManager = $app->getServiceManager();
$eventManager = $app->getEventManager();

$eventManager->attach($serviceManager->get('ZF\ApiProblem\ApiProblemListener'));
$eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'onRender'), 100);
$eventManager->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender'], 100);

$sendResponseListener = $serviceManager->get('SendResponseListener');
$sendResponseListener->getEventManager()->attach(
SendResponseEvent::EVENT_SEND_RESPONSE,
$serviceManager->get('ZF\ApiProblem\Listener\SendApiProblemResponseListener'),
$serviceManager->get(SendApiProblemResponseListener::class),
-500
);
}
Expand All @@ -67,9 +71,9 @@ public function onBootstrap($e)
*
* Attaches a rendering/response strategy to the View.
*
* @param \Zend\Mvc\MvcEvent $e
* @param MvcEvent $e
*/
public function onRender($e)
public function onRender(MvcEvent $e)
{
$app = $e->getTarget();
$services = $app->getServiceManager();
Expand Down
26 changes: 13 additions & 13 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
*/

return array(
'service_manager' => array(
'aliases' => array(
return [
'service_manager' => [
'aliases' => [
'ZF\ApiProblem\ApiProblemListener' => 'ZF\ApiProblem\Listener\ApiProblemListener',
'ZF\ApiProblem\RenderErrorListener' => 'ZF\ApiProblem\Listener\RenderErrorListener',
'ZF\ApiProblem\ApiProblemRenderer' => 'ZF\ApiProblem\View\ApiProblemRenderer',
'ZF\ApiProblem\ApiProblemStrategy' => 'ZF\ApiProblem\View\ApiProblemStrategy',
),
'factories' => array(
],
'factories' => [
'ZF\ApiProblem\Listener\ApiProblemListener' => 'ZF\ApiProblem\Factory\ApiProblemListenerFactory',
'ZF\ApiProblem\Listener\RenderErrorListener' => 'ZF\ApiProblem\Factory\RenderErrorListenerFactory',
'ZF\ApiProblem\Listener\SendApiProblemResponseListener' => 'ZF\ApiProblem\Factory\SendApiProblemResponseListenerFactory',
'ZF\ApiProblem\View\ApiProblemRenderer' => 'ZF\ApiProblem\Factory\ApiProblemRendererFactory',
'ZF\ApiProblem\View\ApiProblemStrategy' => 'ZF\ApiProblem\Factory\ApiProblemStrategyFactory',
)
),
],
],

'view_manager' => array(
'view_manager' => [
// Enable this in your application configuration in order to get full
// exception stack traces in your API-Problem responses.
'display_exceptions' => false,
),
],

'zf-api-problem' => array(
'zf-api-problem' => [
// Accept types that should allow ApiProblem responses
// 'accept_filters' => $stringOrArray,

// Array of controller service names that should enable the ApiProblem render.error listener
//'render_error_controllers' => array(),
)
);
//'render_error_controllers' => [],
],
];
2 changes: 2 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
</rule>

<!-- Paths to check -->
<file>config</file>
<file>src</file>
<file>test</file>
<file>Module.php</file>
</ruleset>