Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Controller
- {
- public function getUrl($name, array $data = array())
- {
- $route = $this->getRequest()->getRouteByName($name);
- if (!$route) {
- return;
- }
- $url = $regex = preg_replace_callback(
- Route::PATTERN_REGEX,
- function($matches) {
- list(, $noRef, $type, $name) = $matches;
- if (isset($data[$name])) {
- return $data[$name];
- }
- },
- $route->getPattern()
- );
- return $url;
- }
- }
Add Comment
Please, Sign In to add comment