Add UrlGenerator trait

This commit is contained in:
Romain Neutron
2013-11-22 09:32:21 +01:00
parent 9c7ef7b882
commit 79dfa946d9

View File

@@ -124,6 +124,7 @@ use Neutron\Silex\Provider\FilesystemServiceProvider;
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
use PHPExiftool\PHPExiftoolServiceProvider;
use Silex\Application as SilexApplication;
use Silex\Application\UrlGeneratorTrait;
use Silex\Provider\FormServiceProvider;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\SessionServiceProvider;
@@ -152,6 +153,8 @@ use Symfony\Component\Form\Exception\FormException;
class Application extends SilexApplication
{
use UrlGeneratorTrait;
private static $availableLanguages = [
'de_DE' => 'Deutsch',
'en_GB' => 'English',
@@ -467,19 +470,6 @@ class Application extends SilexApplication
return $this['form.factory']->create($type, $data, $options, $parent);
}
/**
* Generates a path from the given parameters.
*
* @param string $route The name of the route
* @param mixed $parameters An array of parameters
*
* @return string The generated path
*/
public function path($route, $parameters = [])
{
return $this['url_generator']->generate($route, $parameters, UrlGenerator::ABSOLUTE_PATH);
}
/**
* Returns a redirect response with a relative path related to a route name.
*
@@ -493,19 +483,6 @@ class Application extends SilexApplication
return $this->redirect($this->path($route, $parameters));
}
/**
* Returns an absolute URL from the given parameters.
*
* @param string $route The name of the route
* @param mixed $parameters An array of parameters
*
* @return string The generated URL
*/
public function url($route, $parameters = [])
{
return $this['url_generator']->generate($route, $parameters, UrlGenerator::ABSOLUTE_URL);
}
/**
* Returns a redirect response with a fully qualified URI related to a route name.
*