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);
    }
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);
    }
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 ) ; }
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
Returns association object for all versions or single field version .