src/CampaignAdmin.php
protected function getChangeSetItemResource(ChangeSetItem $changeSetItem)
    {
        $baseClass = DataObject::getSchema()->baseDataClass($changeSetItem->ObjectClass);
        $baseSingleton = DataObject::singleton($baseClass);

        // Allow items to opt out of being displayed in changesets
        if ($baseSingleton->config()->get('hide_in_campaigns')) {
            return [];
        }

        $thumbnailWidth = (int)$this->config()->get('thumbnail_width');
        $thumbnailHeight = (int)$this->config()->get('thumbnail_height');
        $hal = [
            '_links' => [
                'self' => [
                    'id' => $changeSetItem->ID,
                    'href' => $this->ItemLink($changeSetItem->ID)
                ]
            ],
            'ID' => $changeSetItem->ID,
            'Created' => $changeSetItem->Created,
            'LastEdited' => $changeSetItem->LastEdited,
            'Title' => $changeSetItem->getTitle(),
            'ChangeType' => $changeSetItem->getChangeType(),
            'Added' => $changeSetItem->Added,
            'ObjectClass' => $changeSetItem->ObjectClass,
            'ObjectID' => $changeSetItem->ObjectID,
            'BaseClass' => $baseClass,
            'Singular' => $baseSingleton->i18n_singular_name(),
            'Plural' => $baseSingleton->i18n_plural_name(),
            'Thumbnail' => $changeSetItem->ThumbnailURL($thumbnailWidth, $thumbnailHeight),
        ];
        // Get preview urls
        $previews = $changeSetItem->getPreviewLinks();
        if ($previews) {
            $hal['_links']['preview'] = $previews;
        }

        // Get edit link
        $editLink = $changeSetItem->CMSEditLink();
        if ($editLink) {
            $hal['_links']['edit'] = [
                'href' => $editLink,
            ];
        }

        // Depending on whether the object was added implicitly or explicitly, set
        // other related objects.
        if ($changeSetItem->Added === ChangeSetItem::IMPLICITLY) {
            $referencedItems = $changeSetItem->ReferencedBy();
            $referencedBy = [];
            foreach ($referencedItems as $referencedItem) {
                $referencedBy[] = [
                    'href' => $this->SetLink($referencedItem->ID),
                    'ChangeSetItemID' => $referencedItem->ID
                ];
            }
            if ($referencedBy) {
                $hal['_links']['referenced_by'] = $referencedBy;
            }
        }

        $referToItems = $changeSetItem->References();
        $referTo = [];
        foreach ($referToItems as $referToItem) {
            $referTo[] = [
                'ChangeSetItemID' => $referToItem->ID,
            ];
        }
        $hal['_links']['references'] = $referTo;

        return $hal;
    }
protected function getChangeSetItemResource(ChangeSetItem $changeSetItem)
    {
        $baseClass = DataObject::getSchema()->baseDataClass($changeSetItem->ObjectClass);
        $baseSingleton = DataObject::singleton($baseClass);

        // Allow items to opt out of being displayed in changesets
        if ($baseSingleton->config()->get('hide_in_campaigns')) {
            return [];
        }

        $thumbnailWidth = (int)$this->config()->get('thumbnail_width');
        $thumbnailHeight = (int)$this->config()->get('thumbnail_height');
        $hal = [
            '_links' => [
                'self' => [
                    'id' => $changeSetItem->ID,
                    'href' => $this->ItemLink($changeSetItem->ID)
                ]
            ],
            'ID' => $changeSetItem->ID,
            'Created' => $changeSetItem->Created,
            'LastEdited' => $changeSetItem->LastEdited,
            'Title' => $changeSetItem->getTitle(),
            'ChangeType' => $changeSetItem->getChangeType(),
            'Added' => $changeSetItem->Added,
            'ObjectClass' => $changeSetItem->ObjectClass,
            'ObjectID' => $changeSetItem->ObjectID,
            'BaseClass' => $baseClass,
            'Singular' => $baseSingleton->i18n_singular_name(),
            'Plural' => $baseSingleton->i18n_plural_name(),
            'Thumbnail' => $changeSetItem->ThumbnailURL($thumbnailWidth, $thumbnailHeight),
        ];
        // Get preview urls
        $previews = $changeSetItem->getPreviewLinks();
        if ($previews) {
            $hal['_links']['preview'] = $previews;
        }

        // Get edit link
        $editLink = $changeSetItem->CMSEditLink();
        if ($editLink) {
            $hal['_links']['edit'] = [
                'href' => $editLink,
            ];
        }

        // Depending on whether the object was added implicitly or explicitly, set
        // other related objects.
        if ($changeSetItem->Added === ChangeSetItem::IMPLICITLY) {
            $referencedItems = $changeSetItem->ReferencedBy();
            $referencedBy = [];
            foreach ($referencedItems as $referencedItem) {
                $referencedBy[] = [
                    'href' => $this->SetLink($referencedItem->ID),
                    'ChangeSetItemID' => $referencedItem->ID
                ];
            }
            if ($referencedBy) {
                $hal['_links']['referenced_by'] = $referencedBy;
            }
        }

        $referToItems = $changeSetItem->References();
        $referTo = [];
        foreach ($referToItems as $referToItem) {
            $referTo[] = [
                'ChangeSetItemID' => $referToItem->ID,
            ];
        }
        $hal['_links']['references'] = $referTo;

        return $hal;
    }
