Add a first draft for hooks

- New Extension->registerHook($hook_name, $hook_function) method to register a new hook
- Only one hook works for the moment: entry_before_insert
- ExtensionManager::callHook will need to evolve based on future hooks

See https://github.com/FreshRSS/FreshRSS/issues/252
This commit is contained in:
Marien Fressinaud
2014-12-06 18:48:00 +01:00
parent bc81979a6b
commit 08546af75f
3 changed files with 74 additions and 2 deletions

View File

@@ -329,9 +329,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$id = min(time(), $entry_date) . uSecString();
}
$entry->_id($id);
$entry->_isRead($is_read);
$entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
if (is_null($entry)) {
// An extension has returned a null value, there is nothing to insert.
continue;
}
$values = $entry->toArray();
$values['id'] = $id;
$values['is_read'] = $is_read;
$entryDAO->addEntry($values, $prepared_statement);
}
}