Пример #1
0
 public function destroy($extend = false)
 {
     // destroy?
     if (($success = parent::destroy()) && $extend) {
         // remove attachments
         foreach ($this->get_attached as $model) {
             foreach ($this->{$model} as $attached) {
                 $attached->detach($this);
             }
         }
         // destroy children
         foreach ($this->get_children as $model) {
             $soft = in_array($model, $this->soft_destroys);
             // soft destroy?
             foreach ($this->{$model} as $child) {
                 if ($soft) {
                     AppModel::Update($model, $child->id, array(strtolower(get_class($this)) . '_id' => null));
                 } else {
                     $child->destroy();
                 }
             }
         }
     }
     return $success;
 }