Skip to content
Permalink
Browse files

Renaming pivot -> junction

  • Loading branch information...
lorenzo committed Dec 4, 2013
1 parent 15ed285 commit b20150e025a2df5f888802c253b44db465a3e988
Showing with 8 additions and 8 deletions.
  1. +6 −6 Cake/ORM/Association/BelongsToMany.php
  2. +2 −2 Cake/Test/TestCase/ORM/TableTest.php
@@ -346,20 +346,20 @@ protected function _saveTarget(Entity $parentEntity, $entities, $options) {
* @param \Cake\ORM\Entity $sourceEntity the entity from source table in this
* association
* @param array list of entities to link to link to the source entity using the
* pivot table
* junction table
* @return boolean success
*/
protected function _saveLinks(Entity $sourceEntity, $targetEntities, $options) {
$target = $this->target();
$pivot = $this->pivot();
$junction = $this->junction();
$source = $this->source();
$entityClass = $pivot->entityClass();
$belongsTo = $pivot->association($target->alias());
$entityClass = $junction->entityClass();
$belongsTo = $junction->association($target->alias());
$foreignKey = (array)$this->foreignKey();
$assocForeignKey = (array)$belongsTo->foreignKey();
$targetPrimaryKey = (array)$target->primaryKey();
$sourcePrimaryKey = (array)$source->primaryKey();
$jointProperty = $target->association($pivot->alias())->property();
$jointProperty = $target->association($junction->alias())->property();
foreach ($targetEntities as $k => $e) {
$joint = $e->get($jointProperty);
@@ -373,7 +373,7 @@ protected function _saveLinks(Entity $sourceEntity, $targetEntities, $options) {
$sourceEntity->extract($sourcePrimaryKey)
));
$joint->set(array_combine($assocForeignKey, $e->extract($targetPrimaryKey)));
$saved = $pivot->save($joint, $options);
$saved = $junction->save($joint, $options);
if (!$saved && !empty($options['atomic'])) {
return false;
@@ -2557,7 +2557,7 @@ public function testSaveBelongsToWithValidationErrorInJointEntity() {
$table = TableRegistry::get('articles');
$table->belongsToMany('tags');
$table->association('tags')
->pivot()
->junction()
->validator()
->add('article_id', 'num', ['rule' => ['comparison', '>', 4]]);
@@ -2595,7 +2595,7 @@ public function testSaveBelongsToWithValidationErrorInJointEntityNonAtomic() {
$table = TableRegistry::get('articles');
$table->belongsToMany('tags');
$table->association('tags')
->pivot()
->junction()
->validator()
->add('tag_id', 'num', ['rule' => ['comparison', '>', 4]]);

0 comments on commit b20150e

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