Skip to content

Commit

Permalink
Adding getter/setter for through option
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Oct 30, 2016
1 parent eb61dd8 commit 7313afb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
38 changes: 34 additions & 4 deletions src/ORM/Association/BelongsToMany.php
Expand Up @@ -960,14 +960,44 @@ function () use ($sourceEntity, $targetEntities, $options) {
/**
* {@inheritDoc}
*/
public function setConditions($conditions)
{
parent::setConditions($conditions);
$this->_targetConditions = $this->_junctionConditions = null;

return $this;
}

/**
* {@inheritDoc}
* @deprecated Use setConditions()/getConditions() instead.
*/
public function conditions($conditions = null)
{
if ($conditions !== null) {
$this->_conditions = $conditions;
$this->_targetConditions = $this->_junctionConditions = null;
$this->setConditions($conditions);
}

return $this->_conditions;
return $this->getConditions();
}

/**
* @param string|\Cake\ORM\Table $through
* @return $this
*/
public function setThrough($through)
{
$this->_through = $through;

return $this;
}

/**
* @return string|\Cake\ORM\Table
*/
public function getThrough()
{
return $this->_through;
}

/**
Expand Down Expand Up @@ -1410,7 +1440,7 @@ protected function _options(array $opts)
$this->_junctionTableName($opts['joinTable']);
}
if (!empty($opts['through'])) {
$this->_through = $opts['through'];
$this->setThrough($opts['through']);
}
if (!empty($opts['saveStrategy'])) {
$this->saveStrategy($opts['saveStrategy']);
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -4126,6 +4126,7 @@ public function testBelongsToManyFluentInterface()
->setSource($authors)
->setStrategy('select')
->setSaveStrategy('append')
->setThrough('author_articles')
->setJoinType('inner');
}

Expand Down

0 comments on commit 7313afb

Please sign in to comment.