original_string: public function versionAssociation($field = null, $options = [])
      {
          $name = $this->_associationName($field);
  
          if (!$this->_table->associations()->has($name)) {
              $model = $this->_config['referenceName'];
  
              $options += [
                  'className' => $this->_config['versionTable'],
                  'foreignKey' => $this->_config['foreignKey'],
                  'strategy' => 'subquery',
                  'dependent' => true
              ];
  
              if ($field) {
                  $options += [
                      'conditions' => [
                          $name . '.model' => $model,
                          $name . '.field' => $field,
                      ],
                      'propertyName' => $field . '_version'
                  ];
              } else {
                  $options += [
                      'conditions' => [
                          $name . '.model' => $model
                      ],
                      'propertyName' => '__version'
                  ];
              }
  
              $this->_table->hasMany($name, $options);
          }
  
          return $this->_table->getAssociation($name);
      }
code: public function versionAssociation($field = null, $options = [])
      {
          $name = $this->_associationName($field);
  
          if (!$this->_table->associations()->has($name)) {
              $model = $this->_config['referenceName'];
  
              $options += [
                  'className' => $this->_config['versionTable'],
                  'foreignKey' => $this->_config['foreignKey'],
                  'strategy' => 'subquery',
                  'dependent' => true
              ];
  
              if ($field) {
                  $options += [
                      'conditions' => [
                          $name . '.model' => $model,
                          $name . '.field' => $field,
                      ],
                      'propertyName' => $field . '_version'
                  ];
              } else {
                  $options += [
                      'conditions' => [
                          $name . '.model' => $model
                      ],
                      'propertyName' => '__version'
                  ];
              }
  
              $this->_table->hasMany($name, $options);
          }
  
          return $this->_table->getAssociation($name);
      }
code_tokens: public function versionAssociation ( $ field = null , $ options = [ ] ) { $ name = $ this -> _associationName ( $ field ) ; if ( ! $ this -> _table -> associations ( ) -> has ( $ name ) ) { $ model = $ this -> _config [ 'referenceName' ] ; $ options += [ 'className' => $ this -> _config [ 'versionTable' ] , 'foreignKey' => $ this -> _config [ 'foreignKey' ] , 'strategy' => 'subquery' , 'dependent' => true ] ; if ( $ field ) { $ options += [ 'conditions' => [ $ name . '.model' => $ model , $ name . '.field' => $ field , ] , 'propertyName' => $ field . '_version' ] ; } else { $ options += [ 'conditions' => [ $ name . '.model' => $ model ] , 'propertyName' => '__version' ] ; } $ this -> _table -> hasMany ( $ name , $ options ) ; } return $ this -> _table -> getAssociation ( $ name ) ; }
docstring: Returns association object for all versions or single field version.
  
  @param string|null $field Field name for per-field association.
  @param array $options Association options.
  @return \Cake\ORM\Association
docstring_tokens: Returns association object for all versions or single field version .