src/Api/Controller/Bucket.php
public function getList()
    {
        if (!userHasPermission('admin:cdn:manager:object:browse')) {
            throw new ApiException(
                'You do not have permission to access this resource',
                $oHttpCodes::STATUS_UNAUTHORIZED
            );
        }

        $oInput       = Factory::service('Input');
        $oObjectModel = Factory::model('Object', 'nails/module-cdn');
        $iBucketId    = (int) $oInput->get('bucket_id') ?: null;
        $iPage        = (int) $oInput->get('page') ?: 1;

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

        $aObjects = $oObjectModel->getAll(
            $iPage,
            static::CONFIG_OBJECTS_PER_PAGE,
            ['where' => [['bucket_id', $iBucketId]]]
        );

        return Factory::factory('ApiResponse', 'nails/module-api')
            ->setData(array_map(
                function ($oObj) {
                    $oObj->url->preview = $oObj->is_img ? cdnCrop($oObj->id, 400, 400) : null;
                    return $oObj;
                },
                $aObjects
            ))
            ->setMeta([
                'page'     => $iPage,
                'per_page' => static::CONFIG_OBJECTS_PER_PAGE,
            ]);
    }
public function getList()
    {
        if (!userHasPermission('admin:cdn:manager:object:browse')) {
            throw new ApiException(
                'You do not have permission to access this resource',
                $oHttpCodes::STATUS_UNAUTHORIZED
            );
        }

        $oInput       = Factory::service('Input');
        $oObjectModel = Factory::model('Object', 'nails/module-cdn');
        $iBucketId    = (int) $oInput->get('bucket_id') ?: null;
        $iPage        = (int) $oInput->get('page') ?: 1;

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

        $aObjects = $oObjectModel->getAll(
            $iPage,
            static::CONFIG_OBJECTS_PER_PAGE,
            ['where' => [['bucket_id', $iBucketId]]]
        );

        return Factory::factory('ApiResponse', 'nails/module-api')
            ->setData(array_map(
                function ($oObj) {
                    $oObj->url->preview = $oObj->is_img ? cdnCrop($oObj->id, 400, 400) : null;
                    return $oObj;
                },
                $aObjects
            ))
            ->setMeta([
                'page'     => $iPage,
                'per_page' => static::CONFIG_OBJECTS_PER_PAGE,
            ]);
    }
public function getList ( ) { if ( ! userHasPermission ( 'admin:cdn:manager:object:browse' ) ) { throw new ApiException ( 'You do not have permission to access this resource' , $ oHttpCodes :: STATUS_UNAUTHORIZED ) ; } $ oInput = Factory :: service ( 'Input' ) ; $ oObjectModel = Factory :: model ( 'Object' , 'nails/module-cdn' ) ; $ iBucketId = ( int ) $ oInput -> get ( 'bucket_id' ) ? : null ; $ iPage = ( int ) $ oInput -> get ( 'page' ) ? : 1 ; if ( empty ( $ iBucketId ) ) { throw new ApiException ( '`bucket_id` is a required field' , $ oHttpCodes :: STATUS_BAD_REQUEST ) ; } $ aObjects = $ oObjectModel -> getAll ( $ iPage , static :: CONFIG_OBJECTS_PER_PAGE , [ 'where' => [ [ 'bucket_id' , $ iBucketId ] ] ] ) ; return Factory :: factory ( 'ApiResponse' , 'nails/module-api' ) -> setData ( array_map ( function ( $ oObj ) { $ oObj -> url -> preview = $ oObj -> is_img ? cdnCrop ( $ oObj -> id , 400 , 400 ) : null ; return $ oObj ; } , $ aObjects ) ) -> setMeta ( [ 'page' => $ iPage , 'per_page' => static :: CONFIG_OBJECTS_PER_PAGE , ] ) ; }
Returns a paginated list of a bucket's contents

@return array
Returns a paginated list of a bucket s contents