/** * * {@inheritDoc} * @see \Ignaszak\Router\Interfaces\IRoute::getRouteArray() */ public function getRouteArray() : array { $result = ['routes' => [], 'tokens' => [], 'defaults' => [], 'patterns' => []]; foreach ($this->fileArray as $file) { $array = $this->parser->parse(file_get_contents($file)) ?? []; $result['routes'] += $array['routes'] ?? []; $result['tokens'] += $array['tokens'] ?? []; $result['defaults'] += $array['defaults'] ?? []; $result['patterns'] += $array['patterns'] ?? []; } return $this->converter->convert($result); }
/** * * {@inheritDoc} * @see \Ignaszak\Router\Interfaces\IRoute::getRouteArray() */ public function getRouteArray() : array { return $this->converter->convert(['routes' => $this->routesArray, 'tokens' => $this->tokensArray, 'defaults' => $this->defaultsArray, 'patterns' => $this->patternsArray, 'checksum' => $this->getChecksum()]); }
public function testConvert() { $this->assertEquals(['name' => ['path' => '/^\\/(?P<token>test1)\\/(?P<globalToken>test2)\\/test3$/', 'tokens' => ['token' => '/^test1$/', 'globalToken' => '/^test2$/'], 'defaults' => [], 'route' => '/{token}/{globalToken}/@pattern']], $this->converter->convert(['routes' => ['name' => ['path' => '/{token}/{globalToken}/@pattern', 'tokens' => ['token' => 'test1']]], 'tokens' => ['globalToken' => 'test2'], 'patterns' => ['pattern' => 'test3']])); }