public function getRoute($name, array $params = []) { $route = $this->microWebFramework->getRouteName($name); $args = array_merge([$name], $params); if (empty($route)) { throw new MicroWebFrameException("The route '%s' doesn't exist.", $name); } $pattern = '/(\\{\\w*\\}|\\{(.+?):((\\{[^\\}]*\\})*|[^\\}])*\\})/'; preg_match_all($pattern, $route, $tabNameInfo); $nbNeededValue = count($tabNameInfo[0]); if ($nbNeededValue > func_num_args() - 1) { $nbValue = count($tabNameInfo[0]) - func_num_args() + 1; throw new MicroWebFrameException("You need to follow the pattern \"%s\" miss %s values.", $route, $nbValue); } if ($nbNeededValue <= 0) { return $this->getHttpName() . $this->fileEntryPoint . $route; } $nbArgs = count($tabNameInfo[0]); for ($i = 0; $i < $nbArgs; $i++) { $route = preg_replace($pattern, $args[$i + 1], $route, 1); } return $this->getHttpName() . $this->fileEntryPoint . $route; }
protected function setUp() { file_put_contents(__DIR__ . '/Resources/Sphring/db.ct', 0); $sphring = new Sphring(__DIR__ . '/Resources/Sphring/main.yml'); $sphring->setRootProject(__DIR__ . '/../../..'); $sphring->setComposerLockFile(__DIR__ . '/../../../composer.lock'); $sphring->loadContext(); $this->sphring = $sphring; $_SERVER['HTTP_X_Broker_API_Version'] = '2.4'; $_SERVER['PHP_AUTH_USER'] = '******'; $_SERVER['PHP_AUTH_PW'] = 'changePassw0rd'; $this->microWebFrameWork = $sphring->getBean('microwebframe.main'); $this->dispatcher = $this->microWebFrameWork->getRouter()->getDispatcher(); $doctrineBoot = $this->sphring->getBean('microwebframe.doctrine'); $this->entityManager = $doctrineBoot->getEntityManager(); }