Skip to content

Commit

Permalink
Merge branch 'vufind-org:dev' into backToOrigin
Browse files Browse the repository at this point in the history
  • Loading branch information
rominail authored Jul 31, 2024
2 parents 1a3f40c + 45e6430 commit c1ffea3
Show file tree
Hide file tree
Showing 80 changed files with 329 additions and 397 deletions.
2 changes: 2 additions & 0 deletions config/vufind/authority.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[General]
default_handler = AllFields ; Search handler to use if none is specified
default_sort = relevance
default_limit = 20
;limit_options = 10,20,40,60,80,100
case_sensitive_bools = true
default_side_recommend[] = SideFacets:Facets:CheckboxFacets:authority
;default_record_fields = "*,score"
Expand Down
12 changes: 4 additions & 8 deletions module/VuFind/src/VuFind/CSV/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace VuFind\CSV;

use Laminas\ServiceManager\ServiceLocatorInterface;
use VuFind\Service\GetServiceTrait;
use VuFindSearch\Backend\Solr\Document\RawJSONDocument;

use function count;
Expand All @@ -45,12 +46,7 @@
*/
class Importer
{
/**
* Service locator
*
* @var ServiceLocatorInterface
*/
protected $serviceLocator;
use GetServiceTrait;

/**
* Base path for loading .ini files
Expand Down Expand Up @@ -162,7 +158,7 @@ protected function writeData(array $data, string $index, bool $testMode): string
if ($testMode) {
return $json;
}
$solr = $this->serviceLocator->get(\VuFind\Solr\Writer::class);
$solr = $this->getService(\VuFind\Solr\Writer::class);
$solr->save($index, new RawJSONDocument($json), 'update');
return ''; // no output when not in test mode!
}
Expand Down Expand Up @@ -209,7 +205,7 @@ protected function processHeader(ImporterConfig $config, $in, string $mode): voi
protected function getConfiguration(string $iniFile, $in): ImporterConfig
{
// Load properties file:
$resolver = $this->serviceLocator->get(\VuFind\Config\PathResolver::class);
$resolver = $this->getService(\VuFind\Config\PathResolver::class);
$ini = $resolver->getConfigPath($iniFile, $this->configBaseDir);
if (!file_exists($ini)) {
throw new \Exception("Cannot load .ini file: {$ini}.");
Expand Down
50 changes: 19 additions & 31 deletions module/VuFind/src/VuFind/Controller/AbstractBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use VuFind\Http\PhpEnvironment\Request as HttpRequest;
use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFind\I18n\Translator\TranslatorAwareTrait;
use VuFind\Service\GetServiceTrait;

use function intval;
use function is_object;
Expand Down Expand Up @@ -76,6 +77,7 @@
*/
class AbstractBase extends AbstractActionController implements AccessPermissionInterface, TranslatorAwareInterface
{
use GetServiceTrait;
use TranslatorAwareTrait;

/**
Expand All @@ -97,13 +99,6 @@ class AbstractBase extends AbstractActionController implements AccessPermissionI
*/
protected $accessDeniedBehavior = null;

/**
* Service manager
*
* @var ServiceLocatorInterface
*/
protected $serviceLocator;

/**
* Constructor
*
Expand Down Expand Up @@ -288,7 +283,7 @@ protected function createEmailViewModel($params = null, $defaultSubject = null)
*/
protected function getAuthManager()
{
return $this->serviceLocator->get(\VuFind\Auth\Manager::class);
return $this->getService(\VuFind\Auth\Manager::class);
}

/**
Expand All @@ -300,8 +295,7 @@ protected function getAuthManager()
*/
protected function getAuthorizationService()
{
return $this->serviceLocator
->get(\LmcRbacMvc\Service\AuthorizationService::class);
return $this->getService(\LmcRbacMvc\Service\AuthorizationService::class);
}

/**
Expand All @@ -311,7 +305,7 @@ protected function getAuthorizationService()
*/
protected function getILSAuthenticator()
{
return $this->serviceLocator->get(\VuFind\Auth\ILSAuthenticator::class);
return $this->getService(\VuFind\Auth\ILSAuthenticator::class);
}

/**
Expand All @@ -331,7 +325,7 @@ protected function getUser(): ?UserEntityInterface
*/
protected function getViewRenderer()
{
return $this->serviceLocator->get('ViewRenderer');
return $this->getService('ViewRenderer');
}

/**
Expand Down Expand Up @@ -459,8 +453,7 @@ protected function catalogLogin()
*/
public function getConfig($id = 'config')
{
return $this->serviceLocator->get(\VuFind\Config\PluginManager::class)
->get($id);
return $this->getService(\VuFind\Config\PluginManager::class)->get($id);
}

/**
Expand All @@ -470,7 +463,7 @@ public function getConfig($id = 'config')
*/
public function getILS()
{
return $this->serviceLocator->get(\VuFind\ILS\Connection::class);
return $this->getService(\VuFind\ILS\Connection::class);
}

/**
Expand All @@ -480,7 +473,7 @@ public function getILS()
*/
public function getRecordLoader()
{
return $this->serviceLocator->get(\VuFind\Record\Loader::class);
return $this->getService(\VuFind\Record\Loader::class);
}

/**
Expand All @@ -490,7 +483,7 @@ public function getRecordLoader()
*/
public function getRecordCache()
{
return $this->serviceLocator->get(\VuFind\Record\Cache::class);
return $this->getService(\VuFind\Record\Cache::class);
}

/**
Expand All @@ -500,7 +493,7 @@ public function getRecordCache()
*/
public function getRecordRouter()
{
return $this->serviceLocator->get(\VuFind\Record\Router::class);
return $this->getService(\VuFind\Record\Router::class);
}

/**
Expand All @@ -512,8 +505,7 @@ public function getRecordRouter()
*/
public function getTable($table)
{
return $this->serviceLocator->get(\VuFind\Db\Table\PluginManager::class)
->get($table);
return $this->getService(\VuFind\Db\Table\PluginManager::class)->get($table);
}

/**
Expand All @@ -527,8 +519,7 @@ public function getTable($table)
*/
public function getDbService(string $name): \VuFind\Db\Service\DbServiceInterface
{
return $this->serviceLocator->get(\VuFind\Db\Service\PluginManager::class)
->get($name);
return $this->getService(\VuFind\Db\Service\PluginManager::class)->get($name);
}

/**
Expand Down Expand Up @@ -638,7 +629,7 @@ public function confirm(
*/
protected function disableSessionWrites()
{
$this->serviceLocator->get(\VuFind\Session\Settings::class)->disableWrite();
$this->getService(\VuFind\Session\Settings::class)->disableWrite();
}

/**
Expand All @@ -648,7 +639,7 @@ protected function disableSessionWrites()
*/
public function getSearchMemory()
{
return $this->serviceLocator->get(\VuFind\Search\Memory::class);
return $this->getService(\VuFind\Search\Memory::class);
}

/**
Expand All @@ -658,8 +649,7 @@ public function getSearchMemory()
*/
protected function commentsEnabled()
{
$check = $this->serviceLocator
->get(\VuFind\Config\AccountCapabilities::class);
$check = $this->getService(\VuFind\Config\AccountCapabilities::class);
return $check->getCommentSetting() !== 'disabled';
}

Expand All @@ -670,8 +660,7 @@ protected function commentsEnabled()
*/
protected function listsEnabled()
{
$check = $this->serviceLocator
->get(\VuFind\Config\AccountCapabilities::class);
$check = $this->getService(\VuFind\Config\AccountCapabilities::class);
return $check->getListSetting() !== 'disabled';
}

Expand All @@ -682,8 +671,7 @@ protected function listsEnabled()
*/
protected function tagsEnabled()
{
$check = $this->serviceLocator
->get(\VuFind\Config\AccountCapabilities::class);
$check = $this->getService(\VuFind\Config\AccountCapabilities::class);
return $check->getTagSetting() !== 'disabled';
}

Expand Down Expand Up @@ -817,7 +805,7 @@ protected function clearFollowupUrl()
*/
protected function getRecordTabManager()
{
return $this->serviceLocator->get(\VuFind\RecordTab\TabManager::class);
return $this->getService(\VuFind\RecordTab\TabManager::class);
}

/**
Expand Down
30 changes: 14 additions & 16 deletions module/VuFind/src/VuFind/Controller/AbstractRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function addcommentAction()
// something has gone wrong (or user submitted blank form) and we
// should do nothing:
if (!empty($comment)) {
$populator = $this->serviceLocator->get(ResourcePopulator::class);
$populator = $this->getService(ResourcePopulator::class);
$resource = $populator->getOrCreateResourceForDriver($driver);
$commentsService = $this->getDbService(
\VuFind\Db\Service\CommentsServiceInterface::class
Expand All @@ -180,7 +180,7 @@ public function addcommentAction()
$driver->isRatingAllowed()
&& '0' !== ($rating = $this->params()->fromPost('rating', '0'))
) {
$ratingsService = $this->serviceLocator->get(RatingsService::class);
$ratingsService = $this->getService(RatingsService::class);
$ratingsService->saveRating($driver, $user->getId(), intval($rating));
}

Expand Down Expand Up @@ -242,7 +242,7 @@ public function addtagAction()

// Save tags, if any:
if ($tags = $this->params()->fromPost('tag')) {
$this->serviceLocator->get(TagsService::class)->linkTagsToRecord($driver, $user, $tags);
$this->getService(TagsService::class)->linkTagsToRecord($driver, $user, $tags);
$this->flashMessenger()->addMessage(['msg' => 'add_tag_success'], 'success');
return $this->redirectToRecord();
}
Expand Down Expand Up @@ -275,7 +275,7 @@ public function deletetagAction()

// Delete tags, if any:
if ($tag = $this->params()->fromPost('tag')) {
$this->serviceLocator->get(TagsService::class)->unlinkTagsFromRecord(
$this->getService(TagsService::class)->unlinkTagsFromRecord(
$driver,
$user,
[$tag]
Expand Down Expand Up @@ -316,7 +316,7 @@ public function ratingAction()
) {
throw new BadRequestException('error_inconsistent_parameters');
}
$ratingsService = $this->serviceLocator->get(RatingsService::class);
$ratingsService = $this->getService(RatingsService::class);
$ratingsService->saveRating(
$driver,
$user->getId(),
Expand All @@ -331,7 +331,7 @@ public function ratingAction()

// Display the "add rating" form:
$currentRating = $user
? $this->serviceLocator->get(RatingsService::class)->getRatingData($driver, $user->getId())
? $this->getService(RatingsService::class)->getRatingData($driver, $user->getId())
: null;
return $this->createViewModel(compact('currentRating'));
}
Expand Down Expand Up @@ -413,9 +413,9 @@ protected function processSave()
// Perform the save operation:
$driver = $this->loadRecord();
$post = $this->getRequest()->getPost()->toArray();
$tagsService = $this->serviceLocator->get(TagsService::class);
$tagsService = $this->getService(TagsService::class);
$post['mytags'] = $tagsService->parse($post['mytags'] ?? '');
$favorites = $this->serviceLocator->get(\VuFind\Favorites\FavoritesService::class);
$favorites = $this->getService(\VuFind\Favorites\FavoritesService::class);
$results = $favorites->saveRecordToFavorites($post, $user, $driver);

// Display a success status message:
Expand Down Expand Up @@ -542,7 +542,7 @@ public function emailAction()
$driver = $this->loadRecord();

// Create view
$mailer = $this->serviceLocator->get(\VuFind\Mailer\Mailer::class);
$mailer = $this->getService(\VuFind\Mailer\Mailer::class);
$view = $this->createEmailViewModel(
null,
$mailer->getDefaultRecordSubject($driver)
Expand Down Expand Up @@ -585,8 +585,7 @@ public function emailAction()
*/
protected function smsEnabled()
{
$check = $this->serviceLocator
->get(\VuFind\Config\AccountCapabilities::class);
$check = $this->getService(\VuFind\Config\AccountCapabilities::class);
return $check->getSmsSetting() !== 'disabled';
}

Expand All @@ -606,7 +605,7 @@ public function smsAction()
$driver = $this->loadRecord();

// Load the SMS carrier list:
$sms = $this->serviceLocator->get(\VuFind\SMS\SMSInterface::class);
$sms = $this->getService(\VuFind\SMS\SMSInterface::class);
$view = $this->createViewModel();
$view->carriers = $sms->getCarriers();
$view->validation = $sms->getValidationType();
Expand All @@ -618,7 +617,7 @@ public function smsAction()
// Process form submission:
if ($this->formWasSubmitted(useCaptcha: $view->useCaptcha)) {
// Do CSRF check
$csrf = $this->serviceLocator->get(\VuFind\Validator\SessionCsrf::class);
$csrf = $this->getService(\VuFind\Validator\SessionCsrf::class);
if (!$csrf->isValid($this->getRequest()->getPost()->get('csrf'))) {
throw new \VuFind\Exception\BadRequest(
'error_inconsistent_parameters'
Expand Down Expand Up @@ -680,7 +679,7 @@ public function exportAction()
$format = $this->params()->fromQuery('style');

// Display export menu if missing/invalid option
$export = $this->serviceLocator->get(\VuFind\Export::class);
$export = $this->getService(\VuFind\Export::class);
if (empty($format) || !$export->recordSupportsFormat($driver, $format)) {
if (!empty($format)) {
$this->flashMessenger()
Expand Down Expand Up @@ -769,8 +768,7 @@ public function explainAction()
return $view;
}

$explanation = $this->serviceLocator
->get(\VuFind\Search\Explanation\PluginManager::class)
$explanation = $this->getService(\VuFind\Search\Explanation\PluginManager::class)
->get($record->getSourceIdentifier());

$params = $explanation->getParams();
Expand Down
Loading

0 comments on commit c1ffea3

Please sign in to comment.