src/FieldHandlers/RelatedFieldTrait.php
protected function _getRelatedParentProperties(array $relatedProperties) : array
    {
        if (empty($relatedProperties['entity']) ||
            empty($relatedProperties['controller']) ||
            empty($relatedProperties['config']['parent']['module'])
        ) {
            return [];
        }

        $foreignKey = $this->_getForeignKey(
            TableRegistry::get($relatedProperties['config']['parent']['module']),
            empty($relatedProperties['plugin']) ?
                $relatedProperties['controller'] :
                sprintf('%s.%s', $relatedProperties['plugin'], $relatedProperties['controller'])
        );

        if ('' === $foreignKey) {
            return [];
        }

        if (empty($relatedProperties['entity']->get($foreignKey))) {
            return [];
        }

        $result = $this->_getRelatedProperties(
            $relatedProperties['config']['parent']['module'],
            $relatedProperties['entity']->get($foreignKey)
        );

        if (null === $result['entity']) {
            return [];
        }

        return $result;
    }
protected function _getRelatedParentProperties(array $relatedProperties) : array
    {
        if (empty($relatedProperties['entity']) ||
            empty($relatedProperties['controller']) ||
            empty($relatedProperties['config']['parent']['module'])
        ) {
            return [];
        }

        $foreignKey = $this->_getForeignKey(
            TableRegistry::get($relatedProperties['config']['parent']['module']),
            empty($relatedProperties['plugin']) ?
                $relatedProperties['controller'] :
                sprintf('%s.%s', $relatedProperties['plugin'], $relatedProperties['controller'])
        );

        if ('' === $foreignKey) {
            return [];
        }

        if (empty($relatedProperties['entity']->get($foreignKey))) {
            return [];
        }

        $result = $this->_getRelatedProperties(
            $relatedProperties['config']['parent']['module'],
            $relatedProperties['entity']->get($foreignKey)
        );

        if (null === $result['entity']) {
            return [];
        }

        return $result;
    }
protected function _getRelatedParentProperties ( array $ relatedProperties ) : array { if ( empty ( $ relatedProperties [ 'entity' ] ) || empty ( $ relatedProperties [ 'controller' ] ) || empty ( $ relatedProperties [ 'config' ] [ 'parent' ] [ 'module' ] ) ) { return [ ] ; } $ foreignKey = $ this -> _getForeignKey ( TableRegistry :: get ( $ relatedProperties [ 'config' ] [ 'parent' ] [ 'module' ] ) , empty ( $ relatedProperties [ 'plugin' ] ) ? $ relatedProperties [ 'controller' ] : sprintf ( '%s.%s' , $ relatedProperties [ 'plugin' ] , $ relatedProperties [ 'controller' ] ) ) ; if ( '' === $ foreignKey ) { return [ ] ; } if ( empty ( $ relatedProperties [ 'entity' ] -> get ( $ foreignKey ) ) ) { return [ ] ; } $ result = $ this -> _getRelatedProperties ( $ relatedProperties [ 'config' ] [ 'parent' ] [ 'module' ] , $ relatedProperties [ 'entity' ] -> get ( $ foreignKey ) ) ; if ( null === $ result [ 'entity' ] ) { return [ ] ; } return $ result ; }
Get related model's parent model properties.

@param mixed[] $relatedProperties related model properties
@return mixed[] $result containing parent properties
Get related model s parent model properties .