Skip to content

Commit

Permalink
Refactoring canBeJoined so it is more dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 31, 2014
1 parent 7fd9bbf commit beef973
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
10 changes: 2 additions & 8 deletions src/ORM/Association.php
Expand Up @@ -79,13 +79,6 @@ abstract class Association {
*/
protected $_name;

/**
* Whether this association can be expressed directly in a query join
*
* @var boolean
*/
protected $_canBeJoined = false;

/**
* The class name of the target table object
*
Expand Down Expand Up @@ -302,7 +295,8 @@ public function dependent($dependent = null) {
* @return boolean
*/
public function canBeJoined($options = []) {
return $this->_canBeJoined;
$strategy = isset($options['strategy']) ? $options['strategy'] : $this->strategy();
return $strategy == $this::STRATEGY_JOIN;
}

/**
Expand Down
7 changes: 0 additions & 7 deletions src/ORM/Association/BelongsTo.php
Expand Up @@ -28,13 +28,6 @@
*/
class BelongsTo extends Association {

/**
* Whether this association can be expressed directly in a query join
*
* @var boolean
*/
protected $_canBeJoined = true;

/**
* Sets the name of the field representing the foreign key to the target table.
* If no parameters are passed current field is returned
Expand Down
7 changes: 0 additions & 7 deletions src/ORM/Association/HasOne.php
Expand Up @@ -31,13 +31,6 @@ class HasOne extends Association {

use DependentDeleteTrait;

/**
* Whether this association can be expressed directly in a query join
*
* @var boolean
*/
protected $_canBeJoined = true;

/**
* The type of join to be used when adding the association to a query
*
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -117,7 +117,7 @@ public function testConditions() {
* @return void
*/
public function testCanBeJoined() {
$this->assertFalse($this->association->canBeJoined());
$this->assertTrue($this->association->canBeJoined());
}

/**
Expand Down

0 comments on commit beef973

Please sign in to comment.