src/CampaignAdmin.php
public function readCampaign(HTTPRequest $request)
    {
        $response = new HTTPResponse();
        $accepts = $request->getAcceptMimetypes();

        //accept 'text/json' for legacy reasons
        if (in_array('application/json', $accepts) || in_array('text/json', $accepts)) {
            $response->addHeader('Content-Type', 'application/json');
            if (!$request->param('Name')) {
                return (new HTTPResponse(null, 400));
            }

            /** @var ChangeSet $changeSet */
            $changeSet = ChangeSet::get()->byID($request->param('ID'));
            if (!$changeSet) {
                return (new HTTPResponse(null, 404));
            }

            if (!$changeSet->canView()) {
                return (new HTTPResponse(null, 403));
            }

            $body = json_encode($this->getChangeSetResource($changeSet, true));
            return (new HTTPResponse($body, 200))
                ->addHeader('Content-Type', 'application/json');
        } else {
            return $this->index($request);
        }
    }
public function readCampaign(HTTPRequest $request)
    {
        $response = new HTTPResponse();
        $accepts = $request->getAcceptMimetypes();

        //accept 'text/json' for legacy reasons
        if (in_array('application/json', $accepts) || in_array('text/json', $accepts)) {
            $response->addHeader('Content-Type', 'application/json');
            if (!$request->param('Name')) {
                return (new HTTPResponse(null, 400));
            }

            /** @var ChangeSet $changeSet */
            $changeSet = ChangeSet::get()->byID($request->param('ID'));
            if (!$changeSet) {
                return (new HTTPResponse(null, 404));
            }

            if (!$changeSet->canView()) {
                return (new HTTPResponse(null, 403));
            }

            $body = json_encode($this->getChangeSetResource($changeSet, true));
            return (new HTTPResponse($body, 200))
                ->addHeader('Content-Type', 'application/json');
        } else {
            return $this->index($request);
        }
    }
public function readCampaign ( HTTPRequest $ request ) { $ response = new HTTPResponse ( ) ; $ accepts = $ request -> getAcceptMimetypes ( ) ; //accept 'text/json' for legacy reasons if ( in_array ( 'application/json' , $ accepts ) || in_array ( 'text/json' , $ accepts ) ) { $ response -> addHeader ( 'Content-Type' , 'application/json' ) ; if ( ! $ request -> param ( 'Name' ) ) { return ( new HTTPResponse ( null , 400 ) ) ; } /** @var ChangeSet $changeSet */ $ changeSet = ChangeSet :: get ( ) -> byID ( $ request -> param ( 'ID' ) ) ; if ( ! $ changeSet ) { return ( new HTTPResponse ( null , 404 ) ) ; } if ( ! $ changeSet -> canView ( ) ) { return ( new HTTPResponse ( null , 403 ) ) ; } $ body = json_encode ( $ this -> getChangeSetResource ( $ changeSet , true ) ) ; return ( new HTTPResponse ( $ body , 200 ) ) -> addHeader ( 'Content-Type' , 'application/json' ) ; } else { return $ this -> index ( $ request ) ; } }
REST endpoint to get a campaign.

@param HTTPRequest $request

@return HTTPResponse
REST endpoint to get a campaign .