public function getTarget()
    {
        if (!$this->_targetTable) {
            if (strpos($this->_className, '.')) {
                list($plugin) = pluginSplit($this->_className, true);
                $registryAlias = $plugin . $this->_name;
            } else {
                $registryAlias = $this->_name;
            }

            $tableLocator = $this->getTableLocator();

            $config = [];
            $exists = $tableLocator->exists($registryAlias);
            if (!$exists) {
                $config = ['className' => $this->_className];
            }
            $this->_targetTable = $tableLocator->get($registryAlias, $config);

            if ($exists) {
                $className = $this->_getClassName($registryAlias, ['className' => $this->_className]);

                if (!$this->_targetTable instanceof $className) {
                    $errorMessage = '%s association "%s" of type "%s" to "%s" doesn\'t match the expected class "%s". ';
                    $errorMessage .= 'You can\'t have an association of the same name with a different target "className" option anywhere in your app.';

                    throw new RuntimeException(sprintf(
                        $errorMessage,
                        $this->_sourceTable ? get_class($this->_sourceTable) : 'null',
                        $this->getName(),
                        $this->type(),
                        $this->_targetTable ? get_class($this->_targetTable) : 'null',
                        $className
                    ));
                }
            }
        }

        return $this->_targetTable;
    }
public function getTarget()
    {
        if (!$this->_targetTable) {
            if (strpos($this->_className, '.')) {
                list($plugin) = pluginSplit($this->_className, true);
                $registryAlias = $plugin . $this->_name;
            } else {
                $registryAlias = $this->_name;
            }

            $tableLocator = $this->getTableLocator();

            $config = [];
            $exists = $tableLocator->exists($registryAlias);
            if (!$exists) {
                $config = ['className' => $this->_className];
            }
            $this->_targetTable = $tableLocator->get($registryAlias, $config);

            if ($exists) {
                $className = $this->_getClassName($registryAlias, ['className' => $this->_className]);

                if (!$this->_targetTable instanceof $className) {
                    $errorMessage = '%s association "%s" of type "%s" to "%s" doesn\'t match the expected class "%s". ';
                    $errorMessage .= 'You can\'t have an association of the same name with a different target "className" option anywhere in your app.';

                    throw new RuntimeException(sprintf(
                        $errorMessage,
                        $this->_sourceTable ? get_class($this->_sourceTable) : 'null',
                        $this->getName(),
                        $this->type(),
                        $this->_targetTable ? get_class($this->_targetTable) : 'null',
                        $className
                    ));
                }
            }
        }

        return $this->_targetTable;
    }
public function getTarget ( ) { if ( ! $ this -> _targetTable ) { if ( strpos ( $ this -> _className , '.' ) ) { list ( $ plugin ) = pluginSplit ( $ this -> _className , true ) ; $ registryAlias = $ plugin . $ this -> _name ; } else { $ registryAlias = $ this -> _name ; } $ tableLocator = $ this -> getTableLocator ( ) ; $ config = [ ] ; $ exists = $ tableLocator -> exists ( $ registryAlias ) ; if ( ! $ exists ) { $ config = [ 'className' => $ this -> _className ] ; } $ this -> _targetTable = $ tableLocator -> get ( $ registryAlias , $ config ) ; if ( $ exists ) { $ className = $ this -> _getClassName ( $ registryAlias , [ 'className' => $ this -> _className ] ) ; if ( ! $ this -> _targetTable instanceof $ className ) { $ errorMessage = '%s association "%s" of type "%s" to "%s" doesn\'t match the expected class "%s". ' ; $ errorMessage .= 'You can\'t have an association of the same name with a different target "className" option anywhere in your app.' ; throw new RuntimeException ( sprintf ( $ errorMessage , $ this -> _sourceTable ? get_class ( $ this -> _sourceTable ) : 'null' , $ this -> getName ( ) , $ this -> type ( ) , $ this -> _targetTable ? get_class ( $ this -> _targetTable ) : 'null' , $ className ) ) ; } } } return $ this -> _targetTable ; }
Gets the table instance for the target side of the association.

@return \Cake\ORM\Table
Gets the table instance for the target side of the association .