Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9913 removed pimple dependency #1633

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions classes/core/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
/**
* @file classes/core/AppServiceProvider.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class AppServiceProvider
*
* @ingroup core
*
* @brief Resolves requests for application classes such as the request handler
* to support dependency injection
* @brief Resolves requests for application classes such as the request handler
* to support dependency injection
*/

namespace APP\core;

use APP\services\ContextService;
use APP\services\NavigationMenuService;
use APP\services\PublicationFormatService;
use APP\services\StatsEditorialService;
use APP\services\StatsPublicationService;
use PKP\core\PKPRequest;
use PKP\submissionFile\Collector as SubmissionFileCollector;
use PKP\submissionFile\SubmissionFile as BaseSubmissionFile;

class AppServiceProvider extends \PKP\core\AppServiceProvider
{
Expand All @@ -32,7 +33,19 @@ public function register()

$this->app->bind(Request::class, PKPRequest::class);

$this->app->bind(\APP\submissionFile\Collector::class, SubmissionFileCollector::class);
$this->app->bind(\APP\submissionFile\SubmissionFile::class, BaseSubmissionFile::class);
// Publication Format service
$this->app->singleton('publicationFormat', fn ($app) => new PublicationFormatService());

// Navigation Menu service
$this->app->singleton('navigationMenu', fn ($app) => new NavigationMenuService());

// Context service
$this->app->singleton('context', fn ($app) => new ContextService());

// Publication statistics service
$this->app->singleton('publicationStats', fn ($app) => new StatsPublicationService());

// Editorial statistics service
$this->app->singleton('editorialStats', fn ($app) => new StatsEditorialService());
}
}
18 changes: 5 additions & 13 deletions classes/core/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,22 @@
/**
* @file classes/core/Services.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Services
*
* @ingroup core
*
* @see Core
*
* @brief Pimple Dependency Injection Container.
*
* @deprecated 3.5.0 Consider using {@see app()->get('SERVICE_NAME')}
* @see app()->get('SERVICE_NAME')
*/

namespace APP\core;

class Services extends \PKP\core\PKPServices
{
/**
* container initialization
*/
protected function init()
{
$this->container->register(new \APP\services\OMPServiceProvider());
}
}

