Created
January 18, 2011 11:30
-
-
Save johnwards/784301 to your computer and use it in GitHub Desktop.
Sample calling route from xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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('{"name":"'),string(page/name),'"}'))"/> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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