/** * @dataProvider getPathPartData */ public function testGetPartsFromPath($path, $expected, $expectedException) { if (!empty($expectedException)) { $this->setExpectedException($expectedException); } $this->assertEquals($expected, AgaviArrayPathDefinition::getPartsFromPath($path)); }
/** * Prepends one or more components to the path. * * @param string The components to be prepended. * * @author Dominik del Bondio <*****@*****.**> * @since 0.11.0 */ public function unshift($path) { $parts = AgaviArrayPathDefinition::getPartsFromPath($path); $this->parts = array_merge($parts['parts'], $this->parts); }
/** * Performs as match of the route against the input * * @param array The route info array. * @param string The input. * @param array The array where the matches will be stored to. * * @return bool Whether the regexp matched. * * @author Dominik del Bondio <*****@*****.**> * @since 0.11.0 */ protected function parseInput(array $route, $input, &$matches) { if ($route['opt']['source'] !== null) { $parts = AgaviArrayPathDefinition::getPartsFromPath($route['opt']['source']); $partArray = $parts['parts']; $count = count($partArray); if ($count > 0 && isset($this->sources[$partArray[0]])) { $input = $this->sources[$partArray[0]]; if ($count > 1) { array_shift($partArray); if (is_array($input)) { $input = AgaviArrayPathDefinition::getValue($partArray, $input); } elseif ($input instanceof AgaviIRoutingSource) { $input = $input->getSource($partArray); } } } } return preg_match($route['rxp'], $input, $matches, PREG_OFFSET_CAPTURE); }