forked from NatLibFi/NDL-VuFind2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix copying of a public list to favorites.
- Loading branch information
1 parent
ad41f57
commit 0daca76
Showing
4 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
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
87 changes: 87 additions & 0 deletions
87
module/Finna/src/Finna/Favorites/FavoritesServiceFactory.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,87 @@ | ||
<?php | ||
|
||
/** | ||
* Favorites service factory | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) Villanova University 2016. | ||
* | ||
* 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 Favorites | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Page | ||
*/ | ||
|
||
namespace Finna\Favorites; | ||
|
||
use Laminas\ServiceManager\Factory\FactoryInterface; | ||
use Psr\Container\ContainerInterface; | ||
use VuFind\Db\Service\ResourceServiceInterface; | ||
use VuFind\Db\Service\ResourceTagsServiceInterface; | ||
use VuFind\Db\Service\UserListServiceInterface; | ||
use VuFind\Db\Service\UserResourceServiceInterface; | ||
use VuFind\Db\Service\UserServiceInterface; | ||
use VuFind\Record\Loader; | ||
use VuFind\Record\ResourcePopulator; | ||
use VuFind\Tags\TagsService; | ||
|
||
/** | ||
* Favorites service | ||
* | ||
* @category VuFind | ||
* @package Favorites | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Page | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
class FavoritesServiceFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create service | ||
* | ||
* Finna version due to the hardcoded class name | ||
* | ||
* @param ContainerInterface $container Service container | ||
* @param string $name Requested service name (unused) | ||
* @param array $options Extra options (unused) | ||
* | ||
* @return FavoritesService | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function __invoke(ContainerInterface $container, $name, array $options = null) | ||
{ | ||
$serviceManager = $container->get(\VuFind\Db\Service\PluginManager::class); | ||
$sessionManager = $container->get(\Laminas\Session\SessionManager::class); | ||
$session = new \Laminas\Session\Container('List', $sessionManager); | ||
return new FavoritesService( | ||
$serviceManager->get(ResourceServiceInterface::class), | ||
$serviceManager->get(ResourceTagsServiceInterface::class), | ||
$serviceManager->get(UserListServiceInterface::class), | ||
$serviceManager->get(UserResourceServiceInterface::class), | ||
$serviceManager->get(UserServiceInterface::class), | ||
$container->get(ResourcePopulator::class), | ||
$container->get(TagsService::class), | ||
$container->get(Loader::class), | ||
$container->get(\VuFind\Record\Cache::class), | ||
$session | ||
); | ||
} | ||
} |