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

        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');
        $oModel    = Factory::model('Object', 'nails/module-cdn');
        $sKeywords = $oInput->get('keywords');
        $iPage     = (int) $oInput->get('page') ?: 1;
        $oResult   = $oModel->search(
            $sKeywords,
            $iPage,
            static::MAX_OBJECTS_PER_REQUEST
        );

        $oResponse = Factory::factory('ApiResponse', 'nails/module-api');
        $oResponse->setData(array_map(
            function ($oObj) {
                $oObj->is_img = isset($oObj->img);
                $oObj->url    = (object) [
                    'src'     => cdnServe($oObj->id),
                    'preview' => isset($oObj->img) ? cdnCrop($oObj->id, 400, 400) : null,
                ];
                return $oObj;
            },
            $oResult->data
        ));
        return $oResponse;
    }
public function getSearch()
    {
        $oHttpCodes = Factory::service('HttpCodes');

        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');
        $oModel    = Factory::model('Object', 'nails/module-cdn');
        $sKeywords = $oInput->get('keywords');
        $iPage     = (int) $oInput->get('page') ?: 1;
        $oResult   = $oModel->search(
            $sKeywords,
            $iPage,
            static::MAX_OBJECTS_PER_REQUEST
        );

        $oResponse = Factory::factory('ApiResponse', 'nails/module-api');
        $oResponse->setData(array_map(
            function ($oObj) {
                $oObj->is_img = isset($oObj->img);
                $oObj->url    = (object) [
                    'src'     => cdnServe($oObj->id),
                    'preview' => isset($oObj->img) ? cdnCrop($oObj->id, 400, 400) : null,
                ];
                return $oObj;
            },
            $oResult->data
        ));
        return $oResponse;
    }
public function getSearch ( ) { $ oHttpCodes = Factory :: service ( 'HttpCodes' ) ; 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' ) ; $ oModel = Factory :: model ( 'Object' , 'nails/module-cdn' ) ; $ sKeywords = $ oInput -> get ( 'keywords' ) ; $ iPage = ( int ) $ oInput -> get ( 'page' ) ? : 1 ; $ oResult = $ oModel -> search ( $ sKeywords , $ iPage , static :: MAX_OBJECTS_PER_REQUEST ) ; $ oResponse = Factory :: factory ( 'ApiResponse' , 'nails/module-api' ) ; $ oResponse -> setData ( array_map ( function ( $ oObj ) { $ oObj -> is_img = isset ( $ oObj -> img ) ; $ oObj -> url = ( object ) [ 'src' => cdnServe ( $ oObj -> id ) , 'preview' => isset ( $ oObj -> img ) ? cdnCrop ( $ oObj -> id , 400 , 400 ) : null , ] ; return $ oObj ; } , $ oResult -> data ) ) ; return $ oResponse ; }
Search across all objects

@return array
Search across all objects