public function cut($blnDoNotRedirect = false)
{
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['notSortable']) {
throw new InternalServerErrorException('Table "' . $this->strTable . '" is not sortable.');
}
$cr = array();
// ID and PID are mandatory
if (!$this->intId || !strlen(\Input::get('pid'))) {
$this->redirect($this->getReferer());
}
// Get the new position
$this->getNewPosition('cut', \Input::get('pid'), \Input::get('mode') == '2' ? true : false);
// Avoid circular references when there is no parent table
if ($this->Database->fieldExists('pid', $this->strTable) && !strlen($this->ptable)) {
$cr = $this->Database->getChildRecords($this->intId, $this->strTable);
$cr[] = $this->intId;
}
/** @var SessionInterface $objSession */
$objSession = \System::getContainer()->get('session');
// Empty clipboard
$arrClipboard = $objSession->get('CLIPBOARD');
$arrClipboard[$this->strTable] = array();
$objSession->set('CLIPBOARD', $arrClipboard);
// Check for circular references
if (in_array($this->set['pid'], $cr)) {
throw new InternalServerErrorException('Attempt to relate record ' . $this->intId . ' of table "' . $this->strTable . '" to its child record ' . \Input::get('pid') . ' (circular reference).');
}
$this->set['tstamp'] = time();
// HOOK: style sheet category
if ($this->strTable == 'tl_style') {
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = $objSession->getBag('contao_backend');
$filter = $objSessionBag->get('filter');
$category = $filter['tl_style_' . CURRENT_ID]['category'];
if ($category != '') {
$this->set['category'] = $category;
}
}
// Dynamically set the parent table of tl_content
if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dynamicPtable']) {
$this->set['ptable'] = $this->ptable;
}
$this->Database->prepare("UPDATE " . $this->strTable . " %s WHERE id=?")->set($this->set)->execute($this->intId);
// Call the oncut_callback
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['oncut_callback'])) {
foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['oncut_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($this);
} elseif (is_callable($callback)) {
$callback($this);
}
}
}
if (!$blnDoNotRedirect) {
$this->redirect($this->getReferer());
}
}