-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use templates to render account status notifications server-side.
Requires less JS code and makes it easier to customize the notification badges.
- Loading branch information
1 parent
97657b1
commit aa71bd5
Showing
17 changed files
with
406 additions
and
129 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
module/VuFind/src/VuFind/AjaxHandler/AbstractIlsUserAndRendererAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Abstract base class for handlers depending on the ILS, a logged-in user and view renderer. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) Villanova University 2018. | ||
* | ||
* 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. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package AJAX | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development Wiki | ||
*/ | ||
|
||
namespace VuFind\AjaxHandler; | ||
|
||
use Laminas\View\Renderer\PhpRenderer; | ||
use VuFind\Auth\ILSAuthenticator; | ||
use VuFind\Db\Entity\UserEntityInterface; | ||
use VuFind\I18n\Translator\TranslatorAwareInterface; | ||
use VuFind\ILS\Connection; | ||
use VuFind\Session\Settings as SessionSettings; | ||
|
||
/** | ||
* Abstract base class for handlers depending on the ILS and a logged-in user. | ||
* | ||
* @category VuFind | ||
* @package AJAX | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development Wiki | ||
*/ | ||
abstract class AbstractIlsUserAndRendererAction extends AbstractBase implements TranslatorAwareInterface | ||
{ | ||
use \VuFind\I18n\Translator\TranslatorAwareTrait; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param SessionSettings $ss Session settings | ||
* @param Connection $ils ILS connection | ||
* @param ILSAuthenticator $ilsAuthenticator ILS authenticator | ||
* @param ?UserEntityInterface $user Logged in user (or null) | ||
* @param PhpRenderer $renderer View renderer | ||
*/ | ||
public function __construct( | ||
SessionSettings $ss, | ||
protected Connection $ils, | ||
protected ILSAuthenticator $ilsAuthenticator, | ||
protected ?UserEntityInterface $user, | ||
protected PhpRenderer $renderer | ||
) { | ||
$this->sessionSettings = $ss; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
module/VuFind/src/VuFind/AjaxHandler/AbstractIlsUserAndRendererActionFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/** | ||
* Factory for AbstractIlsUserAndRendererAction AJAX handlers. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) Villanova University 2018. | ||
* | ||
* 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. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package AJAX | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development Wiki | ||
*/ | ||
|
||
namespace VuFind\AjaxHandler; | ||
|
||
use Laminas\ServiceManager\Exception\ServiceNotCreatedException; | ||
use Laminas\ServiceManager\Exception\ServiceNotFoundException; | ||
use Psr\Container\ContainerExceptionInterface as ContainerException; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** | ||
* Factory for AbstractIlsAndUserAction AJAX handlers. | ||
* | ||
* @category VuFind | ||
* @package AJAX | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development Wiki | ||
*/ | ||
class AbstractIlsUserAndRendererActionFactory implements \Laminas\ServiceManager\Factory\FactoryInterface | ||
{ | ||
/** | ||
* Create an object | ||
* | ||
* @param ContainerInterface $container Service manager | ||
* @param string $requestedName Service being created | ||
* @param null|array $options Extra options (optional) | ||
* | ||
* @return object | ||
* | ||
* @throws ServiceNotFoundException if unable to resolve the service. | ||
* @throws ServiceNotCreatedException if an exception is raised when | ||
* creating a service. | ||
* @throws ContainerException&\Throwable if any other error occurs | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function __invoke( | ||
ContainerInterface $container, | ||
$requestedName, | ||
?array $options = null | ||
) { | ||
return new $requestedName( | ||
$container->get(\VuFind\Session\Settings::class), | ||
$container->get(\VuFind\ILS\Connection::class), | ||
$container->get(\VuFind\Auth\ILSAuthenticator::class), | ||
$container->get(\VuFind\Auth\Manager::class)->getUserObject(), | ||
$container->get('ViewRenderer'), | ||
...($options ?: []) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.