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

Commit

Permalink
Merge branch 'hotfix/370' into develop
Browse files Browse the repository at this point in the history
Forward port #370
  • Loading branch information
weierophinney committed Aug 14, 2017
2 parents 8b68338 + 680bb97 commit ddd2219
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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

Expand Down
17 changes: 16 additions & 1 deletion src/Model/RpcServiceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function fetchAll($version = null)
$namespaceSep = preg_quote('\\');
$pattern = sprintf(
'#%s%sV%s#',
$this->module,
$this->moduleNameToRegex(),
$namespaceSep,
$version
);
Expand Down Expand Up @@ -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);
}
}

0 comments on commit ddd2219

Please sign in to comment.