-
Notifications
You must be signed in to change notification settings - Fork 6
Binding Events
Similar to jQuery's bind(), you can attach handlers to events within gpFinder by using the bind configuration option. Bind accepts array(key => value) pairs where:
key is a space separated list of events to bind to or "*" for all events
value is a valid [callback](Php Callbacks)
Your callback will receive at least one argument (the name of the event), but will most likely receive more. Arguments depend on the type of event being attached to, see below for more information.
###Example
<?php
function mySimpleCallback( $event, $result, $args ){
// do something here
}
$opts = array(
'bind' => array(
'mkdir mkfile rename duplicate upload rm paste' => 'mySimpleCallback'
),
'roots' => array(...)
);
$connector = new Finder($opts);
$connector->run();#Before Commands
These events are called before commands are performed by gpFinder.
Important Your callback should return the value of $args or a modified version of $args. Otherwise, gpFinder will display "Permission denied".
Events: open-before ls-before tree-before ... (see the full list below)
Callback Arguments: $event, $args, $finder
Callback Return: $args
#After Commands These events are called after a command has been performed by gpFinder
Events: open ls tree parents tmb file size mkdir mkfile rm rename duplicate paste upload get put archive extract search info dim resize netmount
Callback Arguments: $event, $result, $args, $finder
Callback Return: null|false
###Example
<?php
function callback_after( $event, $result, $args ){
// do something here
}
function callback_before( $event, $args ){
// do something here
return $args
}
$opts = array(
'bind' => array(
'upload-before' => 'callback_before',
'mkdir mkfile rename duplicate upload rm paste' => 'callback_after',
),
'roots' => array(...)
);
$connector = new Finder($opts);
$connector->run();