gyro/core/behaviour/base/commanddelegate.cls.php
Go to the documentation of this file.00001 <?php 00002 require_once dirname(__FILE__) . '/commandbase.cls.php'; 00003 00004 /** 00005 * The command delegate delegates all request to another command 00006 * 00007 * Use the command to wrap another 00008 * 00009 * @author Gerd Riesselmann 00010 * @ingroup Behaviour 00011 */ 00012 class CommandDelegate implements ICommand { 00013 /** 00014 * Commadn to delegate to 00015 * 00016 * @var ICommand 00017 */ 00018 protected $delegate; 00019 00020 public function __construct($delegate) { 00021 $this->delegate = $delegate; 00022 } 00023 00024 protected function check_delegate() { 00025 if (empty($this->delegate)) { 00026 throw new Exception('No delegate set for delegation command ' . get_class($this)); 00027 } 00028 } 00029 00030 /** 00031 * Returns title of command. 00032 */ 00033 public function get_name() { 00034 $this->check_delegate(); 00035 return $this->delegate->get_name(); 00036 } 00037 00038 /** 00039 * Returns a description of this command 00040 */ 00041 public function get_description() { 00042 $this->check_delegate(); 00043 return $this->delegate->get_description(); 00044 } 00045 00046 /** 00047 * Returns the object this actionworks upon 00048 * 00049 * @return mixed 00050 */ 00051 public function get_instance() { 00052 $this->check_delegate(); 00053 return $this->delegate->get_instance(); 00054 } 00055 00056 /** 00057 * Returns params 00058 * 00059 * @return mixed 00060 */ 00061 public function get_params() { 00062 $this->check_delegate(); 00063 return $this->delegate->get_params(); 00064 } 00065 00066 /** 00067 * Returns success message for this command 00068 */ 00069 public function get_success_message() { 00070 $this->check_delegate(); 00071 return $this->delegate->get_success_message(); 00072 } 00073 00074 /** 00075 * Return result of command 00076 * 00077 * @return mixed 00078 */ 00079 public function get_result() { 00080 $this->check_delegate(); 00081 return $this->delegate->get_result(); 00082 } 00083 00084 /** 00085 * Returns a name that has parameters build in 00086 * 00087 * @return string 00088 */ 00089 public function get_name_serialized() { 00090 $this->check_delegate(); 00091 return $this->delegate->get_name_serialized(); 00092 } 00093 00094 /** 00095 * Make this command available for text processing systems (that is: the HTML code) 00096 */ 00097 public function serialize() { 00098 $this->check_delegate(); 00099 return $this->delegate->serialize(); 00100 } 00101 00102 public function can_execute($user) { 00103 $this->check_delegate(); 00104 return $this->delegate->can_execute($user); 00105 } 00106 00107 public function execute() { 00108 $this->check_delegate(); 00109 return $this->delegate->execute(); 00110 } 00111 00112 public function undo() { 00113 $this->check_delegate(); 00114 $this->delegate->undo(); 00115 } 00116 }