protected function getChangeSetItemResource ( ChangeSetItem $ changeSetItem ) { $ baseClass = DataObject :: getSchema ( ) -> baseDataClass ( $ changeSetItem -> ObjectClass ) ; $ baseSingleton = DataObject :: singleton ( $ baseClass ) ; // Allow items to opt out of being displayed in changesets if ( $ baseSingleton -> config ( ) -> get ( 'hide_in_campaigns' ) ) { return [ ] ; } $ thumbnailWidth = ( int ) $ this -> config ( ) -> get ( 'thumbnail_width' ) ; $ thumbnailHeight = ( int ) $ this -> config ( ) -> get ( 'thumbnail_height' ) ; $ hal = [ '_links' => [ 'self' => [ 'id' => $ changeSetItem -> ID , 'href' => $ this -> ItemLink ( $ changeSetItem -> ID ) ] ] , 'ID' => $ changeSetItem -> ID , 'Created' => $ changeSetItem -> Created , 'LastEdited' => $ changeSetItem -> LastEdited , 'Title' => $ changeSetItem -> getTitle ( ) , 'ChangeType' => $ changeSetItem -> getChangeType ( ) , 'Added' => $ changeSetItem -> Added , 'ObjectClass' => $ changeSetItem -> ObjectClass , 'ObjectID' => $ changeSetItem -> ObjectID , 'BaseClass' => $ baseClass , 'Singular' => $ baseSingleton -> i18n_singular_name ( ) , 'Plural' => $ baseSingleton -> i18n_plural_name ( ) , 'Thumbnail' => $ changeSetItem -> ThumbnailURL ( $ thumbnailWidth , $ thumbnailHeight ) , ] ; // Get preview urls $ previews = $ changeSetItem -> getPreviewLinks ( ) ; if ( $ previews ) { $ hal [ '_links' ] [ 'preview' ] = $ previews ; } // Get edit link $ editLink = $ changeSetItem -> CMSEditLink ( ) ; if ( $ editLink ) { $ hal [ '_links' ] [ 'edit' ] = [ 'href' => $ editLink , ] ; } // Depending on whether the object was added implicitly or explicitly, set // other related objects. if ( $ changeSetItem -> Added === ChangeSetItem :: IMPLICITLY ) { $ referencedItems = $ changeSetItem -> ReferencedBy ( ) ; $ referencedBy = [ ] ; foreach ( $ referencedItems as $ referencedItem ) { $ referencedBy [ ] = [ 'href' => $ this -> SetLink ( $ referencedItem -> ID ) , 'ChangeSetItemID' => $ referencedItem -> ID ] ; } if ( $ referencedBy ) { $ hal [ '_links' ] [ 'referenced_by' ] = $ referencedBy ; } } $ referToItems = $ changeSetItem -> References ( ) ; $ referTo = [ ] ; foreach ( $ referToItems as $ referToItem ) { $ referTo [ ] = [ 'ChangeSetItemID' => $ referToItem -> ID , ] ; } $ hal [ '_links' ] [ 'references' ] = $ referTo ; return $ hal ; }
Build item resource from a changesetitem

@param ChangeSetItem $changeSetItem
@return array
Build item resource from a changesetitem