Skip to content

Instantly share code, notes, and snippets.

@wizhippo
Created December 14, 2015 14:42
Show Gist options
  • Save wizhippo/41a643c6b2002764b0f9 to your computer and use it in GitHub Desktop.
Save wizhippo/41a643c6b2002764b0f9 to your computer and use it in GitHub Desktop.
<?php
namespace TestBundle\Controller;
use eZ\Bundle\EzPublishCoreBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
/**
* @Route("/routertest")
*/
class DefaultRouterTestController extends Controller
{
/**
* @Route("/", name="routertest")
*/
public function indexAction()
{
// ezpublish:
// siteaccess:
// default_siteaccess: dev
// list:
// - dev
// match:
// Map\URI:
// dev: dev
// KnpMenuBundle and others that use older api and pass false to mean not absolute
// As self::ABSOLUTE_URL = 0 this causes the test
// $referenceType == self::ABSOLUTE_URL to be incorrect
// in eZ\Bundle\EzPublishCoreBundle\Routing\DefaultRouter
//
// You can see in symfony they do a conversion first to support the old format
// https://github.com/symfony/symfony/blob/75f59ebe01acc6f510b32b5ea8d3173d3d8e8458/src/Symfony/Component/Routing/Generator/UrlGenerator.php#L153
$url = $this->generateUrl('routertest_testroute', [], false);
if ($url == '/dev/routertest/testroute') {
return new Response('Pass Got: ' . $url);
}
return new Response('Fail Got: ' . $url);
}
/**
* @Route("/testroute", name="routertest_testroute")
*/
public function testrouteAction()
{
return new Response("testroute");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment