Permalink
Browse files

Suppose you have a component that 'listen' for some named param and i…

…f received you need to add a binding to the next model find call, through containable, and later, in the controller you also need to do other bindings to the same next model find call, but respecting the previous component binding. As contain() have multiple parameters (func_get_args()) we need to create other method, i think this one can be good.

Hope it helps. Please review the documentation because my english it's not soo good.
  • Loading branch information...
1 parent 8671aa3 commit 92f08692bbe5fd66bec1df70e0222093319a8ab6 @adael adael committed Jun 3, 2011
Showing with 18 additions and 0 deletions.
  1. +18 −0 cake/libs/model/behaviors/containable.php
@@ -253,6 +253,24 @@ function contain(&$Model) {
}
/**
+ * Add the specified relations to the next find call.
+ * Unbinds all relations from a model except the specified ones. Calling this function without
+ * parameters unbinds all related models.
+ *
+ * @param object $Model Model on which binding restriction is being applied
+ * @return void
+ * @access public
+ */
+ function containAdd(&$Model) {
+ $args = func_get_args();
+ $contain = call_user_func_array('am', array_slice($args, 1));
+ if(!isset($this->runtime[$Model->alias]['contain']) || !is_array($this->runtime[$Model->alias]['contain'])){
+ $this->runtime[$Model->alias]['contain'] = array();
+ }
+ $this->runtime[$Model->alias]['contain'] += $contain;
+ }
+
+/**
* Permanently restore the original binding settings of given model, useful
* for restoring the bindings after using 'reset' => false as part of the
* contain call.

0 comments on commit 92f0869

Please sign in to comment.