Skip to content
Permalink
Browse files

Adding getter/setter for through option

  • Loading branch information...
dereuromark committed Oct 30, 2016
1 parent eb61dd8 commit 7313afb740d9a7ae05d55b8133c525ef584f13b2
Showing with 35 additions and 4 deletions.
  1. +34 −4 src/ORM/Association/BelongsToMany.php
  2. +1 −0 tests/TestCase/ORM/TableTest.php
@@ -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;
}
/**
@@ -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']);
@@ -4126,6 +4126,7 @@ public function testBelongsToManyFluentInterface()
->setSource($authors)
->setStrategy('select')
->setSaveStrategy('append')
->setThrough('author_articles')
->setJoinType('inner');
}

0 comments on commit 7313afb

Please sign in to comment.
You can’t perform that action at this time.