3.4 3.3
Jump to table of contents

Get Data

Your plugin may need to get data from the application, such as submissions, issues, authors, users and files. Use the Repo facade to retrieve information.

use APP\core\Application;
use APP\facades\Repo;

$currentUser = Application::get()->getUser();
$context = Application::get()->getContext();

$submissions = Repo::submission()

The Collectors are a wrapper around Laravel QueryBuilder. Plugins can access the underlying QueryBuilder to run custom database queries. The example uses the submission collector to build a query of all published submissions in a context, then adds conditions to restrict results to those that have an author with the provided email address.

use APP\author\DAO as AuthorDAO;
use APP\core\Application;
use APP\facades\Repo;
use APP\submission\Submission;

$context = Application::get()->getContext();
$authorDao = app(AuthorDAO::class);

$queryBuilder = Repo::submission()

$submissions = $queryBuilder
    ->leftJoin($authorDao->table . ' as a', 'po.publication_id', '=', 'a.email')
    ->where('a.email', 'example@author.com')
        function($row, $i) {
            return Repo::submission()->dao->fromRow($row);

If a Repository does not exist for the data you want, you may need to use a DAO.

$reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
$reviewAssignments = $reviewAssignmentDao->getByReviewRoundId($reviewRoundId);

Learn more about Repositories, Entities and DAOs in our developer documentation.

View more examples.