public function getAttachment()
    {
        if ($this->relatedObject === null && $this->isRelatedObjectResolved === false) {
            $this->isRelatedObjectResolved = true;

            try {
                $model = $this->modelFactory()->create(Attachment::class)->load($this->attachmentId());
                if ($model->id()) {
                    $this->relatedObject = $model;

                    $type = $model->type();
                    if ($type !== $model->objType()) {
                        $this->relatedObject = $this->modelFactory()->create($type)->setData($model->data());
                    }
                }
            } catch (Exception $e) {
                throw new LogicException(sprintf(
                    'Could not load the related object of the relationship: %s',
                    $e->getMessage()
                ), 0, $e);
            }
        }

        return $this->relatedObject;
    }
public function getAttachment()
    {
        if ($this->relatedObject === null && $this->isRelatedObjectResolved === false) {
            $this->isRelatedObjectResolved = true;

            try {
                $model = $this->modelFactory()->create(Attachment::class)->load($this->attachmentId());
                if ($model->id()) {
                    $this->relatedObject = $model;

                    $type = $model->type();
                    if ($type !== $model->objType()) {
                        $this->relatedObject = $this->modelFactory()->create($type)->setData($model->data());
                    }
                }
            } catch (Exception $e) {
                throw new LogicException(sprintf(
                    'Could not load the related object of the relationship: %s',
                    $e->getMessage()
                ), 0, $e);
            }
        }

        return $this->relatedObject;
    }
public function getAttachment ( ) { if ( $ this -> relatedObject === null && $ this -> isRelatedObjectResolved === false ) { $ this -> isRelatedObjectResolved = true ; try { $ model = $ this -> modelFactory ( ) -> create ( Attachment :: class ) -> load ( $ this -> attachmentId ( ) ) ; if ( $ model -> id ( ) ) { $ this -> relatedObject = $ model ; $ type = $ model -> type ( ) ; if ( $ type !== $ model -> objType ( ) ) { $ this -> relatedObject = $ this -> modelFactory ( ) -> create ( $ type ) -> setData ( $ model -> data ( ) ) ; } } } catch ( Exception $ e ) { throw new LogicException ( sprintf ( 'Could not load the related object of the relationship: %s' , $ e -> getMessage ( ) ) , 0 , $ e ) ; } } return $ this -> relatedObject ; }
Retrieve the related object of the relationship.

@throws LogicException If the relationship is broken or incomplete.
@return ModelInterface|null
Retrieve the related object of the relationship .