Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

SoftDelete: PHP5.4 Compatibility #69

Merged
merged 1 commit into from

2 participants

@davidyell

Made a few minor updates to the SoftDelete behaviour to avoid it throwing 'strict' warnings in 5.4.

Just really added type hinting and updated the comments accordingly.

@dogmatic69 dogmatic69 merged commit de878d0 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 10 deletions.
  1. +10 −10 Model/Behavior/SoftDeleteBehavior.php
View
20 Model/Behavior/SoftDeleteBehavior.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/**
* Copyright 2007-2010, Cake Development Corporation (http://cakedc.com)
*
@@ -36,10 +36,10 @@ class SoftDeleteBehavior extends ModelBehavior {
/**
* Setup callback
*
- * @param object $model
+ * @param Model $model
* @param array $settings
*/
- public function setup($model, $settings = array()) {
+ public function setup(Model $model, $settings = array()) {
if (empty($settings)) {
$settings = $this->default;
} elseif (!is_array($settings)) {
@@ -67,11 +67,11 @@ public function setup($model, $settings = array()) {
/**
* Before find callback
*
- * @param object $model
+ * @param Model $model
* @param array $query
* @return array
*/
- public function beforeFind($model, $query) {
+ public function beforeFind(Model $model, $query) {
$runtime = $this->runtime[$model->alias];
if ($runtime) {
if (!is_array($query['conditions'])) {
@@ -99,11 +99,11 @@ public function beforeFind($model, $query) {
/**
* Before delete callback
*
- * @param object $model
+ * @param Model $model
* @param array $query
* @return boolean
*/
- public function beforeDelete($model) {
+ public function beforeDelete(Model $model, $cascade = true) {
$runtime = $this->runtime[$model->alias];
if ($runtime) {
$res = $this->delete($model, $model->id);
@@ -209,7 +209,7 @@ public function softDelete($model, $active) {
public function purgeDeletedCount($model, $expiration = '-90 days') {
$this->softDelete($model, false);
return $model->find('count', array(
- 'conditions' => $this->_purgeDeletedConditions($model, $expiration),
+ 'conditions' => $this->_purgeDeletedConditions($model, $expiration),
'recursive' => -1));
}
@@ -223,8 +223,8 @@ public function purgeDeletedCount($model, $expiration = '-90 days') {
public function purgeDeleted($model, $expiration = '-90 days') {
$this->softDelete($model, false);
$records = $model->find('all', array(
- 'conditions' => $this->_purgeDeletedConditions($model, $expiration),
- 'fields' => array($model->primaryKey),
+ 'conditions' => $this->_purgeDeletedConditions($model, $expiration),
+ 'fields' => array($model->primaryKey),
'recursive' => -1));
if ($records) {
foreach ($records as $record) {
Something went wrong with that request. Please try again.