Skip to content

Commit

Permalink
Removing setters for prperties in EagerLoadable, fixing indentation
Browse files Browse the repository at this point in the history
Also removed a parameter in a function that is not used anymore
  • Loading branch information
lorenzo committed Jan 15, 2015
1 parent 0d511f2 commit 6f46952
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 48 deletions.
52 changes: 12 additions & 40 deletions src/ORM/EagerLoadable.php
Expand Up @@ -137,56 +137,35 @@ public function associations()
}

/**
* Sets the Association class instance to use for loading the records.
* Gets the Association class instance to use for loading the records.
*
* If called with no arguments it returns the current
* value.
*
* @param \Cake\ORM\Association|null $instance The value to set.
* @return \Cake\ORM\Association|null
*/
public function instance($instance = null)
public function instance()
{
if ($instance === null) {
return $this->_instance;
}
$this->_instance = $instance;
return $this->_instance;
}

/**
* Sets a dotted separated string representing the path of associations
* Gets a dotted separated string representing the path of associations
* that should be followed to fetch this level.
*
* If called with no arguments it returns the current
* value.
*
* @param string|null $path The value to set.
* @return string|null
*/
public function aliasPath($path = null)
public function aliasPath()
{
if ($path === null) {
return $this->_aliasPath;
}
$this->_aliasPath = $path;
return $this->_aliasPath;
}

/**
* Sets a dotted separated string representing the path of entity properties
* Gets a dotted separated string representing the path of entity properties
* in which results for this level should be placed.
*
* If called with no arguments it returns the current
* value.
*
* @param string|null $path The value to set.
* @return string|null
*/
public function propertyPath($path = null)
public function propertyPath()
{
if ($path === null) {
return $this->_propertyPath;
}
$this->_propertyPath = $path;
return $this->_propertyPath;
}

/**
Expand Down Expand Up @@ -225,21 +204,14 @@ public function config(array $config = null)
}

/**
* Sets weather or not this level was meant for a
* Gets weather or not this level was meant for a
* "matching" fetch operation.
*
* If called with no arguments it returns the current
* value.
*
* @param bool|null $matching The value to set.
* @return bool|null
*/
public function forMatching($matching = null)
public function forMatching()
{
if ($matching === null) {
return $this->_forMatching;
}
$this->_forMatching = $matching;
return $this->_forMatching;
}

/**
Expand Down
11 changes: 5 additions & 6 deletions src/ORM/EagerLoader.php
Expand Up @@ -404,13 +404,13 @@ protected function _normalizeContain(Table $parent, $alias, $options, $paths)
protected function _fixStrategies()
{
foreach ($this->_aliasList as $aliases) {
foreach ($aliases as $alias => $configs) {
foreach ($aliases as $configs) {
if (count($configs) < 2) {
continue;
}
foreach ($configs as $loadable) {
if (strpos($loadable->aliasPath(), '.')) {
$this->_correctStrategy($loadable, $alias);
$this->_correctStrategy($loadable);
}
}
}
Expand All @@ -421,11 +421,10 @@ protected function _fixStrategies()
* Changes the association fetching strategy if required because of duplicate
* under the same direct associations chain
*
* @param \Cake\ORM\EagerLoader $loadable The association config
* @param string $alias the name of the association to evaluate
* @param \Cake\ORM\EagerLoadable $loadable The association config
* @return void
*/
protected function _correctStrategy($loadable, $alias)
protected function _correctStrategy($loadable)
{
$config = $loadable->config();
$currentStrategy = isset($config['strategy']) ?
Expand Down Expand Up @@ -465,7 +464,7 @@ protected function _resolveJoins($associations, $matching = [])
}

if ($inMatching) {
$this->_correctStrategy($loadable, $table);
$this->_correctStrategy($loadable);
}

$loadable->canBeJoined(false);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -691,8 +691,8 @@ public function testFindMatchingOverwrite2()
->matching('Articles.Tags', function ($q) {
return $q->where(['Tags.id' => 2]);
})
->contain('Articles.Authors')
->first();
->contain('Articles.Authors')
->first();

$this->assertNotNull($result->article->author);
}
Expand Down

0 comments on commit 6f46952

Please sign in to comment.