Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
[#226] Update getServiceType() to reflect changes to service names
Browse files Browse the repository at this point in the history
Originally, this looked for just namespaced segments (`Rest` and `Rpc`).
However, with the changes made for 1.0.4 to remove encoded slashes from
service names, this breaks link injection, as it could not identify a
REST service by the namespace, and thus always identified services as
RPC. The change introduced will now also detect when the service name
contains dash-separated namespaces (`-Rest-`).
  • Loading branch information
weierophinney committed Sep 9, 2014
1 parent 5b3e962 commit c4dbab4
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use Zend\Http\Header\GenericHeader;
use Zend\Http\Header\GenericMultiHeader;
use Zend\ModuleManager\ModuleManagerInterface;
use Zend\Mvc\MvcEvent;
use Zend\Mvc\Router\RouteMatch;
use ZF\Configuration\ConfigResource;
Expand All @@ -35,21 +34,6 @@ class Module
*/
protected $sm;

/**
* Ensure the UI module is loaded
*
* @param ModuleManagerInterface $modules
*/
public function init(ModuleManagerInterface $modules)
{
$loaded = $modules->getLoadedModules();
if (isset($loaded['ZF\Apigility\Admin\Ui'])) {
return;
}

$modules->loadModule('ZF\Apigility\Admin\Ui');
}

public function onBootstrap(MvcEvent $e)
{
$app = $e->getApplication();
Expand Down Expand Up @@ -752,7 +736,9 @@ protected function injectLinksForServicesByType($type, $services, LinkCollection

protected function getServiceType($service)
{
if (strstr($service, '\\Rest\\')) {
if (strstr($service, '\\Rest\\')
|| strstr($service, '-Rest-')
) {
return 'rest';
}
return 'rpc';
Expand Down

0 comments on commit c4dbab4

Please sign in to comment.