original_string: public function junction($table = null)
      {
          if ($table === null && $this->_junctionTable) {
              return $this->_junctionTable;
          }
  
          $tableLocator = $this->getTableLocator();
          if ($table === null && $this->_through) {
              $table = $this->_through;
          } elseif ($table === null) {
              $tableName = $this->_junctionTableName();
              $tableAlias = Inflector::camelize($tableName);
  
              $config = [];
              if (!$tableLocator->exists($tableAlias)) {
                  $config = ['table' => $tableName];
  
                  // Propagate the connection if we'll get an auto-model
                  if (!App::className($tableAlias, 'Model/Table', 'Table')) {
                      $config['connection'] = $this->getSource()->getConnection();
                  }
              }
              $table = $tableLocator->get($tableAlias, $config);
          }
  
          if (is_string($table)) {
              $table = $tableLocator->get($table);
          }
          $source = $this->getSource();
          $target = $this->getTarget();
  
          $this->_generateSourceAssociations($table, $source);
          $this->_generateTargetAssociations($table, $source, $target);
          $this->_generateJunctionAssociations($table, $source, $target);
  
          return $this->_junctionTable = $table;
      }
code: public function junction($table = null)
      {
          if ($table === null && $this->_junctionTable) {
              return $this->_junctionTable;
          }
  
          $tableLocator = $this->getTableLocator();
          if ($table === null && $this->_through) {
              $table = $this->_through;
          } elseif ($table === null) {
              $tableName = $this->_junctionTableName();
              $tableAlias = Inflector::camelize($tableName);
  
              $config = [];
              if (!$tableLocator->exists($tableAlias)) {
                  $config = ['table' => $tableName];
  
                  // Propagate the connection if we'll get an auto-model
                  if (!App::className($tableAlias, 'Model/Table', 'Table')) {
                      $config['connection'] = $this->getSource()->getConnection();
                  }
              }
              $table = $tableLocator->get($tableAlias, $config);
          }
  
          if (is_string($table)) {
              $table = $tableLocator->get($table);
          }
          $source = $this->getSource();
          $target = $this->getTarget();
  
          $this->_generateSourceAssociations($table, $source);
          $this->_generateTargetAssociations($table, $source, $target);
          $this->_generateJunctionAssociations($table, $source, $target);
  
          return $this->_junctionTable = $table;
      }
code_tokens: public function junction ( $ table = null ) { if ( $ table === null && $ this -> _junctionTable ) { return $ this -> _junctionTable ; } $ tableLocator = $ this -> getTableLocator ( ) ; if ( $ table === null && $ this -> _through ) { $ table = $ this -> _through ; } elseif ( $ table === null ) { $ tableName = $ this -> _junctionTableName ( ) ; $ tableAlias = Inflector :: camelize ( $ tableName ) ; $ config = [ ] ; if ( ! $ tableLocator -> exists ( $ tableAlias ) ) { $ config = [ 'table' => $ tableName ] ; // Propagate the connection if we'll get an auto-model if ( ! App :: className ( $ tableAlias , 'Model/Table' , 'Table' ) ) { $ config [ 'connection' ] = $ this -> getSource ( ) -> getConnection ( ) ; } } $ table = $ tableLocator -> get ( $ tableAlias , $ config ) ; } if ( is_string ( $ table ) ) { $ table = $ tableLocator -> get ( $ table ) ; } $ source = $ this -> getSource ( ) ; $ target = $ this -> getTarget ( ) ; $ this -> _generateSourceAssociations ( $ table , $ source ) ; $ this -> _generateTargetAssociations ( $ table , $ source , $ target ) ; $ this -> _generateJunctionAssociations ( $ table , $ source , $ target ) ; return $ this -> _junctionTable = $ table ; }
docstring: Sets the table instance for the junction relation. If no arguments
  are passed, the current configured table instance is returned
  
  @param string|\Cake\ORM\Table|null $table Name or instance for the join table
  @return \Cake\ORM\Table
docstring_tokens: Sets the table instance for the junction relation . If no arguments are passed the current configured table instance is returned