/** * This method runs before the record with key value of $id is deleted from $table * * @param FOFTable $table * * @return boolean */ protected function onBeforeDelete(&$id, &$table) { list($isCLI, $isAdmin) = FOFDispatcher::isCliAdmin(); // Let's import the plugin only if we're not in CLI (content plugin needs a user) if (!$isCLI) { JPluginHelper::importPlugin('content'); } $dispatcher = JDispatcher::getInstance(); try { $table->load($id); $name = $this->input->getCmd('view', 'cpanel'); $context = $this->option . '.' . $name; $result = $dispatcher->trigger($this->event_before_delete, array($context, $table)); if (in_array(false, $result, true)) { // Plugin failed, return false $this->setError($table->getError()); return false; } $this->_recordForDeletion = clone $table; } catch (Exception $e) { // Oops, an exception occured! $this->setError($e->getMessage()); return false; } return true; }