src/CampaignAdmin.php
protected function getChangeSetResource(ChangeSet $changeSet, $sync = false)
    {
        $stateLabel = sprintf(
            '<span class="campaign-status campaign-status--%s"></span>%s',
            $changeSet->State,
            $changeSet->getStateLabel()
        );

        $hal = [
            '_links' => [
                'self' => [
                    'href' => $this->SetLink($changeSet->ID)
                ]
            ],
            'ID' => $changeSet->ID,
            'Name' => $changeSet->Name,
            'Created' => $changeSet->Created,
            'LastEdited' => $changeSet->LastEdited,
            'State' => $changeSet->State,
            'StateLabel' => [ 'html' => $stateLabel ],
            'IsInferred' => $changeSet->IsInferred,
            'canEdit' => $changeSet->canEdit(),
            'canPublish' => false,
            '_embedded' => ['items' => []],
            'placeholderGroups' => $this->getPlaceholderGroups(),
        ];

        // Before presenting the changeset to the client,
        // synchronise it with new changes.
        try {
            if ($sync) {
                $changeSet->sync();
            }
            $hal['PublishedLabel'] = $changeSet->getPublishedLabel() ?: '-';
            $hal['Details'] = $changeSet->getDetails();
            $hal['canPublish'] = $changeSet->canPublish() && $changeSet->hasChanges();

            foreach ($changeSet->Changes() as $changeSetItem) {
                if (!$changeSetItem) {
                    continue;
                }

                /** @var ChangesetItem $changeSetItem */
                $resource = $this->getChangeSetItemResource($changeSetItem);
                if (!empty($resource)) {
                    $hal['_embedded']['items'][] = $resource;
                }
            }

        // An unexpected data exception means that the database is corrupt
        } catch (UnexpectedDataException $e) {
            $hal['PublishedLabel'] = '-';
            $hal['Details'] = 'Corrupt database! ' . $e->getMessage();
            $hal['canPublish'] = false;
        }
        return $hal;
    }
protected function getChangeSetResource(ChangeSet $changeSet, $sync = false)
    {
        $stateLabel = sprintf(
            '<span class="campaign-status campaign-status--%s"></span>%s',
            $changeSet->State,
            $changeSet->getStateLabel()
        );

        $hal = [
            '_links' => [
                'self' => [
                    'href' => $this->SetLink($changeSet->ID)
                ]
            ],
            'ID' => $changeSet->ID,
            'Name' => $changeSet->Name,
            'Created' => $changeSet->Created,
            'LastEdited' => $changeSet->LastEdited,
            'State' => $changeSet->State,
            'StateLabel' => [ 'html' => $stateLabel ],
            'IsInferred' => $changeSet->IsInferred,
            'canEdit' => $changeSet->canEdit(),
            'canPublish' => false,
            '_embedded' => ['items' => []],
            'placeholderGroups' => $this->getPlaceholderGroups(),
        ];

        // Before presenting the changeset to the client,
        // synchronise it with new changes.
        try {
            if ($sync) {
                $changeSet->sync();
            }
            $hal['PublishedLabel'] = $changeSet->getPublishedLabel() ?: '-';
            $hal['Details'] = $changeSet->getDetails();
            $hal['canPublish'] = $changeSet->canPublish() && $changeSet->hasChanges();

            foreach ($changeSet->Changes() as $changeSetItem) {
                if (!$changeSetItem) {
                    continue;
                }

                /** @var ChangesetItem $changeSetItem */
                $resource = $this->getChangeSetItemResource($changeSetItem);
                if (!empty($resource)) {
                    $hal['_embedded']['items'][] = $resource;
                }
            }

        // An unexpected data exception means that the database is corrupt
        } catch (UnexpectedDataException $e) {
            $hal['PublishedLabel'] = '-';
            $hal['Details'] = 'Corrupt database! ' . $e->getMessage();
            $hal['canPublish'] = false;
        }
        return $hal;
    }
protected function getChangeSetResource ( ChangeSet $ changeSet , $ sync = false ) { $ stateLabel = sprintf ( '<span class="campaign-status campaign-status--%s"></span>%s' , $ changeSet -> State , $ changeSet -> getStateLabel ( ) ) ; $ hal = [ '_links' => [ 'self' => [ 'href' => $ this -> SetLink ( $ changeSet -> ID ) ] ] , 'ID' => $ changeSet -> ID , 'Name' => $ changeSet -> Name , 'Created' => $ changeSet -> Created , 'LastEdited' => $ changeSet -> LastEdited , 'State' => $ changeSet -> State , 'StateLabel' => [ 'html' => $ stateLabel ] , 'IsInferred' => $ changeSet -> IsInferred , 'canEdit' => $ changeSet -> canEdit ( ) , 'canPublish' => false , '_embedded' => [ 'items' => [ ] ] , 'placeholderGroups' => $ this -> getPlaceholderGroups ( ) , ] ; // Before presenting the changeset to the client, // synchronise it with new changes. try { if ( $ sync ) { $ changeSet -> sync ( ) ; } $ hal [ 'PublishedLabel' ] = $ changeSet -> getPublishedLabel ( ) ? : '-' ; $ hal [ 'Details' ] = $ changeSet -> getDetails ( ) ; $ hal [ 'canPublish' ] = $ changeSet -> canPublish ( ) && $ changeSet -> hasChanges ( ) ; foreach ( $ changeSet -> Changes ( ) as $ changeSetItem ) { if ( ! $ changeSetItem ) { continue ; } /** @var ChangesetItem $changeSetItem */ $ resource = $ this -> getChangeSetItemResource ( $ changeSetItem ) ; if ( ! empty ( $ resource ) ) { $ hal [ '_embedded' ] [ 'items' ] [ ] = $ resource ; } } // An unexpected data exception means that the database is corrupt } catch ( UnexpectedDataException $ e ) { $ hal [ 'PublishedLabel' ] = '-' ; $ hal [ 'Details' ] = 'Corrupt database! ' . $ e -> getMessage ( ) ; $ hal [ 'canPublish' ] = false ; } return $ hal ; }
Build item resource from a changeset

@param ChangeSet $changeSet
@param bool $sync Set to true to force async of this changeset
@return array
Build item resource from a changeset