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