From 7413a16ef25495f57697c515b289dd4d9d2a3e48 Mon Sep 17 00:00:00 2001 From: Alexandr Vronskiy Date: Fri, 21 Oct 2016 14:03:45 +0300 Subject: [PATCH 1/4] Bugfix for PSR4 support Missing fix which already have in RestServiceModel --- src/Model/RpcServiceModel.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Model/RpcServiceModel.php b/src/Model/RpcServiceModel.php index 44b71344..f77a503f 100644 --- a/src/Model/RpcServiceModel.php +++ b/src/Model/RpcServiceModel.php @@ -146,7 +146,7 @@ public function fetchAll($version = null) $namespaceSep = preg_quote('\\'); $pattern = sprintf( '#%s%sV%s#', - $this->module, + $this->moduleNameToRegex(), $namespaceSep, $version ); @@ -763,4 +763,19 @@ public function createMediaType() $this->moduleEntity->getLatestVersion() ); } + + /** + * Converts a module name (which could include namespace separators) into a string that can be used in regex + * matches. Use-cases: + * - Acme\Account => Acme\\Account + * - Acme\\Account (ideally it should never happen) => Acme\\Account + * - Acme => Acme + * + * @return string + */ + private function moduleNameToRegex() + { + // find all backslashes (\) that are NOT followed by another \ and replace them with \\ (two of them) + return preg_replace('#\\\\(?!\\\\)#', '\\\\\\\\', $this->module); + } } From 1410afc304d684cc1ff95c4d8eb468075109a64d Mon Sep 17 00:00:00 2001 From: Alexandr Vronskiy Date: Fri, 21 Oct 2016 14:16:05 +0300 Subject: [PATCH 2/4] PSR fix --- src/Model/RpcServiceModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/RpcServiceModel.php b/src/Model/RpcServiceModel.php index f77a503f..30cf5da2 100644 --- a/src/Model/RpcServiceModel.php +++ b/src/Model/RpcServiceModel.php @@ -763,7 +763,7 @@ public function createMediaType() $this->moduleEntity->getLatestVersion() ); } - + /** * Converts a module name (which could include namespace separators) into a string that can be used in regex * matches. Use-cases: From 9cc383a78875f12a22e518d4a916b229d525f370 Mon Sep 17 00:00:00 2001 From: Alexandr Vronskiy Date: Fri, 21 Oct 2016 14:53:14 +0300 Subject: [PATCH 3/4] PSR2 codestyle fix --- src/Model/RpcServiceModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/RpcServiceModel.php b/src/Model/RpcServiceModel.php index 30cf5da2..840b778e 100644 --- a/src/Model/RpcServiceModel.php +++ b/src/Model/RpcServiceModel.php @@ -764,7 +764,7 @@ public function createMediaType() ); } - /** + /** * Converts a module name (which could include namespace separators) into a string that can be used in regex * matches. Use-cases: * - Acme\Account => Acme\\Account From 680bb970b40c119837da65205594612011896e0b Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 14 Aug 2017 15:00:12 -0500 Subject: [PATCH 4/4] Adds CHANGELOG for #370 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fbbd4d4..aad0d8a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,9 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#370](https://github.com/zfcampus/zf-apigility-admin/pull/370) provides a fix + to the `RpcServiceModel::fetchAll()` method that allows it to work with PSR-4 + structured modules. ## 1.5.9 - 2016-10-12