php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38595 XSLTProcessor::registerPHPFunctions() should be able to register callbacks
Submitted: 2006-08-25 17:09 UTC Modified: 2011-02-21 21:22 UTC
Votes:11
Avg. Score:4.5 ± 0.9
Reproduced:9 of 9 (100.0%)
Same Version:2 (22.2%)
Same OS:7 (77.8%)
From: goliath dot mailinglist at gmx dot de Assigned:
Status: Open Package: XSLT related
PHP Version: 5.1.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: goliath dot mailinglist at gmx dot de
New email:
PHP Version: OS:

 

 [2006-08-25 17:09 UTC] goliath dot mailinglist at gmx dot de
Description:
------------
XSLTProcessor::registerPHPFunctions() has very limited use. It is only possible to register static callable functions.

Some nicer API would be:
$xslt = new XSLTProcessor()
$xslt->registerPHPFunctions(array(
	'func1' => 'functionblah',
	'func2' => array('class', 'method'),
	'func3' => array($obj, 'method') // this would be the real advantage
));

Or even better:
$xslt->registerPHPFunction('func1', 'functionblah');
$xslt->registerPHPFunction('func2', array('class', 'method'));
$xslt->registerPHPFunction('func3', array($obj, 'method'));
$xslt->removePHPFunction('func1');

This would be similar to the set/get/removeParameter-API....

btw.: Your CAPCHA only works with cookies enabled, that really sucks.

Reproduce code:
---------------
None, not possible

Expected result:
----------------
Be able to have instance-methods as callbacks for the XSLTProcessor.
(Note: Not global accessibly objects)

Actual result:
--------------
Not possible

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-24 03:35 UTC] php at xmlnode dot com
I'm not sure how important this really is.  I too was disappointed at 
the lack of flexibility with registerPHPFunctions, but it was hard to 
be too upset about it because for us, the decision to use XSL as a 
template is an acknowledgment of standards and registerPHPFunctions is 
not standard...  

What we've done, if the value can't be passed as a parameter using 
XSLTProcessor::setParameter() is created a class with a bunch of 
static methods which are then called using something like this:

php:function('XSL::<function name>',0)

If objects need to be instantiated, that work is done inside of those 
respective methods -- not throughout the XSL.  The approach here has 
the added benefit of being able to periodically scrutinize what others 
on the team  are wanting access to within the XSL and make adjustments 
for security, performance, etc.

YMMV
 [2011-02-21 21:22 UTC] jani@php.net
-Package: Feature/Change Request +Package: XSLT related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 15:01:30 2019 UTC