/** * Fetch all Doctrine services * * @param string $version * @return array */ public function fetchAll($version = null) { $config = $this->configResource->fetch(true); if (!isset($config['zf-rest'])) { return []; } $services = []; $pattern = false; // Initialize pattern if a version was passed and it is valid if (null !== $version) { $version = (int) $version; if (!in_array($version, $this->moduleEntity->getVersions(), true)) { throw new Exception\RuntimeException(sprintf('Invalid version "%s" provided', $version), 400); } $namespaceSep = preg_quote('\\'); $pattern = sprintf('#%s%sV%s#', $this->module, $namespaceSep, $version); } foreach (array_keys($config['zf-rest']) as $controllerService) { // Because a version is always supplied this check may not be necessary if (!$pattern) { $services[] = $this->fetch($controllerService); continue; } if (preg_match($pattern, $controllerService)) { $services[] = $this->fetch($controllerService); continue; } } return $services; }
/** * Fetch all services * * @param string $version * @return DoctrineRpcServiceEntity[] */ public function fetchAll($version = null) { $config = $this->configResource->fetch(true); if (!isset($config['zf-rpc-doctrine-controller'])) { // @codeCoverageIgnoreStart return array(); // @codeCoverageIgnoreEnd } $services = array(); $pattern = false; // @codeCoverageIgnoreStart // Initialize pattern if a version was passed and it's valid // Ignored from code coverage because Apigility sets the version // and it's no longer handled here: FIXME: verify this if (null !== $version) { if (!in_array($version, $this->moduleEntity->getVersions())) { throw new Exception\RuntimeException(sprintf('Invalid version "%s" provided', $version), 400); } $namespaceSep = preg_quote('\\'); $pattern = sprintf('#%s%sV%s#', $this->module, $namespaceSep, $version); } foreach (array_keys($config['zf-rpc-doctrine-controller']) as $controllerService) { if (!$pattern) { $services[] = $this->fetch($controllerService); continue; } // @codeCoverageIgnoreEnd if (preg_match($pattern, $controllerService)) { $services[] = $this->fetch($controllerService); continue; } } return $services; }