Esempio n. 1
0
 public function executeDelete()
 {
     $instance = InstancePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($instance);
     $ref_error = 0;
     foreach ($instance->getRefCountMethods() as $ref) {
         $method = "count" . $ref['affix'];
         $count = $instance->{$method}();
         if ($count > 0) {
             ++$ref_error;
             $this->getRequest()->setError('instance/delete/' . sfInflector::camelize($ref['table']), $count);
         }
     }
     if ($ref_error > 0) {
         $this->getRequest()->setError('instance/delete', '_ERR_DELETE_ (' . $instance->toString() . ' - id:' . $instance->getId() . ')');
     } else {
         $instance->delete();
     }
     return $this->forward('instance', 'list');
 }