Callback.php in Crumbs, the Breadcrumbs suite 7.2
File
lib/EntityPlugin/Callback.php
View source
<?php
class crumbs_EntityPlugin_Callback implements crumbs_EntityPlugin {
protected $callback;
protected $module;
protected $key;
protected $callbackType;
function __construct($callback, $module, $key, $callback_type) {
$this->callback = $callback;
$this->module = $module;
$this->key = $key;
$this->callbackType = $callback_type;
}
function __sleep() {
return array(
'module',
'key',
'callbackType',
);
}
function describe($api, $entity_type, $keys) {
foreach ($keys as $key => $title) {
$api
->addRule($key, $title);
}
}
function entityFindCandidate($entity, $entity_type, $distinction_key) {
if (!isset($this->callback)) {
$this->callback = crumbs()->callbackRestoration
->restoreCallback($this->module, $this->key, $this->callbackType);
}
if (!empty($this->callback)) {
return call_user_func($this->callback, $entity, $entity_type, $distinction_key);
}
return NULL;
}
}