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. |
(bool) | exists | Ariadne 9. Returns true if the template exists. |
(mixed) | loaded | Ariadne 9. Returns true if the library is loaded. |
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.
exists
(bool) ar('pinp')->exists( $template )
(string) | $template | The template identifier. At least the name of the template, but may also include the library and/or the type. |
Ariadne 9.0 only. Returns true if $template
can be found in the loaded libraries or parents. It will only check pinp template, not the predefined templates in Ariadne.
Examples:
<pinp> if ( ar('pinp')->exists('view.html') ) { ... } </pinp>
Check a template defined for a specific type:
ar('pinp')->exists('pobject::tags.save')
Check a template defined in a named library:
ar('pinp')->exists('tags:tags.save')
And a template defined in a named library, for a specific type:
ar('pinp')->exists('tags:pobject::tags.save')
loaded
(bool) ar('pinp')->loaded( $name, $libraryPath = null )
(string) | $name | The name of the library. |
(string) | $libraryPath | Optional. The path of the library. |
Ariadne 9.0 only. Returns true if a library with the name $name
is loaded. If you add a library path, it will also check if the loaded library is exactly the same.