| | 284 | |
|---|
| | 285 | function ___afterDestroy(&$object) |
|---|
| | 286 | { |
|---|
| | 287 | $success = true; |
|---|
| | 288 | $associated_ids = $object->getAssociatedIds(); |
|---|
| | 289 | foreach ($associated_ids as $associated_id){ |
|---|
| | 290 | if( isset($object->$associated_id->_associatedAs) && |
|---|
| | 291 | $object->$associated_id->_associatedAs == 'belongsTo' && |
|---|
| | 292 | $object->$associated_id->getAssociationOption('dependent')){ |
|---|
| | 293 | if ($object->$associated_id->getType() == 'belongsTo'){ |
|---|
| | 294 | $object->$associated_id->load(); |
|---|
| | 295 | } |
|---|
| | 296 | if(method_exists($object->$associated_id, 'destroy')){ |
|---|
| | 297 | $success = $object->$associated_id->destroy() ? $success : false; |
|---|
| | 298 | } |
|---|
| | 299 | } |
|---|
| | 300 | } |
|---|
| | 301 | return $success; |
|---|
| | 302 | } |
|---|
| | 303 | |
|---|
| | 304 | |
|---|