Accessing DB directly to get specific item (caption of submission)

I had prepared a custom plugin to display html galleys into the article details page, together with images and tables.

Using version 3.1, I could access the ‘caption’ setting of a submission by using the getData (‘caption’)

After updating to 3.3, this does not work. I know the caption is stored in ‘submission_artwork_files’, and I seem to have an idea to get the caption directly from the DB. However, my Laravel knowledge is poor (I am not a professional coder, and this is a side-project)

So how do I get the cpation or access the DB directly?

I have done so far:

  1. prepared plugin (works)

  2. Added:
    use Illuminate\Database\Query\Builder;
    use Illuminate\Support\Collection;
    use Illuminate\Support\Facades\DB;
    use Illuminate\Support\LazyCollection;
    use PKP\db\DAO;

$test = DB::table(‘submission_artwork_files’)
->where(‘file_id’, ‘=’, (int) $galleyFile->getData(‘id’))

??Order by revision DESC to get latest version

I get a Facade not set error



For future reference:

Managed to do this using ArticleGalleyDAO and then accessing DB directly

$TestingGalleyDAO = DAORegistry::getDAO(‘ArticleGalleyDAO’);
error_log ("File id is: " . $galleyFile->getData(‘id’));

            $result = $TestingGalleyDAO->retrieve(
              'SELECT `caption` FROM `submission_artwork_files` WHERE `file_id` = ?  ORDER BY `submission_artwork_files`.`revision` DESC ',
              [$galleyFile->getData('id') ]
            $caption = $result->current()->caption;
            error_log ("Caption is: " . $caption);