plugin = $plugin; $this->profile = $profile; } /** * Implements LinkitSearchPluginInterface::factory(). */ public static function factory($plugin, LinkitProfile $profile) { ctools_include('plugins'); // Make sure that the handler class exists and that it has this class as one // of its parents. if (class_exists($plugin['handler']['class']) && is_subclass_of($plugin['handler']['class'], __CLASS__)) { return new $plugin['handler']['class']($plugin, $profile); } else { // The plugin handler class is defined but it cannot be found, so lets // instantiate the LinkitSearchPluginBroken instead. return new LinkitSearchPluginBroken($plugin, $profile); } } /** * Implements LinkitSearchPluginInterface::ui_title(). */ public function ui_title() { if (!isset($this->plugin['ui_title'])) { return check_plain($this->plugin['module'] . ':' . $this->plugin['name']); } return check_plain($this->plugin['ui_title']); } /** * Implements LinkitSearchPluginInterface::ui_description(). */ public function ui_description() { if (isset($this->plugin['ui_description'])) { return check_plain($this->plugin['ui_description']); } } /** * Generate a settings form for this handler. * Uses the standard Drupal FAPI. * * @return * An array containing any custom form elements to be displayed in the * profile editing form */ public function buildSettingsForm() {} /** * Determine if the handler is considered 'broken', meaning it's a * a placeholder used when a handler can't be found. */ public function broken() { } } /** * A special handler to take the place of missing or broken Linkit search * plugin handlers. */ class LinkitSearchPluginBroken extends LinkitSearchPlugin { /** * Overrides LinkitSearchPlugin::ui_title(). */ public function ui_title() { return t('Broken/missing handler'); } /** * Overrides LinkitSearchPlugin::ui_description(). */ public function ui_description() {} /** * Implements LinkitSearchPluginInterface::fetchResults(). */ public function fetchResults($search_string) {} /** * Overrides LinkitSearchPlugin::broken(). */ public function broken() { return TRUE; } }