gyro/core/behaviour/commands/generics/delete.cmd.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Delete command 00004 * 00005 * @author Gerd Riesselmann 00006 * @ingroup Behaviour 00007 */ 00008 class DeleteCommand extends CommandTransactional { 00009 /** 00010 * Executes commands 00011 * 00012 * @return Status 00013 */ 00014 protected function do_execute() { 00015 $ret = new Status(); 00016 $o = $this->get_instance(); 00017 if ($o) { 00018 $ret->merge($o->delete()); 00019 $this->set_result($o); 00020 if ($ret->is_ok()) { 00021 $this->clear_history($o); 00022 } 00023 } 00024 else { 00025 $ret->append(tr('Delete Command: No instance set to delete', 'core')); 00026 } 00027 return $ret; 00028 } 00029 00030 /** 00031 * Clear history 00032 * 00033 * @param IActionSource $deleted_instance 00034 */ 00035 protected function clear_history(IActionSource $deleted_instance) { 00036 $actions = $deleted_instance->get_actions(AccessControl::get_current_aro(), ''); 00037 foreach($actions as $action) { 00038 if ($action instanceof IAction) { 00039 /* @var $action IAction */ 00040 $url = ActionMapper::get_url($action->get_name(), $deleted_instance); 00041 History::remove($url); 00042 } 00043 } 00044 } 00045 00046 /** 00047 * Returns title of command. 00048 */ 00049 public function get_name() { 00050 return 'delete'; 00051 } 00052 00053 /** 00054 * Returns a description of this command 00055 */ 00056 public function get_description() { 00057 $ret = ''; 00058 $inst = $this->get_instance(); 00059 if ($inst) { 00060 $ret = tr( 00061 'Delete', 00062 'app' 00063 ); 00064 } 00065 return $ret; 00066 } 00067 00068 }