Skip to content

Commit

Permalink
pkp#229 Typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Mar 27, 2023
1 parent 8bdee64 commit a588471
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
5 changes: 3 additions & 2 deletions OrcidProfileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use APP\handler\Handler;
use APP\template\TemplateManager;
use Carbon\Carbon;
use Exception;
use PKP\core\Core;
use PKP\plugins\Hook;
use PKP\plugins\PluginRegistry;
Expand All @@ -36,7 +37,7 @@ class OrcidProfileHandler extends Handler
public const TEMPLATE = 'orcidVerify.tpl';
const ORCIDPROFILEPLUGIN = 'orcidprofileplugin';
private bool $isSandBox;
private ?\PKP\plugins\Plugin $plugin;
private OrcidProfilePlugin $plugin;



Expand Down Expand Up @@ -183,7 +184,7 @@ public function orcidAuthorize($args, $request)
';
break;
default:
assert(false);
throw new Exception('Invalid target');
}
}

Expand Down
18 changes: 11 additions & 7 deletions OrcidProfilePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
define('ORCID_WORK_URL', 'work');
define('ORCID_REVIEW_URL', 'peer-review');

use APP\author\Author;
use APP\controllers\grid\users\author\form\AuthorForm;
use APP\core\Application;
use APP\core\Request;
use APP\core\Services;
Expand All @@ -57,15 +59,16 @@
use PKP\core\JSONMessage;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\form\Form;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
use PKP\plugins\PluginRegistry;
use PKP\services\PKPSchemaService;
use PKP\submission\PKPSubmission;
use PKP\submission\reviewAssignment\ReviewAssignment;
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
use ReviewAssignment;
use Sokil\IsoCodes\IsoCodesFactory;

class OrcidProfilePlugin extends GenericPlugin
Expand Down Expand Up @@ -256,8 +259,8 @@ public function getSetting($contextId, $name)

/**
* adds orcid form fields.
* @param $hookName
* @param $form
* @param string $hookName
* @param Form $form
* @return bool
*/
function addOrcidFormFields($hookName, $form): bool
Expand Down Expand Up @@ -302,8 +305,8 @@ function addOrcidFormFields($hookName, $form): bool
}

/**
* @param $hookName
* @param $args
* @param string $hookName
* @param array $args
*/
function handleThankReviewer($hookName, $args)
{
Expand Down Expand Up @@ -339,9 +342,8 @@ public function publishReviewerWorkToOrcid(Submission $submission, Request $requ
{
$context = $request->getContext();
$requestVars = $request->getUserVars();

/** @var ReviewAssignmentDAO */
$reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
/* @var $reviewAssignmentDao ReviewAssignmentDAO */
$reviewAssignmentId = $requestVars['reviewAssignmentId'];
if (isset($reviewAssignmentId)) {
$review = $reviewAssignmentDao->getById($reviewAssignmentId);
Expand Down Expand Up @@ -587,6 +589,7 @@ public function handleFormDisplay($hookName, $args)
$templateMgr = TemplateManager::getManager($request);
switch ($hookName) {
case 'authorform::display':
/** @var AuthorForm */
$authorForm = &$args[0];
$author = $authorForm->getAuthor();
if ($author) {
Expand Down Expand Up @@ -819,6 +822,7 @@ public function handleUserPublicProfileDisplay($hookName, $params)
public function handleAuthorFormExecute($hookname, $args)
{
if (count($args) == 3) {
/** @var Author */
$author = &$args[0];
$values = $args[2];

Expand Down
10 changes: 6 additions & 4 deletions classes/OrcidValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace APP\plugins\generic\orcidProfile\classes;

class OrcidValidator {
use APP\plugins\generic\orcidProfile\OrcidProfilePlugin;

class OrcidValidator {
public $plugin;
/**
* OrcidValidator constructor.
* @param $plugin
* @param OrcidProfilePlugin $plugin
*/
function __construct(&$plugin) {
$this->plugin =& $plugin;
}

/**
* @param $str
* @param string $str
* @return bool
*/
public function validateClientId($str) {
Expand All @@ -25,7 +27,7 @@ public function validateClientId($str) {
}

/**
* @param $str
* @param string $str
* @return bool
*/
public function validateClientSecret($str) {
Expand Down
7 changes: 4 additions & 3 deletions classes/form/OrcidProfileSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
use APP\core\Application;
use PKP\form\Form;
use APP\plugins\generic\orcidProfile\classes\OrcidValidator;
use APP\plugins\generic\orcidProfile\OrcidProfilePlugin;
use APP\template\TemplateManager;

use PKP\plugins\Plugin;

class OrcidProfileSettingsForm extends Form {

Expand All @@ -45,8 +46,8 @@ class OrcidProfileSettingsForm extends Form {

/**
* Constructor
* @param $plugin object
* @param $contextId int
* @param OrcidProfilePlugin $plugin
* @param int $contextId
*/
function __construct($plugin, $contextId) {
$this->contextId = $contextId;
Expand Down
9 changes: 5 additions & 4 deletions classes/form/OrcidProfileStatusForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

namespace APP\plugins\generic\orcidProfile\classes\form;


use APP\core\Application;
use PKP\form\Form;
use APP\plugins\generic\orcidProfile\classes\OrcidValidator;
use APP\plugins\generic\orcidProfile\OrcidProfilePlugin;
use APP\template\TemplateManager;


Expand All @@ -44,8 +45,8 @@ class OrcidProfileStatusForm extends Form {

/**
* Constructor
* @param $plugin object
* @param $contextId int
* @param OrcidProfilePlugin $plugin
* @param int $contextId
*/
function __construct($plugin, $contextId) {
$this->contextId = $contextId;
Expand Down Expand Up @@ -83,7 +84,7 @@ function fetch($request, $template = null, $display = false) {
$clientSecret = $this->plugin->getSetting($contextId, 'orcidClientSecret');

$templateMgr = TemplateManager::getManager($request);
$aboutUrl = $request->getDispatcher()->url($request, ROUTE_PAGE, null, 'orcidapi', 'about', null);
$aboutUrl = $request->getDispatcher()->url($request, Application::ROUTE_PAGE, null, 'orcidapi', 'about', null);
$templateMgr->assign(array(
'globallyConfigured' => $this->plugin->isGloballyConfigured(),
'orcidAboutUrl' => $aboutUrl,
Expand Down

0 comments on commit a588471

Please sign in to comment.