00001 <?php
00002 
00003 
00004 
00005 
00006 
00007   
00008 class CreateCommand extends CommandTransactional  {
00009 
00010 
00011 
00012 
00013 
00014         protected function do_execute() {
00015                 $ret = new Status();
00016                 $inst = DB::create($this->get_instance());
00017                 if ($inst) {
00018                         $inst->set_default_values();
00019                         $inst->read_from_array($this->get_params());
00020                         $ret->merge($inst->validate());
00021                         if ($ret->is_ok()) {
00022                                 $ret->merge($inst->insert());
00023                                 $this->set_result($inst);               
00024                         }
00025                 }
00026                 else {
00027                         $ret->append(tr('Unknown model %s', 'core', array('%s' => $this->get_instance())));
00028                 }
00029                 
00030                 return $ret;
00031         }
00032 
00033 
00034 
00035 
00036         public function get_name() {
00037                 return 'create';
00038         }
00039         
00040 
00041 
00042 
00043         public function get_description() {
00044                 $ret = '';
00045                 $ret = tr(
00046                         'Create new %type',
00047                         'app',
00048                         array('%type' => $this->get_instance())
00049                 );
00050                 return $ret;
00051         }
00052         
00053 }