Admin Controller

This method removes an item.

  • return - void
public function delete()
{
// Check for request forgeries
$this->checkToken();

// Get items to remove from the request.
$cid = $this->input->get('cid', array(), 'array');

if (!is_array($cid) || count($cid) < 1)
{
\JLog::add(\JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), \JLog::WARNING, 'jerror');
}
else
{
// Get the model.
$model = $this->getModel();

// Make sure the item ids are integers
$cid = ArrayHelper::toInteger($cid);

// Remove the items.
if ($model->delete($cid))
{
$this->setMessage(\JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
}
else
{
$this->setMessage($model->getError(), 'error');
}

// Invoke the postDelete method to allow for the child class to access the model.
$this->postDeleteHook($model, $cid);
}

$this->setRedirect(\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}