@@ -102,7 +102,7 @@ public function beforeFind(Model $model, $query) {
102102 * Check if a record exists for the given id
103103 *
104104 * @param Model $model
105- * @param id
105+ * @param $ id
106106 * @return mixed
107107 */
108108 public function existsAndNotDeleted (Model $ model , $ id ) {
@@ -126,8 +126,8 @@ public function existsAndNotDeleted(Model $model, $id) {
126126 * Before delete callback
127127 *
128128 * @param Model $model
129- * @param boolean $cascade
130- * @return boolean
129+ * @param bool $cascade
130+ * @return bool
131131 */
132132 public function beforeDelete (Model $ model , $ cascade = true ) {
133133 $ runtime = $ this ->runtime [$ model ->alias ];
@@ -144,8 +144,8 @@ public function beforeDelete(Model $model, $cascade = true) {
144144 * Mark record as deleted
145145 *
146146 * @param object $model
147- * @param integer $id
148- * @return boolean
147+ * @param int $id
148+ * @return bool
149149 */
150150 public function delete ($ model , $ id ) {
151151 $ runtime = $ this ->runtime [$ model ->alias ];
@@ -188,8 +188,8 @@ public function delete($model, $id) {
188188 * Mark record as not deleted
189189 *
190190 * @param object $model
191- * @param integer $id
192- * @return boolean
191+ * @param int $id
192+ * @return bool
193193 */
194194 public function undelete ($ model , $ id ) {
195195 $ runtime = $ this ->runtime [$ model ->alias ];
@@ -248,7 +248,7 @@ public function softDelete($model, $active) {
248248 *
249249 * @param object $model
250250 * @param mixed $expiration anything parseable by strtotime(), by default '-90 days'
251- * @return integer
251+ * @return int
252252 */
253253 public function purgeDeletedCount ($ model , $ expiration = '-90 days ' ) {
254254 $ runtime = $ this ->runtime [$ model ->alias ];
@@ -268,7 +268,7 @@ public function purgeDeletedCount($model, $expiration = '-90 days') {
268268 *
269269 * @param object $model
270270 * @param mixed $expiration anything parseable by strtotime(), by default '-90 days'
271- * @return boolean if there were some outdated records
271+ * @return bool if there were some outdated records
272272 */
273273 public function purgeDeleted ($ model , $ expiration = '-90 days ' ) {
274274 $ this ->softDelete ($ model , false );
@@ -335,6 +335,7 @@ protected function _normalizeFields($model, $settings = array()) {
335335 *
336336 * @param Model $model
337337 * @param mixed $active
338+ * @return void
338339 */
339340 protected function _softDeleteAssociations (Model $ model , $ active ) {
340341 if (empty ($ model ->belongsTo )) {
@@ -345,6 +346,13 @@ protected function _softDeleteAssociations(Model $model, $active) {
345346 $ parentModels = array_keys ($ model ->belongsTo );
346347
347348 foreach ($ parentModels as $ parentModel ) {
349+ list ($ plugin , $ modelClass ) = pluginSplit ($ parentModel , true );
350+ App::uses ($ modelClass , $ plugin . 'Model ' );
351+ if (!class_exists ($ modelClass )) {
352+ throw new MissingModelException (array ('class ' => $ modelClass ));
353+ }
354+ $ model ->{$ parentModel } = new $ parentModel (null , null , $ model ->useDbConfig );
355+
348356 foreach (array ('hasOne ' , 'hasMany ' ) as $ assocType ) {
349357 if (empty ($ model ->{$ parentModel }->{$ assocType })) {
350358 continue ;
@@ -407,4 +415,4 @@ public function softDeleteAll(Model $model, $conditions = array()) {
407415 $ this ->delete ($ model , $ result [$ model ->alias ][$ model ->primaryKey ]);
408416 }
409417 }
410- }
418+ }
0 commit comments