/** * @param string $id * @return boolean */ public function canDelete($id) { $model = StyleHelper::loadModel(); $item = $model->getTable(); $item->load($id); if (!$item->id) { throw new \RuntimeException('Outline not found', 404); } return $item->home ? false : true; }
public function delete($id) { $model = StyleHelper::loadModel(); $item = $model->getTable(); $item->load($id); if (!$item->id) { throw new \RuntimeException('Configuration not found', 404); } try { if (!$model->delete($id)) { $error = $model->getError(); // Well, Joomla can always send enqueue message instead! if (!$error) { $messages = \JFactory::getApplication()->getMessageQueue(); $message = reset($messages); $error = $message ? $message['message'] : 'Unknown error'; } throw new \RuntimeException($error); } } catch (\Exception $e) { throw new \RuntimeException('Deleting configuration failed: ' . $e->getMessage(), 400, $e); } // Remove configuration directory. $gantry = $this->container; $locator = $gantry['locator']; $path = $locator("gantry-config://{$item->id}", true, true); if ($path) { Folder::delete($path); } }