src/Api/Controller/CdnObject.php
public function postDelete()
    {
        $oHttpCodes = Factory::service('HttpCodes');

        if (!userHasPermission('admin:cdn:manager:object:delete')) {
            throw new ApiException(
                'You do not have permission to access this resource',
                $oHttpCodes::STATUS_UNAUTHORIZED
            );
        }

        $oInput    = Factory::service('Input');
        $oCdn      = Factory::service('Cdn', 'nails/module-cdn');
        $iObjectId = $oInput->post('object_id');

        if (empty($iObjectId)) {
            throw new ApiException(
                '`object_id` is a required field',
                $oHttpCodes::STATUS_BAD_REQUEST
            );
        }

        $oObject  = $oCdn->getObject($iObjectId);
        $bIsTrash = false;
        if (empty($oObject)) {
            $oObject  = $oCdn->getObjectFromTrash($iObjectId);
            $bIsTrash = true;
        }

        if (empty($oObject)) {
            throw new ApiException(
                'Invalid object ID',
                $oHttpCodes::STATUS_NOT_FOUND
            );
        }

        if ($bIsTrash) {
            $bDelete = $oCdn->purgeTrash([$iObjectId]);
        } else {
            $bDelete = $oCdn->objectDelete($iObjectId);
        }

        if (!$bDelete) {
            throw new ApiException(
                $oCdn->lastError(),
                $oHttpCodes::STATUS_BAD_REQUEST
            );
        }

        return Factory::factory('ApiResponse', 'nails/module-api');
    }
public function postDelete()
    {
        $oHttpCodes = Factory::service('HttpCodes');

        if (!userHasPermission('admin:cdn:manager:object:delete')) {
            throw new ApiException(
                'You do not have permission to access this resource',
                $oHttpCodes::STATUS_UNAUTHORIZED
            );
        }

        $oInput    = Factory::service('Input');
        $oCdn      = Factory::service('Cdn', 'nails/module-cdn');
        $iObjectId = $oInput->post('object_id');

        if (empty($iObjectId)) {
            throw new ApiException(
                '`object_id` is a required field',
                $oHttpCodes::STATUS_BAD_REQUEST
            );
        }

        $oObject  = $oCdn->getObject($iObjectId);
        $bIsTrash = false;
        if (empty($oObject)) {
            $oObject  = $oCdn->getObjectFromTrash($iObjectId);
            $bIsTrash = true;
        }

        if (empty($oObject)) {
            throw new ApiException(
                'Invalid object ID',
                $oHttpCodes::STATUS_NOT_FOUND
            );
        }

        if ($bIsTrash) {
            $bDelete = $oCdn->purgeTrash([$iObjectId]);
        } else {
            $bDelete = $oCdn->objectDelete($iObjectId);
        }

        if (!$bDelete) {
            throw new ApiException(
                $oCdn->lastError(),
                $oHttpCodes::STATUS_BAD_REQUEST
            );
        }

        return Factory::factory('ApiResponse', 'nails/module-api');
    }
public function postDelete ( ) { $ oHttpCodes = Factory :: service ( 'HttpCodes' ) ; if ( ! userHasPermission ( 'admin:cdn:manager:object:delete' ) ) { throw new ApiException ( 'You do not have permission to access this resource' , $ oHttpCodes :: STATUS_UNAUTHORIZED ) ; } $ oInput = Factory :: service ( 'Input' ) ; $ oCdn = Factory :: service ( 'Cdn' , 'nails/module-cdn' ) ; $ iObjectId = $ oInput -> post ( 'object_id' ) ; if ( empty ( $ iObjectId ) ) { throw new ApiException ( '`object_id` is a required field' , $ oHttpCodes :: STATUS_BAD_REQUEST ) ; } $ oObject = $ oCdn -> getObject ( $ iObjectId ) ; $ bIsTrash = false ; if ( empty ( $ oObject ) ) { $ oObject = $ oCdn -> getObjectFromTrash ( $ iObjectId ) ; $ bIsTrash = true ; } if ( empty ( $ oObject ) ) { throw new ApiException ( 'Invalid object ID' , $ oHttpCodes :: STATUS_NOT_FOUND ) ; } if ( $ bIsTrash ) { $ bDelete = $ oCdn -> purgeTrash ( [ $ iObjectId ] ) ; } else { $ bDelete = $ oCdn -> objectDelete ( $ iObjectId ) ; } if ( ! $ bDelete ) { throw new ApiException ( $ oCdn -> lastError ( ) , $ oHttpCodes :: STATUS_BAD_REQUEST ) ; } return Factory :: factory ( 'ApiResponse' , 'nails/module-api' ) ; }
Delete an object from the CDN

@return array
Delete an object from the CDN