Browse Source

Merge pull request #4338 from robertpustulka/3.0-cascade-callbacks

3.0 accessible cascadeCallbacks in Association
Mark Story 11 years ago
parent
commit
6ce18474dc
2 changed files with 25 additions and 0 deletions
  1. 14 0
      src/ORM/Association.php
  2. 11 0
      tests/TestCase/ORM/AssociationTest.php

+ 14 - 0
src/ORM/Association.php

@@ -210,6 +210,20 @@ abstract class Association {
 	}
 
 /**
+ * Sets whether or not cascaded deletes should also fire callbacks. If no
+ * arguments are passed, the current configured value is returned
+ *
+ * @param bool $cascadeCallbacks cascade callbacks switch value
+ * @return bool
+ */
+	public function cascadeCallbacks($cascadeCallbacks = null) {
+		if ($cascadeCallbacks !== null) {
+			$this->_cascadeCallbacks = $cascadeCallbacks;
+		}
+		return $this->_cascadeCallbacks;
+	}
+
+/**
  * Sets the table instance for the source side of the association. If no arguments
  * are passed, the current configured table instance is returned
  *

+ 11 - 0
tests/TestCase/ORM/AssociationTest.php

@@ -92,6 +92,17 @@ class AssociationTest extends \Cake\TestSuite\TestCase {
 	}
 
 /**
+ * Tests that cascadeCallbacks() returns the correct configured value
+ *
+ * @return void
+ */
+	public function testCascadeCallbacks() {
+		$this->assertSame(false, $this->association->cascadeCallbacks());
+		$this->association->cascadeCallbacks(true);
+		$this->assertSame(true, $this->association->cascadeCallbacks());
+	}
+
+/**
  * Tests that name() returns the correct configured value
  *
  * @return void