public static function find_shortcode_record($args, &$errorCode = null)
    {
        // Validate shortcode
        if (!isset($args['id']) || !is_numeric($args['id'])) {
            return null;
        }

        // Check if the file is found
        /** @var File $file */
        $file = DataObject::get_by_id(File::class, $args['id']);
        if (!$file) {
            $errorCode = 404;
            return null;
        }

        // Check if the file is viewable
        $inheritsCanView = Config::inst()->get(static::class, 'shortcodes_inherit_canview');
        if (!$inheritsCanView && !$file->canView()) {
            $errorCode = 403;
            return null;
        }

        // Success
        return $file;
    }
public static function find_shortcode_record($args, &$errorCode = null)
    {
        // Validate shortcode
        if (!isset($args['id']) || !is_numeric($args['id'])) {
            return null;
        }

        // Check if the file is found
        /** @var File $file */
        $file = DataObject::get_by_id(File::class, $args['id']);
        if (!$file) {
            $errorCode = 404;
            return null;
        }

        // Check if the file is viewable
        $inheritsCanView = Config::inst()->get(static::class, 'shortcodes_inherit_canview');
        if (!$inheritsCanView && !$file->canView()) {
            $errorCode = 403;
            return null;
        }

        // Success
        return $file;
    }
public static function find_shortcode_record ( $ args , & $ errorCode = null ) { // Validate shortcode if ( ! isset ( $ args [ 'id' ] ) || ! is_numeric ( $ args [ 'id' ] ) ) { return null ; } // Check if the file is found /** @var File $file */ $ file = DataObject :: get_by_id ( File :: class , $ args [ 'id' ] ) ; if ( ! $ file ) { $ errorCode = 404 ; return null ; } // Check if the file is viewable $ inheritsCanView = Config :: inst ( ) -> get ( static :: class , 'shortcodes_inherit_canview' ) ; if ( ! $ inheritsCanView && ! $ file -> canView ( ) ) { $ errorCode = 403 ; return null ; } // Success return $ file ; }
Find the record to use for a given shortcode.

@param array $args Array of input shortcode arguments
@param int $errorCode If the file is not found, or is inaccessible, this will be assigned to a HTTP error code.

@return File|null The File DataObject, if it can be found.
Find the record to use for a given shortcode .