ar\pinp
With the PINP module you can check if access to a certain method is allowed in PINP code. You can also create a function callback to a PINP template.
methods
(function) |
getCallback |
Returns a function callback for a template. |
(bool) |
isAllowed |
Returns true if access to a certain class and method is allowed in PINP code. |
getCallback
(function) ar_pinp::getCallback( $template, $params = array() )
(string) |
$template |
The name of the template |
(array) |
$params |
The parameters for the callback function |
This method returns a new function callback, which when called will call the given template name on the current object. The $params variable should be an array with parameter names. The arguments to the function call will be matched in order with the names in $params and passed as named arguments to the template.
<pinp>
$mySort = ar('pinp')->getCallback('my.sort', array('a', 'b') );
$array = array( 1, 2, 4, 3 );
usort( $array, $mySort );
</pinp>
my.sort:
<pinp>
$a = getvar('a');
$b = getvar('b');
if ( $a == $b ) {
return 0;
}
return ( $a < $b ) ? -1 : 1;
</pinp>
isAllowed
(bool) ar_pinp::isAllowed( $class, $method )
(string) |
$class |
The name of the class. |
(string) |
$method |
The name of the method. |
Returns true if the given method on the given class may be used in a PINP template.