Skip to content

Commit

Permalink
implemented event callback function #236
Browse files Browse the repository at this point in the history
  • Loading branch information
psolom committed Nov 23, 2017
1 parent 9abb88a commit 850cb92
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 1 deletion.
103 changes: 103 additions & 0 deletions connectors/php/events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* Events handlers of API operations.
*
* @license MIT License
* @author Pavel Solomienko <https://github.com/servocoder/>
* @copyright Authors
*/

/**
* Event listener on after "getfolder" API method successfully executed.
*
* @param \RFM\Event\Api\AfterFolderReadEvent $event
*/
function fm_event_api_after_folder_read($event)
{
$data = $event->getFolderData();
$list = $event->getFolderContent();
}

/**
* Event listener on after "addfolder" API method successfully executed.
*
* @param \RFM\Event\Api\AfterFolderCreateEvent $event
*/
function fm_event_api_after_folder_create($event)
{
$data = $event->getFolderData();
}

/**
* Event listener on after "upload" API method successfully executed.
*
* @param \RFM\Event\Api\AfterFileUploadEvent $event
*/
function fm_event_api_after_file_upload($event)
{
$data = $event->getUploadedFileData();
}

/**
* Event listener on after "extract" API method successfully executed.
*
* @param \RFM\Event\Api\AfterFileExtractEvent $event
*/
function fm_event_api_after_file_extract($event)
{
$data = $event->getArchiveData();
$list = $event->getArchiveContent();
}

/**
* Event listener on after "rename" API method successfully executed.
*
* @param \RFM\Event\Api\AfterItemRenameEvent $event
*/
function fm_event_api_after_item_rename($event)
{
$data = $event->getItemData();
$originalData = $event->getOriginalItemData();
}

/**
* Event listener on after "copy" API method successfully executed.
*
* @param \RFM\Event\Api\AfterItemCopyEvent $event
*/
function fm_event_api_after_item_copy($event)
{
$data = $event->getItemData();
$originalData = $event->getOriginalItemData();
}

/**
* Event listener on after "move" API method successfully executed.
*
* @param \RFM\Event\Api\AfterItemMoveEvent $event
*/
function fm_event_api_after_item_move($event)
{
$data = $event->getItemData();
$originalData = $event->getOriginalItemData();
}

/**
* Event listener on after "delete" API method successfully executed.
*
* @param \RFM\Event\Api\AfterItemDeleteEvent $event
*/
function fm_event_api_after_item_delete($event)
{
$data = $event->getOriginalItemData();
}

/**
* Event listener on after "download" API method successfully executed.
*
* @param \RFM\Event\Api\AfterItemDownloadEvent $event
*/
function fm_event_api_after_item_download($event)
{
$data = $event->getDownloadedItemData();
}
6 changes: 5 additions & 1 deletion connectors/php/filemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// ini_set('display_errors', '1');

require 'vendor/autoload.php';
require_once 'vendor/autoload.php';
require_once __DIR__ . '/events.php';

// fix display non-latin chars correctly
// https://github.com/servocoder/RichFilemanager/issues/7
Expand Down Expand Up @@ -104,6 +105,9 @@ function fm_has_write_permission($filepath)

$app = new \RFM\Application();

// uncomment to use events
$app->registerEventsListeners();

$local = new \RFM\Repository\Local\Storage($config);

// example to setup files root folder
Expand Down

0 comments on commit 850cb92

Please sign in to comment.