added comments and renamed short method to url generators
This commit is contained in:
parent
86b2937078
commit
9496e35711
|
@ -14,7 +14,7 @@ class LegacyUrlGenerator extends UrlGenerator
|
|||
* @param array $parameters
|
||||
* @return string urls in the form <app url>/index.php?p=<path>&<parameters>
|
||||
*/
|
||||
public function link_to($path, $parameters = [])
|
||||
public function linkTo($path, $parameters = [])
|
||||
{
|
||||
$page = ltrim($path, '/');
|
||||
if (!empty($page)) {
|
||||
|
@ -22,7 +22,7 @@ class LegacyUrlGenerator extends UrlGenerator
|
|||
$parameters = array_merge(['p' => $page], $parameters);
|
||||
}
|
||||
|
||||
$uri = parent::link_to('index.php', $parameters);
|
||||
$uri = parent::linkTo('index.php', $parameters);
|
||||
$uri = preg_replace('~(/index\.php)+~', '/index.php', $uri);
|
||||
|
||||
return $uri;
|
||||
|
|
|
@ -14,7 +14,7 @@ class UrlGenerator implements UrlGeneratorInterface
|
|||
* @param array $parameters
|
||||
* @return string url in the form [app url]/[path]?[parameters]
|
||||
*/
|
||||
public function link_to($path, $parameters = [])
|
||||
public function linkTo($path, $parameters = [])
|
||||
{
|
||||
$path = '/' . ltrim($path, '/');
|
||||
$request = app('request');
|
||||
|
|
|
@ -12,5 +12,5 @@ interface UrlGeneratorInterface
|
|||
* @param array $parameters
|
||||
* @return string
|
||||
*/
|
||||
public function link_to($path, $parameters = []);
|
||||
public function linkTo($path, $parameters = []);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ function url($path = null, $parameters = [])
|
|||
return $urlGenerator;
|
||||
}
|
||||
|
||||
return $urlGenerator->link_to($path, $parameters);
|
||||
return $urlGenerator->linkTo($path, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -177,7 +177,7 @@ class HelpersTest extends TestCase
|
|||
$this->assertEquals($urlGeneratorMock, url());
|
||||
|
||||
$urlGeneratorMock->expects($this->once())
|
||||
->method('link_to')
|
||||
->method('linkTo')
|
||||
->with('foo/bar', ['param' => 'value'])
|
||||
->willReturn('http://lorem.ipsum/foo/bar?param=value');
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class LegacyUrlGeneratorTest extends TestCase
|
|||
$urlGenerator = new LegacyUrlGenerator();
|
||||
$this->assertInstanceOf(UrlGeneratorInterface::class, $urlGenerator);
|
||||
|
||||
$url = $urlGenerator->link_to($urlToPath, $arguments);
|
||||
$url = $urlGenerator->linkTo($urlToPath, $arguments);
|
||||
$this->assertEquals($expectedUrl, $url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ class UrlGeneratorTest extends TestCase
|
|||
$urlGenerator = new UrlGenerator();
|
||||
$this->assertInstanceOf(UrlGeneratorInterface::class, $urlGenerator);
|
||||
|
||||
$url = $urlGenerator->link_to($urlToPath, $arguments);
|
||||
$url = $urlGenerator->linkTo($urlToPath, $arguments);
|
||||
$this->assertEquals($expectedUrl, $url);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue