src/Service/Cdn.php
public function getObject($objectIdSlug, $bucketIdSlug = '', $data = [])
    {
        //  Check the cache
        $cacheKey = 'object-' . $objectIdSlug;
        $cacheKey .= $bucketIdSlug ? '-' . $bucketIdSlug : '';
        $cache    = $this->getCache($cacheKey);

        if ($cache) {
            return $cache;
        }

        // --------------------------------------------------------------------------

        if (!isset($data['where'])) {
            $data['where'] = [];
        }

        if (is_numeric($objectIdSlug)) {
            $data['where'][] = ['o.id', $objectIdSlug];
        } else {
            $data['where'][] = ['o.filename', $objectIdSlug];
            if (!empty($bucketIdSlug)) {
                if (is_numeric($bucketIdSlug)) {
                    $data['where'][] = ['b.id', $bucketIdSlug];
                } else {
                    $data['where'][] = ['b.slug', $bucketIdSlug];
                }
            }
        }

        $objects = $this->getObjects(null, null, $data);

        if (empty($objects)) {
            return false;
        }

        // --------------------------------------------------------------------------

        //  Cache the object
        $this->setCache($cacheKey, $objects[0]);

        // --------------------------------------------------------------------------

        return $objects[0];
    }
public function getObject($objectIdSlug, $bucketIdSlug = '', $data = [])
    {
        //  Check the cache
        $cacheKey = 'object-' . $objectIdSlug;
        $cacheKey .= $bucketIdSlug ? '-' . $bucketIdSlug : '';
        $cache    = $this->getCache($cacheKey);

        if ($cache) {
            return $cache;
        }

        // --------------------------------------------------------------------------

        if (!isset($data['where'])) {
            $data['where'] = [];
        }

        if (is_numeric($objectIdSlug)) {
            $data['where'][] = ['o.id', $objectIdSlug];
        } else {
            $data['where'][] = ['o.filename', $objectIdSlug];
            if (!empty($bucketIdSlug)) {
                if (is_numeric($bucketIdSlug)) {
                    $data['where'][] = ['b.id', $bucketIdSlug];
                } else {
                    $data['where'][] = ['b.slug', $bucketIdSlug];
                }
            }
        }

        $objects = $this->getObjects(null, null, $data);

        if (empty($objects)) {
            return false;
        }

        // --------------------------------------------------------------------------

        //  Cache the object
        $this->setCache($cacheKey, $objects[0]);

        // --------------------------------------------------------------------------

        return $objects[0];
    }
public function getObject ( $ objectIdSlug , $ bucketIdSlug = '' , $ data = [ ] ) { //  Check the cache $ cacheKey = 'object-' . $ objectIdSlug ; $ cacheKey .= $ bucketIdSlug ? '-' . $ bucketIdSlug : '' ; $ cache = $ this -> getCache ( $ cacheKey ) ; if ( $ cache ) { return $ cache ; } // -------------------------------------------------------------------------- if ( ! isset ( $ data [ 'where' ] ) ) { $ data [ 'where' ] = [ ] ; } if ( is_numeric ( $ objectIdSlug ) ) { $ data [ 'where' ] [ ] = [ 'o.id' , $ objectIdSlug ] ; } else { $ data [ 'where' ] [ ] = [ 'o.filename' , $ objectIdSlug ] ; if ( ! empty ( $ bucketIdSlug ) ) { if ( is_numeric ( $ bucketIdSlug ) ) { $ data [ 'where' ] [ ] = [ 'b.id' , $ bucketIdSlug ] ; } else { $ data [ 'where' ] [ ] = [ 'b.slug' , $ bucketIdSlug ] ; } } } $ objects = $ this -> getObjects ( null , null , $ data ) ; if ( empty ( $ objects ) ) { return false ; } // -------------------------------------------------------------------------- //  Cache the object $ this -> setCache ( $ cacheKey , $ objects [ 0 ] ) ; // -------------------------------------------------------------------------- return $ objects [ 0 ] ; }
Returns a single object

@param mixed  $objectIdSlug The object's ID or filename
@param string $bucketIdSlug The bucket's ID or slug
@param array  $data         Data to pass to getCountCommon()()

@return mixed                stdClass on success, false on failure
Returns a single object