Skip to content

Commit

Permalink
Update Query::$primary and Query::primary() names.
Browse files Browse the repository at this point in the history
To Query::eagerLoaded and Query::eagerLoaded(), respectively. To reflect
the real purpose of the variable/function.
  • Loading branch information
bar committed Mar 15, 2014
1 parent d1c67fe commit ed11b09
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Datasource/QueryTrait.php
Expand Up @@ -185,7 +185,7 @@ public function all() {
}

$table = $this->repository();
$event = new Event('Model.beforeFind', $table, [$this, $this->_options, $this->primary()]);
$event = new Event('Model.beforeFind', $table, [$this, $this->_options, $this->eagerLoaded()]);
$table->getEventManager()->dispatch($event);

if (isset($this->_results)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association.php
Expand Up @@ -418,7 +418,7 @@ public function attachTo(Query $query, array $options = []) {
}

$options['conditions'] = $query->newExpr()->add($options['conditions']);
$dummy = $target->query()->primary(false);
$dummy = $target->query()->eagerLoaded(false);

if (!empty($options['queryBuilder'])) {
$dummy = $options['queryBuilder']($dummy);
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association/ExternalAssociationTrait.php
Expand Up @@ -228,7 +228,7 @@ protected function _buildQuery($options) {
$fetchQuery = $this
->find('all')
->where($options['conditions'])
->primary(false)
->eagerLoaded(false)
->hydrate($options['query']->hydrate());
$fetchQuery = $this->_addFilteringCondition($fetchQuery, $key, $filter);

Expand Down
12 changes: 6 additions & 6 deletions src/ORM/Query.php
Expand Up @@ -100,7 +100,7 @@ class Query extends DatabaseQuery {
*
* @var boolean
*/
protected $_primary = true;
protected $_eagerLoaded = true;

/**
* Constuctor
Expand Down Expand Up @@ -654,17 +654,17 @@ protected function _dirty() {
}

/**
* Sets the query instance to be the primary query. If no argument is passed,
* the current configured query `_primary` value is returned.
* Sets the query instance to be the eager loaded query. If no argument is
* passed, the current configured query `_eagerLoaded` value is returned.
*
* @param boolean $value
* @return \Cake\ORM\Query
*/
public function primary($value = null) {
public function eagerLoaded($value = null) {
if ($value === null) {
return $this->_primary;
return $this->_eagerLoaded;
}
$this->_primary = $value;
$this->_eagerLoaded = $value;
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Table.php
Expand Up @@ -73,7 +73,7 @@
* Table objects provide a few callbacks/events you can hook into to augment/replace
* find operations. Each event uses the standard event subsystem in CakePHP
*
* - `beforeFind($event, $query, $options, $primary)` - Fired before each find operation.
* - `beforeFind($event, $query, $options, $eagerLoaded)` - Fired before each find operation.
* By stopping the event and supplying a return value you can bypass the find operation
* entirely. Any changes done to the $query instance will be retained for the rest of the find.
* - `beforeValidate($event, $entity, $options, $validator)` - Fired before an entity is validated.
Expand Down

0 comments on commit ed11b09

Please sign in to comment.