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: 2024-01-13 12:44 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: nielsdos (profile)
Status: Closed Package: XSLT related
PHP Version: 5.1.5 OS: Linux
Private report: No CVE-ID: None
 [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
 [2023-04-25 08:04 UTC] officelpsts at gmail dot com
Lifestyle Fashion News are sharing latest news about lifestyle, fashion,etc. More info to visit: (https://lifestylefashionnews.com)github.com
 [2024-01-13 12:44 UTC] nielsdos@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nielsdos
 [2024-01-13 12:44 UTC] nielsdos@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

This was implemented in https://wiki.php.net/rfc/improve_callbacks_dom_and_xsl
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC