Skip to content
Snippets Groups Projects
Commit 192270db authored by Dorian Merz's avatar Dorian Merz
Browse files

refs #21064 [fid] fix code style in VuFind sub directory

parent d51e616d
No related merge requests found
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Auth;
......@@ -29,6 +34,15 @@ use VuFind\Db\Row\User as UserRow;
use VuFind\Exception\Auth as AuthException;
use Zend\Http\PhpEnvironment\Request;
/**
* Class Authenticator
*
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class Authenticator extends AbstractBase
{
protected const AUTH_ERROR_BAD_CREDENTIALS
......@@ -44,17 +58,27 @@ class Authenticator extends AbstractBase
= 'fid::auth_error_account_deleted';
/**
* Fid client
*
* @var Client
*/
protected $client;
/**
* Authenticator constructor.
*
* @param Client $client fid client
*/
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* @param Request $request
* {@inheritdoc}
*
* @param Request $request Request object containing
* new account details.
*
* @return VuFindUser|UserRow
* @throws AuthException
......@@ -66,7 +90,10 @@ class Authenticator extends AbstractBase
}
/**
* @param Request $request
* {@inheritdoc}
*
* @param Request $request Request object containing
* account credentials.
*
* @return VuFindUser|UserRow
* @throws AuthException
......@@ -94,9 +121,7 @@ class Authenticator extends AbstractBase
throw new AuthException(self::AUTH_ERROR_ACCOUNT_BLOCKED);
}
/**
* @var User $user
*/
/* @var User $user */
$user = $this->client->requestUserDetails();
if ($user->isDeleted()) {
$this->client->logoff();
......@@ -104,9 +129,7 @@ class Authenticator extends AbstractBase
}
if ($ownerId = $logon->getOwnerId()) {
/**
* @var VuFindUser $userRow
*/
/* @var VuFindUser $userRow */
$userRow = $this->getUserTable()->getByUsername($ownerId);
return $userRow;
......@@ -117,7 +140,9 @@ class Authenticator extends AbstractBase
}
/**
* @param string $url
* {@inheritdoc}
*
* @param string $url URL to redirect user to after logging out.
*
* @return string
* @throws ClientException
......@@ -129,6 +154,8 @@ class Authenticator extends AbstractBase
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function isExpired()
......@@ -136,11 +163,21 @@ class Authenticator extends AbstractBase
return !$this->client->isLoggedOn();
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function supportsCreation()
{
return true;
}
/**
* {@ineritdoc}
*
* @return bool
*/
public function supportsPasswordRecovery()
{
return true;
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,21 +17,38 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Auth;
use fid\Service\Client;
use Psr\Container\ContainerInterface;
/**
* Class AuthenticatorFactory
*
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class AuthenticatorFactory
{
/**
* Create an Authenticator object
*
* @param ContainerInterface $container Service container
*
* @return Authenticator
*/
public function __invoke(ContainerInterface $container)
{
/**
* @var Client $client
*/
/* @var Client $client */
$client = $container->get(Client::class);
return new Authenticator($client);
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Auth;
......@@ -24,19 +29,37 @@ use fid\Service\Client;
use fid\Service\ClientException;
use fid\Service\UserNotAuthorizedException;
/**
* Class ILSAuthenticator
*
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class ILSAuthenticator
{
/**
* Fid Client
*
* @var Client
*/
protected $client;
/**
* ILSAuthenticator constructor.
*
* @param Client $client fid Client
*/
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* Attempt to log in the user to the backend, and save credentials if it works.
*
* @return array|null
* @throws ClientException
* @throws UserNotAuthorizedException
......@@ -47,6 +70,8 @@ class ILSAuthenticator
}
/**
* Log the current user into the catalog using stored credentials.
*
* @return array|null
* @throws ClientException
* @throws UserNotAuthorizedException
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Auth;
......@@ -25,15 +30,33 @@ use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use Psr\Container\ContainerInterface;
use VuFind\Auth\ILSAuthenticator as ProxyClass;
/**
* Class ILSAuthenticatorFactory
*
* @category VuFind
* @package Auth
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class ILSAuthenticatorFactory
{
/**
* Create ILSAuthenticator object
*
* @param ContainerInterface $container Service container
*
* @return \ProxyManager\Proxy\VirtualProxyInterface
*/
public function __invoke(ContainerInterface $container)
{
$factory = new LazyLoadingValueHolderFactory();
return $factory->createProxy(
ProxyClass::class,
function (&$object, $proxy, $method, $params, &$initializer) use ($container) {
function (
&$object, $proxy, $method, $params, &$initializer
) use ($container) {
$initializer = null;
$client = $container->get(Client::class);
$object = new ILSAuthenticator($client);
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package Db
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Db\Row;
......@@ -24,20 +29,40 @@ use fid\Service\Client;
use fid\Service\ClientException;
use VuFind\Db\Row\User as BaseUser;
/**
* Class User
*
* @category VuFind
* @package Db
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class User extends BaseUser
{
/**
* Fid client
*
* @var Client
*/
protected $client;
/**
* Setter for fid client
*
* @param Client $client fid client
*
* @return void
*/
public function setClient(Client $client)
{
$this->client = $client;
}
/**
* @param string $offset
* Read data from user
*
* @param string $offset name of user field to read data from
*
* @return mixed|string|null
* @throws ClientException
......@@ -47,11 +72,27 @@ class User extends BaseUser
return $this->readUserFields($offset) ?: parent::offsetGet($offset);
}
/**
* Magic getter function. Reads user fields
*
* @param string $name field name
*
* @return false|mixed|string
*/
public function __get($name)
{
return $this->readUserFields($name) ?: parent::__get($name);
}
/**
* Reads user fields from client
*
* @param string $offset name of user field to read from
*
* @return false|string|null
* @throws ClientException
* @throws \fid\Service\UserNotAuthorizedException
*/
protected function readUserFields($offset)
{
$user = $this->client->requestUserDetails();
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,24 +17,44 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package Db
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Db\Row;
use fid\Service\Client;
use Psr\Container\ContainerInterface;
/**
* Class UserDelegatorFactory
* Adds Client to user object on creation
*
* @category VuFind
* @package Db
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class UserDelegatorFactory
{
/**
* Adds Client to user object on creation
*
* @param ContainerInterface $container service container
* @param string $name name of class to instantiate
* @param callable $callback constructor callback
*
* @return User
*/
public function __invoke(
ContainerInterface $container,
$name,
callable $callback
) {
/**
* @var User $user
*/
/* @var User $user */
$user = call_user_func($callback);
$user->setClient($container->get(Client::class));
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package ILS
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\ILS;
......@@ -25,23 +30,47 @@ use fid\Service\ClientException;
use VuFind\Exception\ILS as ILSException;
use VuFind\ILS\Driver\AbstractBase;
/**
* Class Fid
*
* @category VuFind
* @package ILS
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class Fid extends AbstractBase
{
/**
* Fid client
*
* @var Client
*/
protected $client;
/**
* Fid constructor.
*
* @param Client $client fid client
*/
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* Initialize the Fid object
*
* @return void
*/
public function init()
{
// intentionally left blank
}
/**
* Login user
*
* @return array|null
* @throws ClientException
*/
......@@ -56,26 +85,66 @@ class Fid extends AbstractBase
return ['id' => $user->getId()];
}
/**
* Method should not be called
*
* @param string $id Record id
*
* @return mixed|void
* @throws ILSException
*/
public function getStatus($id)
{
throw new ILSException('Method not available');
}
/**
* Method should not be called
*
* @param array $ids Record ids
*
* @return array|void
* @throws ILSException
*/
public function getStatuses($ids)
{
throw new ILSException('Method not available');
}
/**
* Method should not be called
*
* @param string $id Record id
* @param array|null $patron patron data
*
* @return array|void
* @throws ILSException
*/
public function getHolding($id, array $patron = null)
{
throw new ILSException('Method not available');
}
/**
* Method should not be called
*
* @param string $id Record id
*
* @return array|void
* @throws ILSException
*/
public function getPurchaseHistory($id)
{
throw new ILSException('Method not available');
}
/**
* Return patron data as is
*
* @param mixed $patron patron data
*
* @return mixed
*/
public function getMyProfile($patron)
{
return $patron;
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) 2019 Leipzig University Library
*
* PHP version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -15,21 +17,38 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @category VuFind
* @package ILS
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\ILS;
use fid\Service\Client;
use Psr\Container\ContainerInterface;
/**
* Class FidFactory
*
* @category VuFind
* @package ILS
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class FidFactory
{
/**
* Create an Fid object
*
* @param ContainerInterface $container Service container
*
* @return Fid
*/
public function __invoke(ContainerInterface $container): Fid
{
/**
* @var Client $client
*/
/* @var Client $client */
$client = $container->get(Client::class);
return new Fid($client);
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) Leipzig University Library 2019.
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @category VuFind
* @package Resolver
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Resolver\Driver;
......@@ -29,12 +34,19 @@ use Zend\Config\Config;
/**
* Class Ezb
* Driver for EZB link resolver
*
* @package fid\VuFind\Resolver\Driver
* @category VuFind
* @package Resolver
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class Ezb extends BaseEzb
{
/**
* Link resolver configuration
*
* @var Config
*/
protected $config;
......@@ -60,12 +72,26 @@ class Ezb extends BaseEzb
*/
protected $baseUrl;
/**
* Collected record messages
*
* @var array
*/
protected $messages = [];
/**
* Collected states of results
*
* @var array
*/
protected $stateOfResults = [];
/**
* @param Config $config
* Setter for $config
*
* @param Config $config resolver configuration
*
* @return void
*/
public function setConfig(Config $config): void
{
......@@ -73,7 +99,11 @@ class Ezb extends BaseEzb
}
/**
* @param Client $fidClient
* Setter for $fidClient
*
* @param Client $fidClient fid client
*
* @return void
*/
public function setFidClient(Client $fidClient): void
{
......@@ -81,7 +111,11 @@ class Ezb extends BaseEzb
}
/**
* @param Connection $ils
* Setter for $ils
*
* @param Connection $ils ILS connection
*
* @return void
*/
public function setIls(Connection $ils): void
{
......@@ -89,7 +123,11 @@ class Ezb extends BaseEzb
}
/**
* @param string $baseUrl
* Setter for $baseUrl
*
* @param string $baseUrl resolver's base URL
*
* @return void
*/
public function setBaseUrl(string $baseUrl): void
{
......@@ -100,8 +138,9 @@ class Ezb extends BaseEzb
* Fetch Links
* Fetches a set of links corresponding to an OpenURL
*
* @param string $openURL openURL (url-encoded)*
* @return string raw XML returned by resolver
* @param string $openURL openURL (url-encoded)*
*
* @return string raw XML returned by resolver
*/
public function fetchLinks($openURL)
{
......@@ -268,7 +307,8 @@ class Ezb extends BaseEzb
"Result[@state={$state}][" . ($i + 1) . "]/AccessLevel";
$accessLevel = $xpath->query($accessLevelXP, $result)->item(0);
if (isset($accessLevel)) {
$record['title'] = $accessLevel_mapping[strip_tags($accessLevel->nodeValue)];
$record['title']
= $accessLevel_mapping[strip_tags($accessLevel->nodeValue)];
}
// set message of the record
......@@ -286,8 +326,8 @@ class Ezb extends BaseEzb
$record['href'] = $journalUrl->nodeValue;
}
$stateOfResultXP = "/OpenURLResponseXML/Full/ElectronicData/ResultList/" .
"Result/@state";
$stateOfResultXP = "/OpenURLResponseXML/Full/ElectronicData/".
"ResultList/Result/@state";
$stateOfResult = $xpath->query($stateOfResultXP, $result)->item(0);
if (isset($stateOfResult->nodeValue)) {
$this->stateOfResults[] = $stateOfResult->nodeValue;
......
......@@ -2,6 +2,8 @@
/**
* Copyright (C) Leipzig University Library 2019.
*
* PHP Version 7
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
......@@ -15,8 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @category VuFind
* @package Resolver
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid\VuFind\Resolver\Driver;
......@@ -24,13 +29,26 @@ use fid\Service\Client;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
/**
* Class EzbDelegatorFactory
*
* @category VuFind
* @package Resolver
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class EzbDelegatorFactory implements DelegatorFactoryInterface
{
/**
* @param ContainerInterface $container
* @param string $name
* @param callable $callback
* @param array|null $options
* Create an Ezb object and set
* config, fid client, ILS connection, and base URL
*
* @param ContainerInterface $container Service container
* @param string $name class name for object to create
* @param callable $callback instantiation callback
* @param array|null $options options
*
* @return Ezb|object
*/
public function __invoke(
......@@ -42,9 +60,7 @@ class EzbDelegatorFactory implements DelegatorFactoryInterface
$ezbConfig = $container->get('VuFind\Config')->get('Resolver');
$fidClient = $container->get(Client::class);
$ils = $container->get('VuFind\ILS\Connection');
/**
* @var Ezb $ezb
*/
/* @var Ezb $ezb */
$ezb = call_user_func($callback);
$ezb->setConfig($ezbConfig->Ezb);
$ezb->setFidClient($fidClient);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment