diff --git a/api/v1/_dois/BackendDoiController.php b/api/v1/_dois/BackendDoiController.php index 1d06d8dfcb5..c34d5bebb19 100644 --- a/api/v1/_dois/BackendDoiController.php +++ b/api/v1/_dois/BackendDoiController.php @@ -23,7 +23,7 @@ use Illuminate\Http\Response; use Illuminate\Support\Facades\Route; use Illuminate\Support\LazyCollection; -use PKP\db\DAORegistry; +use PKP\submission\genre\Genre; class BackendDoiController extends \PKP\API\v1\_dois\PKPBackendDoiController { @@ -82,9 +82,8 @@ public function editGalley(Request $illuminateRequest): JsonResponse Repo::galley()->edit($galley, ['doiId' => $doi->getId()]); - /** @var \PKP\submission\GenreDAO $genreDao */ - $genreDao = DAORegistry::getDAO('GenreDAO'); - $genres = $genreDao->getByContextId($context->getId())->toArray(); + $genres = Genre::where('context_id', $context->getId())->get()->toArray(); + // Re-fetch submission and publication to reflect changes in galley $submission = Repo::submission()->get((int) $submissionId); $publication = Repo::publication()->get((int) $publicationId); @@ -152,8 +151,6 @@ protected function getUserGroups(int $contextId): LazyCollection protected function getGenres(int $contextId): array { - /** @var \PKP\submission\GenreDAO $genreDao */ - $genreDao = DAORegistry::getDAO('GenreDAO'); - return $genreDao->getByContextId($contextId)->toArray(); + return Genre::where('context_id', $contextId)->get()->toArray(); } } diff --git a/api/v1/issues/IssueController.php b/api/v1/issues/IssueController.php index 4a456eec4e7..9fff4d33e86 100644 --- a/api/v1/issues/IssueController.php +++ b/api/v1/issues/IssueController.php @@ -29,13 +29,12 @@ use Illuminate\Support\LazyCollection; use PKP\core\PKPBaseController; use PKP\core\PKPRequest; -use PKP\db\DAORegistry; use PKP\plugins\Hook; use PKP\security\authorization\ContextAccessPolicy; use PKP\security\authorization\ContextRequiredPolicy; use PKP\security\authorization\UserRolesRequiredPolicy; use PKP\security\Role; -use PKP\submission\GenreDAO; +use PKP\submission\genre\Genre; class IssueController extends PKPBaseController { @@ -275,7 +274,6 @@ protected function getUserGroups(int $contextId): LazyCollection protected function getGenres(int $contextId): array { - $genreDao = DAORegistry::getDAO('GenreDAO'); /** @var GenreDAO $genreDao */ - return $genreDao->getByContextId($contextId)->toArray(); + return Genre::where('context_id', $contextId)->get()->toArray(); } } diff --git a/classes/services/ContextService.php b/classes/services/ContextService.php index 2b516bf1506..0568d45970b 100644 --- a/classes/services/ContextService.php +++ b/classes/services/ContextService.php @@ -27,7 +27,7 @@ use PKP\db\DAORegistry; use PKP\file\TemporaryFileManager; use PKP\plugins\Hook; -use PKP\submission\GenreDAO; +use PKP\submission\genre\Genre; class ContextService extends \PKP\services\PKPContextService { @@ -151,9 +151,7 @@ public function beforeDeleteContext($hookName, $args) // Create tombstones for all published submissions $articleTombstoneManager = new ArticleTombstoneManager(); $articleTombstoneManager->insertTombstonesByContext($context); - /** @var GenreDAO */ - $genreDao = DAORegistry::getDAO('GenreDAO'); - $genreDao->deleteByContextId($context->getId()); + Genre::where('context_id', $context->getId())->delete(); } /** @@ -201,7 +199,7 @@ public function afterDeleteContext($hookName, $args) */ public function validateContext($hookName, $args) { - $errors = & $args[0]; + $errors = &$args[0]; $props = $args[2]; $allowedLocales = $args[3]; diff --git a/pages/article/ArticleHandler.php b/pages/article/ArticleHandler.php index 80d420e9e64..aaf69646997 100644 --- a/pages/article/ArticleHandler.php +++ b/pages/article/ArticleHandler.php @@ -39,8 +39,7 @@ use PKP\plugins\PluginRegistry; use PKP\security\authorization\ContextRequiredPolicy; use PKP\security\Validation; -use PKP\submission\Genre; -use PKP\submission\GenreDAO; +use PKP\submission\genre\Genre; use PKP\submission\PKPSubmission; use PKP\submissionFile\SubmissionFile; use stdClass; @@ -167,8 +166,8 @@ public function initialize($request, $args = []) $this->galley = $galley; break; - // In some cases, a URL to a galley may use the ID when it should use - // the urlPath. Redirect to the galley's correct URL. + // In some cases, a URL to a galley may use the ID when it should use + // the urlPath. Redirect to the galley's correct URL. } elseif (ctype_digit($galleyId) && $galley->getId() == $galleyId) { $request->redirect(null, $request->getRequestedPage(), $request->getRequestedOp(), [$submission->getBestId(), $galley->getBestGalleyId()]); } @@ -261,15 +260,11 @@ public function view($args, $request) $primaryGalleys = []; $supplementaryGalleys = []; if ($galleys) { - $genreDao = DAORegistry::getDAO('GenreDAO'); /** @var GenreDAO $genreDao */ - $primaryGenres = $genreDao->getPrimaryByContextId($context->getId())->toArray(); - $primaryGenreIds = array_map(function ($genre) { - return $genre->getId(); - }, $primaryGenres); - $supplementaryGenres = $genreDao->getBySupplementaryAndContextId(true, $context->getId())->toArray(); - $supplementaryGenreIds = array_map(function ($genre) { - return $genre->getId(); - }, $supplementaryGenres); + $primaryGenres = Repo::genre()->getPrimaryByContextId($context->getId()); + $primaryGenreIds = $primaryGenres->pluck('id')->toArray(); + + $supplementaryGenres = Repo::genre()->getBySupplementaryAndContextId(true, $context->getId()); + $supplementaryGenreIds = $supplementaryGenres->pluck('id')->toArray(); foreach ($galleys as $galley) { $remoteUrl = $galley->getData('urlRemote'); @@ -502,9 +497,7 @@ public function download($args, $request) // if the file is a galley file (i.e. not a dependent file e.g. CSS or images), fire an usage event. if ($this->galley->getData('submissionFileId') == $this->submissionFileId) { $assocType = Application::ASSOC_TYPE_SUBMISSION_FILE; - /** @var GenreDAO */ - $genreDao = DAORegistry::getDAO('GenreDAO'); - $genre = $genreDao->getById($submissionFile->getData('genreId')); + $genre = Repo::genre()->find($submissionFile->getData('genreId')); // TO-DO: is this correct ? if ($genre->getCategory() != Genre::GENRE_CATEGORY_DOCUMENT || $genre->getSupplementary() || $genre->getDependent()) { $assocType = Application::ASSOC_TYPE_SUBMISSION_FILE_COUNTER_OTHER; diff --git a/pages/issue/IssueHandler.php b/pages/issue/IssueHandler.php index 5192ee7bd06..7ffdd58bf6e 100644 --- a/pages/issue/IssueHandler.php +++ b/pages/issue/IssueHandler.php @@ -39,7 +39,6 @@ use PKP\plugins\PluginRegistry; use PKP\security\authorization\ContextRequiredPolicy; use PKP\security\Validation; -use PKP\submission\GenreDAO; use PKP\submission\PKPSubmission; class IssueHandler extends Handler @@ -351,11 +350,8 @@ public static function _setupIssueTemplate(Request $request, Issue $issue, Journ $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO'); /** @var IssueGalleyDAO $issueGalleyDao */ - $genreDao = DAORegistry::getDAO('GenreDAO'); /** @var GenreDAO $genreDao */ - $primaryGenres = $genreDao->getPrimaryByContextId($journal->getId())->toArray(); - $primaryGenreIds = array_map(function ($genre) { - return $genre->getId(); - }, $primaryGenres); + $primaryGenreIds = Repo::genre()->getPrimaryByContextId($journal->getId())->pluck('id')->toArray(); + // Show scheduled submissions if this is a preview $allowedStatuses = [PKPSubmission::STATUS_PUBLISHED]; diff --git a/plugins/generic/datacite/filter/DataciteXmlFilter.php b/plugins/generic/datacite/filter/DataciteXmlFilter.php index 7abbe2047f7..37166b86a1f 100644 --- a/plugins/generic/datacite/filter/DataciteXmlFilter.php +++ b/plugins/generic/datacite/filter/DataciteXmlFilter.php @@ -30,8 +30,7 @@ use PKP\facades\Locale; use PKP\galley\Galley; use PKP\i18n\LocaleConversion; -use PKP\submission\Genre; -use PKP\submission\GenreDAO; +use PKP\submission\genre\Genre; use PKP\submissionFile\SubmissionFile; // Title types @@ -131,9 +130,8 @@ public function &process(&$pubObject) if ($cache->isCached('genres', $galleyFile->getData('genreId'))) { $genre = $cache->get('genres', $galleyFile->getData('genreId')); } else { - /** @var GenreDAO */ - $genreDao = DAORegistry::getDAO('GenreDAO'); - $genre = $genreDao->getById($galleyFile->getData('genreId')); + $genreId = $galleyFile->getData('genreId'); + $genre = Genre::find($genreId); if ($genre) { $cache->add($genre, null); }