if (!PKP_STRICT_MODE) {
Expand Down
13 changes: 6 additions & 7 deletions classes/publication/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace APP\publication;

use APP\core\Application;
use APP\core\Services;
use APP\facades\Repo;
use APP\file\PublicFileManager;
use APP\monograph\ChapterDAO;
Expand Down Expand Up @@ -74,7 +73,7 @@ public function add(Publication $publication): int
$submission = Repo::submission()->get($publication->getData('submissionId'));
$submissionContext = $this->request->getContext();
if ($submissionContext->getId() !== $submission->getData('contextId')) {
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
$submissionContext = app()->get('context')->get($submission->getData('contextId'));
}

$supportedLocales = $submission->getPublicationLanguages($submissionContext->getSupportedSubmissionMetadataLocales());
Expand Down Expand Up @@ -258,7 +257,7 @@ public function edit(Publication $publication, array $params): Publication
$submission = Repo::submission()->get($publication->getData('submissionId'));
$submissionContext = $this->request->getContext();
if ($submissionContext->getId() !== $submission->getData('contextId')) {
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
$submissionContext = app()->get('context')->get($submission->getData('contextId'));
}

foreach ($params['coverImage'] as $localeKey => $newCoverImage) {
Expand Down Expand Up @@ -301,7 +300,7 @@ public function publish(Publication $publication)
if ($submission->getData('currentPublicationId') === $publication->getId()) {
$context = $this->request->getContext();
if (!$context || $context->getId() !== $submission->getData('contextId')) {
$context = Services::get('context')->get($submission->getData('contextId'));
$context = app()->get('context')->get($submission->getData('contextId'));
}

// Remove publication format tombstones for this publication
Expand Down Expand Up @@ -350,7 +349,7 @@ public function unpublish(Publication $publication)
parent::unpublish($publication);

$submission = Repo::submission()->get($publication->getData('submissionId'));
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
$submissionContext = app()->get('context')->get($submission->getData('contextId'));

// Create tombstones for this publication
$publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
Expand Down Expand Up @@ -384,12 +383,12 @@ public function unpublish(Publication $publication)
public function delete(Publication $publication)
{
$submission = Repo::submission()->get($publication->getData('submissionId'));
$context = Services::get('context')->get($submission->getData('contextId'));
$context = app()->get('context')->get($submission->getData('contextId'));

// Delete Publication Formats (and all related objects)
$publicationFormats = $publication->getData('publicationFormats');
foreach ($publicationFormats as $publicationFormat) {
Services::get('publicationFormat')->deleteFormat($publicationFormat, $submission, $context);
app()->get('publicationFormat')->deleteFormat($publicationFormat, $submission, $context);
}

// Delete chapters and assigned chapter authors.
Expand Down
3 changes: 1 addition & 2 deletions classes/publicationFormat/PublicationFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

use APP\codelist\ONIXCodelistItemDAO;
use APP\core\Application;
use APP\core\Services;
use APP\facades\Repo;
use PKP\db\DAORegistry;
use PKP\db\DAOResultFactory;
Expand Down Expand Up @@ -322,7 +321,7 @@ public function getCalculatedFileSize()

foreach ($stageMonographFiles as $monographFile) {
if ($monographFile->getViewable()) {
$fileSize += (int) Services::get('file')->fs->fileSize($monographFile->getData('path'));
$fileSize += (int) app()->get('file')->fs->fileSize($monographFile->getData('path'));
}
}

Expand Down
3 changes: 1 addition & 2 deletions classes/search/MonographSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

use APP\core\Application;
use APP\core\Request;
use APP\core\Services;
use APP\facades\Repo;
use APP\press\Press;
use PKP\db\DAORegistry;
Expand Down Expand Up @@ -69,7 +68,7 @@ public function getSparseArray($unorderedResults, $orderBy, $orderDir, $exclude)
$filter['dateStart'] = $oneMonthAgo;
$filter['dateEnd'] = $today;
}
$rawReport = Services::get('publicationStats')->getTotals($filter);
$rawReport = app()->get('publicationStats')->getTotals($filter);
foreach ($rawReport as $row) {
$unorderedResults[$row->submission_id]['metric'] = $row->metric;
}
Expand Down
90 changes: 0 additions & 90 deletions classes/services/OMPServiceProvider.php

This file was deleted.

3 changes: 1 addition & 2 deletions classes/submission/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

namespace APP\submission;

use APP\core\Services;
use APP\facades\Repo;
use APP\publication\Publication;
use PKP\submission\PKPSubmission;
Expand Down Expand Up @@ -56,7 +55,7 @@ public function getSectionId()
*/
public function _getContextLicenseFieldValue($locale, $field, $publication = null)
{
$context = Services::get('context')->get($this->getData('contextId'));
$context = app()->get('context')->get($this->getData('contextId'));
$fieldValue = null; // Scrutinizer
switch ($field) {
case static::PERMISSIONS_FIELD_LICENSE_URL:
Expand Down
3 changes: 1 addition & 2 deletions classes/sushi/PR.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace APP\sushi;

use APP\core\Services;
use PKP\statistics\PKPStatisticsHelper;
use PKP\sushi\CounterR5Report;

Expand Down Expand Up @@ -144,7 +143,7 @@ public function getReportItems(): array
$params['dateEnd'] = $this->endDate;
// do not consider metric_type filter now, but for display

$statsService = Services::get('sushiStats');
$statsService = app()->get('sushiStats');
$metricsQB = $statsService->getQueryBuilder($params);
$groupBy = [];
// consider granularity=Month to group the metrics by month
Expand Down
3 changes: 1 addition & 2 deletions classes/sushi/TR.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace APP\sushi;

use APP\core\Services;
use APP\facades\Repo;
use PKP\statistics\PKPStatisticsHelper;
use PKP\sushi\CounterR5Report;
Expand Down Expand Up @@ -193,7 +192,7 @@ public function getReportItems(): array
// do not consider section_type filter now, but later when grouping by submission
// do not consider metric_type filter now, but for display

$statsService = Services::get('sushiStats');
$statsService = app()->get('sushiStats');
$metricsQB = $statsService->getQueryBuilder($params);
// consider attributes to group the metrics by
$groupBy = ['m.' . PKPStatisticsHelper::STATISTICS_DIMENSION_SUBMISSION_ID];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use APP\controllers\tab\pubIds\form\PublicIdentifiersForm;
use APP\core\Application;
use APP\core\Request;
use APP\core\Services;
use APP\facades\Repo;
use APP\log\event\SubmissionEventLogEntry;
use APP\notification\NotificationManager;
Expand Down Expand Up @@ -347,7 +346,7 @@ public function deleteFormat($args, $request)
}

/** @var PublicationFormatService */
$publicationFormatService = Services::get('publicationFormat');
$publicationFormatService = app()->get('publicationFormat');
$publicationFormatService->deleteFormat($representation, $submission, $context);

$currentUser = $request->getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace APP\controllers\grid\navigationMenus\form;

use APP\core\Application;
use APP\core\Services;
use APP\facades\Repo;
use APP\section\Section;
use APP\services\NavigationMenuService;
Expand All @@ -35,7 +34,7 @@ class NavigationMenuItemsForm extends PKPNavigationMenuItemsForm
*/
public function fetch($request, $template = null, $display = false)
{
$customTemplates = Services::get('navigationMenu')->getMenuItemCustomEditTemplates();
$customTemplates = app()->get('navigationMenu')->getMenuItemCustomEditTemplates();

$request = Application::get()->getRequest();
$context = $request->getContext();
Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 85 files
+1 −2 api/v1/_library/PKPLibraryController.php
+1 −2 api/v1/_payments/PKPBackendPaymentsSettingsController.php
+10 −11 api/v1/contexts/PKPContextController.php
+3 −4 api/v1/site/PKPSiteController.php
+11 −12 api/v1/stats/contexts/PKPStatsContextController.php
+2 −3 api/v1/stats/editorial/PKPStatsEditorialController.php
+8 −9 api/v1/stats/publications/PKPStatsPublicationController.php
+6 −7 api/v1/submissions/PKPSubmissionController.php
+6 −7 api/v1/submissions/PKPSubmissionFileController.php
+1 −2 api/v1/temporaryFiles/PKPTemporaryFilesController.php
+1 −2 classes/author/Repository.php
+1 −2 classes/components/fileAttachers/ReviewFiles.php
+1 −2 classes/components/forms/site/PKPSiteConfigForm.php
+2 −3 classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php
+32 −17 classes/core/AppServiceProvider.php
+1 −2 classes/core/Dispatcher.php
+1 −2 classes/core/PKPBaseController.php
+10 −64 classes/core/PKPServices.php
+5 −6 classes/db/SchemaDAO.php
+1 −2 classes/decision/Repository.php
+1 −2 classes/decision/types/traits/IsRecommendation.php
+1 −2 classes/doi/RegistrationAgencySettings.php
+1 −2 classes/doi/Repository.php
+1 −2 classes/emailTemplate/DAO.php
+1 −2 classes/emailTemplate/Repository.php
+1 −3 classes/file/PKPFile.php
+1 −2 classes/galley/Galley.php
+1 −2 classes/install/PKPInstall.php
+1 −2 classes/institution/Repository.php
+3 −4 classes/jats/Repository.php
+1 −2 classes/mail/Mailable.php
+0 −1 classes/mail/mailables/ChangeProfileEmailInvitationNotify.php
+1 −2 classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php
+1 −2 classes/migration/upgrade/v3_4_0/I6782_UsageStatsSettings.php
+1 −2 classes/migration/upgrade/v3_4_0/InstallEmailTemplates.php
+1 −2 classes/migration/upgrade/v3_5_0/I9860_EditorialMastheadNavMenuItem.php
+1 −2 classes/migration/upgrade/v3_5_0/InstallEmailTemplates.php
+1 −2 classes/plugins/ThemePlugin.php
+1 −2 classes/publication/PKPPublication.php
+6 −7 classes/publication/Repository.php
+1 −2 classes/section/Repository.php
+6 −7 classes/services/PKPContextService.php
+3 −4 classes/services/PKPSiteService.php
+2 −3 classes/site/SiteDAO.php
+2 −3 classes/submission/Repository.php
+1 −2 classes/submission/action/EditorAction.php
+4 −5 classes/submissionFile/Repository.php
+1 −2 classes/submissionFile/SubmissionFile.php
+2 −3 classes/submissionFile/maps/Schema.php
+1 −2 classes/sushi/CounterR5Report.php
+1 −2 classes/task/DepositDois.php
+1 −2 classes/task/EditorialReminders.php
+3 −4 classes/task/PKPUsageStatsLoader.php
+1 −2 classes/task/PublishSubmissions.php
+3 −4 classes/template/PKPTemplateManager.php
+1 −2 classes/userGroup/Repository.php
+0 −1 composer.json
+0 −53 composer.lock
+4 −5 controllers/api/file/FileApiHandler.php
+1 −2 controllers/api/file/PKPManageFileApiHandler.php
+2 −3 controllers/grid/admin/context/ContextGridHandler.php
+1 −2 controllers/grid/admin/languages/AdminLanguageGridHandler.php
+3 −4 controllers/grid/languages/LanguageGridHandler.php
+1 −2 controllers/grid/languages/form/AddLanguageForm.php
+1 −2 controllers/grid/navigationMenus/NavigationMenuItemsGridCellProvider.php
+1 −2 controllers/grid/navigationMenus/NavigationMenusGridCellProvider.php
+3 −4 controllers/grid/navigationMenus/form/NavigationMenuForm.php
+4 −5 controllers/grid/navigationMenus/form/PKPNavigationMenuItemsForm.php
+1 −2 controllers/grid/settings/languages/ManageLanguageGridHandler.php
+1 −2 controllers/grid/users/author/form/PKPAuthorForm.php
+1 −2 controllers/grid/users/reviewer/form/AdvancedSearchReviewerForm.php
+1 −2 controllers/modals/publish/PublishHandler.php
+1 −2 controllers/wizard/fileUpload/form/SubmissionFilesUploadForm.php
+1 −2 jobs/email/EditorialReminder.php
+4 −5 jobs/notifications/StatisticsReportMail.php
+2 −3 jobs/statistics/CompileMonthlyMetrics.php
+3 −4 pages/admin/AdminHandler.php
+1 −2 pages/authorDashboard/PKPAuthorDashboardHandler.php
+1 −2 pages/navigationMenu/NavigationMenuItemHandler.php
+6 −7 pages/stats/PKPStatsHandler.php
+1 −2 pages/workflow/PKPWorkflowHandler.php
+1 −2 plugins/importexport/native/filter/NativeXmlSubmissionFileFilter.php
+1 −2 tools/buildSwagger.php
+2 −3 tools/reprocessUsageStatsMonth.php
+1 −2 tools/setVersionTool.php
7 changes: 3 additions & 4 deletions pages/catalog/CatalogBookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use APP\core\Application;
use APP\core\Request;
use APP\core\Services;
use APP\facades\Repo;
use APP\handler\Handler;
use APP\monograph\Chapter;
Expand Down Expand Up @@ -390,7 +389,7 @@ public function download($args, $request, $view = false)
}

$path = $submissionFile->getData('path');
$filename = Services::get('file')->formatFilename($path, $submissionFile->getLocalizedData('name'));
$filename = app()->get('file')->formatFilename($path, $submissionFile->getLocalizedData('name'));
switch ($submissionFile->getData('assocType')) {
case Application::ASSOC_TYPE_PUBLICATION_FORMAT: // Publication format file
if ($submissionFile->getData('assocId') != $publicationFormat->getId() || $submissionFile->getDirectSalesPrice() === null) {
Expand All @@ -403,7 +402,7 @@ public function download($args, $request, $view = false)
if (!$genre->getDependent()) {
$dispatcher->handle404();
}
return Services::get('file')->download($submissionFile->getData('fileId'), $filename);
return app()->get('file')->download($submissionFile->getData('fileId'), $filename);
default: $dispatcher->handle404();
}

Expand Down Expand Up @@ -464,7 +463,7 @@ public function download($args, $request, $view = false)
}
$returner = true;
Hook::call('FileManager::downloadFileFinished', [&$returner]);
return Services::get('file')->download($submissionFile->getData('fileId'), $filename, $inline);
return app()->get('file')->download($submissionFile->getData('fileId'), $filename, $inline);
}

// Fall-through: user needs to pay for purchase.
Expand Down
Loading