Skip to content

Instantly share code, notes, and snippets.

@johnwards
Created January 18, 2011 11:30
Show Gist options
  • Save johnwards/784301 to your computer and use it in GitHub Desktop.
Save johnwards/784301 to your computer and use it in GitHub Desktop.
Sample calling route from xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl"
exclude-result-prefixes="xsl php">
<xsl:output method="xml"
omit-xml-declaration="yes"
indent="yes"
encoding="utf-8"/>
<xsl:template match="/">
<xsl:value-of
select="php:function('Bundle\Liip\XsltBundle\XsltEngine::route_generate','hello',concat(string('{&quot;name&quot;:&quot;'),string(page/name),'&quot;}'))"/>
</xsl:template>
</xsl:stylesheet>
<?php
class XsltEngine implements EngineInterface
{
//Snip..
protected static $router_instance;
public static function route_generate($name, $json)
{
$params = json_decode($json,true);
return self::$router_instance->generate($name, $params);
}
public function __construct(ContainerInterface $container, LoaderInterface $loader, Kernel $kernel, Request $request, Router $router, $options = array())
{
//Snip..
self::$router_instance = $router;
}
//Snip..
public function render($name, array $parameters = array())
{
//Snip..
$xsl = new \XSLTProcessor();
$xsl->registerPHPFunctions();
//Snip..
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment