protected function _primaryDataMayHaveRelationships()
    {
        $path = $this->_getPathObject('data.relationships');

        if (!$this->_hasProperty($path)) {
            return true;
        }

        $relationships = $this->_getProperty($path->dotted);

        if (empty($relationships)) {
            $this->_errorCollection->addRelationshipsError(
                $title = '_required',
                $detail = "Relationships object does not contain any members",
                $status = null,
                $idx = null,
                $aboutLink = $this->_getAboutLink('http://jsonapi.org/format/#crud-creating')
            );

            return false;
        }

        foreach ($relationships as $relationship => $data) {
            $relationshipPathObject = $this->_getPathObject($path->dotted . '.' . $relationship);

            if (!$this->_relationshipMustHaveData($relationshipPathObject)) {
                continue;
            }

            if ($this->_relationshipDataIsNull($relationshipPathObject)) {
                continue;
            }

            // single belongsTo relationship
            if ($this->_stringIsSingular($relationshipPathObject->key)) {
                $this->_relationshipDataMustHaveType($relationship, $relationshipPathObject);
                $this->_relationshipDataMustHaveId($relationship, $relationshipPathObject);

                continue;
            }

            // multiple hasMany relationships
            $hasManys = $this->_getProperty($relationshipPathObject->dotted . '.data');

            $i = 0;
            foreach ($hasManys as $hasMany) {
                $pathObject = $this->_getPathObject($relationshipPathObject->dotted . '.data.' . $i);

                $this->_relationshipDataMustHaveType($relationship, $pathObject);
                $this->_relationshipDataMustHaveId($relationship, $pathObject);

                $i++;
            }
        }

        return true;
    }
protected function _primaryDataMayHaveRelationships()
    {
        $path = $this->_getPathObject('data.relationships');

        if (!$this->_hasProperty($path)) {
            return true;
        }

        $relationships = $this->_getProperty($path->dotted);

        if (empty($relationships)) {
            $this->_errorCollection->addRelationshipsError(
                $title = '_required',
                $detail = "Relationships object does not contain any members",
                $status = null,
                $idx = null,
                $aboutLink = $this->_getAboutLink('http://jsonapi.org/format/#crud-creating')
            );

            return false;
        }

        foreach ($relationships as $relationship => $data) {
            $relationshipPathObject = $this->_getPathObject($path->dotted . '.' . $relationship);

            if (!$this->_relationshipMustHaveData($relationshipPathObject)) {
                continue;
            }

            if ($this->_relationshipDataIsNull($relationshipPathObject)) {
                continue;
            }

            // single belongsTo relationship
            if ($this->_stringIsSingular($relationshipPathObject->key)) {
                $this->_relationshipDataMustHaveType($relationship, $relationshipPathObject);
                $this->_relationshipDataMustHaveId($relationship, $relationshipPathObject);

                continue;
            }

            // multiple hasMany relationships
            $hasManys = $this->_getProperty($relationshipPathObject->dotted . '.data');

            $i = 0;
            foreach ($hasManys as $hasMany) {
                $pathObject = $this->_getPathObject($relationshipPathObject->dotted . '.data.' . $i);

                $this->_relationshipDataMustHaveType($relationship, $pathObject);
                $this->_relationshipDataMustHaveId($relationship, $pathObject);

                $i++;
            }
        }

        return true;
    }
protected function _primaryDataMayHaveRelationships ( ) { $ path = $ this -> _getPathObject ( 'data.relationships' ) ; if ( ! $ this -> _hasProperty ( $ path ) ) { return true ; } $ relationships = $ this -> _getProperty ( $ path -> dotted ) ; if ( empty ( $ relationships ) ) { $ this -> _errorCollection -> addRelationshipsError ( $ title = '_required' , $ detail = "Relationships object does not contain any members" , $ status = null , $ idx = null , $ aboutLink = $ this -> _getAboutLink ( 'http://jsonapi.org/format/#crud-creating' ) ) ; return false ; } foreach ( $ relationships as $ relationship => $ data ) { $ relationshipPathObject = $ this -> _getPathObject ( $ path -> dotted . '.' . $ relationship ) ; if ( ! $ this -> _relationshipMustHaveData ( $ relationshipPathObject ) ) { continue ; } if ( $ this -> _relationshipDataIsNull ( $ relationshipPathObject ) ) { continue ; } // single belongsTo relationship if ( $ this -> _stringIsSingular ( $ relationshipPathObject -> key ) ) { $ this -> _relationshipDataMustHaveType ( $ relationship , $ relationshipPathObject ) ; $ this -> _relationshipDataMustHaveId ( $ relationship , $ relationshipPathObject ) ; continue ; } // multiple hasMany relationships $ hasManys = $ this -> _getProperty ( $ relationshipPathObject -> dotted . '.data' ) ; $ i = 0 ; foreach ( $ hasManys as $ hasMany ) { $ pathObject = $ this -> _getPathObject ( $ relationshipPathObject -> dotted . '.data.' . $ i ) ; $ this -> _relationshipDataMustHaveType ( $ relationship , $ pathObject ) ; $ this -> _relationshipDataMustHaveId ( $ relationship , $ pathObject ) ; $ i ++ ; } } return true ; }
Ensures that primary data 'relationships' member contains valid data
if it exists.

@return bool
Ensures that primary data relationships member contains valid data if it exists .