Skip to content

Commit

Permalink
pkp/pkp-lib#9913 removed pimple dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir authored and asmecher committed Aug 1, 2024
1 parent 1b6cd7a commit 340b86b
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 126 deletions.
3 changes: 1 addition & 2 deletions api/v1/submissions/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace APP\API\v1\submissions;

use APP\core\Services;
use APP\facades\Repo;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -122,7 +121,7 @@ public function relatePublication(Request $illuminateRequest): JsonResponse
// Validate against the schema
$submissionContext = $request->getContext();
if (!$submissionContext || $submissionContext->getId() !== $submission->getData('contextId')) {
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
$submissionContext = app()->get('context')->get($submission->getData('contextId'));
}

$errors = Repo::publication()->validate($publication, $params, $submission, $submissionContext);
Expand Down
26 changes: 20 additions & 6 deletions classes/core/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
/**
* @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\StatsEditorialService;
use APP\services\StatsPublicationService;
use PKP\core\PKPRequest;

class AppServiceProvider extends \PKP\core\AppServiceProvider
Expand All @@ -29,5 +31,17 @@ public function register()
parent::register();

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

// 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\OPSServiceProvider());
}
}

if (!PKP_STRICT_MODE) {
Expand Down
3 changes: 1 addition & 2 deletions classes/search/PreprintSearch.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\server\Server;
use PKP\db\DAORegistry;
Expand Down Expand Up @@ -74,7 +73,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
84 changes: 0 additions & 84 deletions classes/services/OPSServiceProvider.php

This file was deleted.

3 changes: 1 addition & 2 deletions classes/submission/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace APP\submission;

use APP\core\Application;
use APP\core\Services;
use APP\facades\Repo;
use APP\preprint\PreprintTombstoneManager;
use APP\section\Section;
Expand Down Expand Up @@ -91,7 +90,7 @@ public function updateStatus(Submission $submission, ?int $newStatus = null, ?Se
if ($requestContext && $requestContext->getId() === $submission->getData('contextId')) {
$context = $requestContext;
} else {
$context = Services::get('context')->get($submission->getData('contextId'));
$context = app()->get('context')->get($submission->getData('contextId'));
}
$preprintTombstoneManager = new PreprintTombstoneManager();
if (!$section) {
Expand Down
5 changes: 2 additions & 3 deletions classes/submission/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace APP\submission;

use APP\core\Services;
use APP\facades\Repo;
use APP\publication\Publication;
use APP\statistics\StatisticsHelper;
Expand Down Expand Up @@ -56,7 +55,7 @@ class Submission extends PKPSubmission
*/
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 Submission::PERMISSIONS_FIELD_LICENSE_URL:
Expand Down Expand Up @@ -144,7 +143,7 @@ public function getTotalGalleyViews()
'contextIds' => [$this->getData('contextId')],
'fileIds' => $fileIds,
];
$metrics = Services::get('publicationStats')
$metrics = app()->get('publicationStats')
->getQueryBuilder($filters)
->getSum([])
->value('metric');
Expand Down
3 changes: 1 addition & 2 deletions classes/sushi/IR.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 @@ -199,7 +198,7 @@ public function getReportItems(): array
}
// 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
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 @@ -135,7 +134,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 pages/authorDashboard/AuthorDashboardHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use APP\components\forms\publication\PublishForm;
use APP\core\Application;
use APP\core\PageRouter;
use APP\core\Services;
use APP\facades\Repo;
use APP\publication\Publication;
use APP\template\TemplateManager;
Expand All @@ -45,7 +44,7 @@ public function setupTemplate($request)

$submissionContext = $request->getContext();
if ($submission->getData('contextId') !== $submissionContext->getId()) {
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
$submissionContext = app()->get('context')->get($submission->getData('contextId'));
}

$locales = $submissionContext->getSupportedFormLocaleNames();
Expand Down
7 changes: 3 additions & 4 deletions pages/preprint/PreprintHandler.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\observers\events\UsageEvent;
Expand Down Expand Up @@ -374,11 +373,11 @@ public function download($args, $request)
if (!Hook::call('PreprintHandler::download', [$this->preprint, &$this->galley, &$this->submissionFileId])) {
$submissionFile = Repo::submissionFile()->get($this->submissionFileId);

if (!Services::get('file')->fs->has($submissionFile->getData('path'))) {
if (!app()->get('file')->fs->has($submissionFile->getData('path'))) {
$request->getDispatcher()->handle404();
}

$filename = Services::get('file')->formatFilename($submissionFile->getData('path'), $submissionFile->getLocalizedData('name'));
$filename = app()->get('file')->formatFilename($submissionFile->getData('path'), $submissionFile->getLocalizedData('name'));

// 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) {
Expand All @@ -395,7 +394,7 @@ public function download($args, $request)
$returner = true;
Hook::call('FileManager::downloadFileFinished', [&$returner]);

Services::get('file')->download($submissionFile->getData('fileId'), $filename);
app()->get('file')->download($submissionFile->getData('fileId'), $filename);
}
} else {
header('HTTP/1.0 403 Forbidden');
Expand Down
3 changes: 1 addition & 2 deletions pages/workflow/WorkflowHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace APP\pages\workflow;

use APP\core\Application;
use APP\core\Services;
use APP\decision\types\Decline;
use APP\decision\types\RevertDecline;
use APP\facades\Repo;
Expand Down Expand Up @@ -70,7 +69,7 @@ public function setupIndex($request)

$submissionContext = $request->getContext();
if ($submission->getData('contextId') !== $submissionContext->getId()) {
$submissionContext = Services::get('context')->get($submission->getData('contextId'));
$submissionContext = app()->get('context')->get($submission->getData('contextId'));
}

$latestPublication = $submission->getLatestPublication();
Expand Down
2 changes: 0 additions & 2 deletions tools/buildpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ plugins/generic/citationStyleLanguage/lib/vendor/guzzle/guzzle/tests/Guzzle/Test
plugins/generic/citationStyleLanguage/lib/vendor/symfony/config/Tests/ \
lib/pkp/lib/vendor/symfony/translation/Tests/ \
lib/pkp/lib/vendor/symfony/process/Tests/ \
lib/pkp/lib/vendor/pimple/pimple/src/Pimple/Tests/ \
lib/pkp/lib/vendor/robloach/component-installer/tests/ComponentInstaller/Test/ \
lib/pkp/lib/vendor/michelf/php-markdown/test \
plugins/generic/citationStyleLanguage/lib/vendor/satooshi/php-coveralls/tests/ \
Expand All @@ -87,7 +86,6 @@ plugins/generic/citationStyleLanguage/lib/vendor/seboettg/citeproc-php/example/
lib/pkp/lib/vendor/nikic/fast-route/test/ \
lib/pkp/lib/vendor/ezyang/htmlpurifier/tests/ \
lib/pkp/lib/vendor/ezyang/htmlpurifier/smoketests/ \
lib/pkp/lib/vendor/pimple/pimple/ext/pimple/tests/ \
lib/pkp/lib/vendor/robloach/component-installer/tests/ \
lib/pkp/lib/vendor/swiftmailer/swiftmailer/tests/ \
lib/pkp/lib/vendor/dragonmantank/cron-expression/tests/ \
Expand Down

0 comments on commit 340b86b

Please sign in to comment.