本文整理汇总了PHP中Zend\ServiceManager\ServiceManager::getServiceLocator方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceManager::getServiceLocator方法的具体用法?PHP ServiceManager::getServiceLocator怎么用?PHP ServiceManager::getServiceLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ServiceManager\ServiceManager
的用法示例。
在下文中一共展示了ServiceManager::getServiceLocator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserComments
/**
* Factory for UserComments tab plugin.
*
* @param ServiceManager $sm Service manager.
*
* @return UserComments
*/
public static function getUserComments(ServiceManager $sm)
{
$capabilities = $sm->getServiceLocator()->get('VuFind\\AccountCapabilities');
$config = $sm->getServiceLocator()->get('VuFind\\Config')->get('config');
$useRecaptcha = isset($config->Captcha) && isset($config->Captcha->forms) && (trim($config->Captcha->forms) === '*' || strpos($config->Captcha->forms, 'userComments'));
return new UserComments('enabled' === $capabilities->getCommentSetting(), $useRecaptcha);
}
示例2: getReviews
/**
* Create Reviews loader
*
* @param ServiceManager $sm Service manager
*
* @return mixed
*/
public static function getReviews(ServiceManager $sm)
{
$loader = $sm->getServiceLocator()->get('VuFind\\ContentReviewsPluginManager');
$config = $sm->getServiceLocator()->get('VuFind\\Config')->get('config');
$providers = isset($config->Content->reviews) ? $config->Content->reviews : '';
return new Loader($loader, $providers);
}
示例3: getSolr
/**
* Factory for Solr driver.
*
* @param ServiceManager $sm Service manager.
*
* @return Solr
*/
public static function getSolr(ServiceManager $sm)
{
$cacheDir = $sm->getServiceLocator()->get('VuFind\\CacheManager')->getCacheDir(false);
$hierarchyFilters = $sm->getServiceLocator()->get('VuFind\\Config')->get('HierarchyDefault');
$filters = isset($hierarchyFilters->HierarchyTree->filterQueries) ? $hierarchyFilters->HierarchyTree->filterQueries->toArray() : [];
return new Solr($sm->getServiceLocator()->get('VuFind\\Search'), rtrim($cacheDir, '/') . '/hierarchy', $filters);
}
示例4: getSolrParams
/**
* Factory for Solr params object.
*
* @param ServiceManager $sm Service manager.
*
* @return Solr
*/
public static function getSolrParams(ServiceManager $sm)
{
$options = $sm->getServiceLocator()->get('VuFind\\SearchOptionsPluginManager')->get('Solr');
$config = $sm->getServiceLocator()->get('VuFind\\Config');
$translator = $sm->getServiceLocator()->get('VuFind\\Translator');
$solr = new \MZKPortal\Search\Solr\Params(clone $options, $config, $translator);
return $solr;
}
示例5: getSolr
/**
* Factory for Solr driver.
*
* @param ServiceManager $sm Service manager.
*
* @return Solr
*/
public static function getSolr(ServiceManager $sm)
{
$cacheDir = $sm->getServiceLocator()->get('VuFind\\CacheManager')->getCacheDir(false);
$hierarchyFilters = $sm->getServiceLocator()->get('VuFind\\Config')->get('HierarchyDefault');
$filters = isset($hierarchyFilters->HierarchyTree->filterQueries) ? $hierarchyFilters->HierarchyTree->filterQueries->toArray() : [];
$solr = $sm->getServiceLocator()->get('VuFind\\Search\\BackendManager')->get('Solr')->getConnector();
$formatterManager = $sm->getServiceLocator()->get('VuFind\\HierarchyTreeDataFormatterPluginManager');
return new Solr($solr, $formatterManager, rtrim($cacheDir, '/') . '/hierarchy', $filters);
}
示例6: getLayoutClass
/**
* Construct the LayoutClass helper.
*
* @param ServiceManager $sm Service manager.
*
* @return LayoutClass
*/
public static function getLayoutClass(ServiceManager $sm)
{
$config = $sm->getServiceLocator()->get('VuFind\\Config')->get('config');
$left = !isset($config->Site->sidebarOnLeft) ? false : $config->Site->sidebarOnLeft;
$offcanvas = !isset($config->Site->offcanvas) ? false : $config->Site->offcanvas;
// The right-to-left setting is injected into the layout by the Bootstrapper;
// pull it back out here to avoid duplicate effort.
$layout = $sm->getServiceLocator()->get('viewmanager')->getViewModel();
return new LayoutClass($left, $offcanvas, $layout->rtl);
}
示例7: getEDS
/**
* Factory for Solr results object.
*
* @param ServiceManager $sm Service manager.
*
* @return Solr
*/
public static function getEDS(ServiceManager $sm)
{
$config = $sm->getServiceLocator()->get('VuFind\\Config');
$container = new \Zend\Session\Container('EBSCO');
// No API info in session? Re-establish connection:
if (!isset($container->info)) {
$backend = $sm->getServiceLocator()->get('VuFind\\Search\\BackendManager')->get('EDS');
$backend->getSessionToken();
}
$eds = new \VuFind\Search\EDS\Options($config, $container->info);
return $eds;
}
示例8: getHoldingsILS
public static function getHoldingsILS(ServiceManager $sm)
{
// If VuFind is configured to suppress the holdings tab when the
// ILS driver specifies no holdings, we need to pass in a connection
// object:
$config = $sm->getServiceLocator()->get('VuFind\\Config')->get('config');
if (isset($config->Site->hideHoldingsTabWhenEmpty) && $config->Site->hideHoldingsTabWhenEmpty) {
$catalog = $sm->getServiceLocator()->get('VuFind\\ILSConnection');
} else {
$catalog = false;
}
return new HoldingsILS($catalog);
}
示例9: getLayoutClass
/**
* Construct the LayoutClass helper.
*
* @param ServiceManager $sm Service manager.
*
* @return LayoutClass
*/
public static function getLayoutClass(ServiceManager $sm)
{
$config = $sm->getServiceLocator()->get('VuFind\\Config')->get('config');
$left = !isset($config->Site->sidebarOnLeft) ? false : $config->Site->sidebarOnLeft;
$mirror = !isset($config->Site->mirrorSidebarInRTL) ? true : $config->Site->mirrorSidebarInRTL;
$offcanvas = !isset($config->Site->offcanvas) ? false : $config->Site->offcanvas;
// The right-to-left setting is injected into the layout by the Bootstrapper;
// pull it back out here to avoid duplicate effort, then use it to apply
// the mirror setting appropriately.
$layout = $sm->getServiceLocator()->get('viewmanager')->getViewModel();
if ($layout->rtl && !$mirror) {
$left = !$left;
}
return new LayoutClass($left, $offcanvas);
}
示例10: getLayoutClass
/**
* Construct the LayoutClass helper.
*
* @param ServiceManager $sm Service manager.
*
* @return LayoutClass
*/
public static function getLayoutClass(ServiceManager $sm)
{
$config = $sm->getServiceLocator()->get('VuFind\\Config')->get('config');
$left = !isset($config->Site->sidebarOnLeft) ? false : $config->Site->sidebarOnLeft;
$offcanvas = !isset($config->Site->offcanvas) ? false : $config->Site->offcanvas;
return new LayoutClass($left, $offcanvas);
}
示例11: __invoke
public function __invoke(ServiceManager $container)
{
$entityManager = $container->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$options = $this->options;
$options['object_repository'] = $entityManager->getRepository($options['entity']);
return new ObjectExists($options);
}
示例12: initUrlQueryHelper
/**
* Internal utility function for initializing
* UrlQueryHelper for a Results-object with search ids for all tabs.
*
* @param ResultsManager $results Search results.
* @param ServiceManager $sm Service manager.
*
* @return Results Search results with initialized UrlQueryHelper
*/
public static function initUrlQueryHelper(\VuFind\Search\Base\Results $results, $sm)
{
$helper = new UrlQueryHelper($results->getParams());
$savedSearches = $sm->getServiceLocator()->get('Request')->getQuery('search');
if ($savedSearches) {
$helper->setDefaultParameter('search', $savedSearches);
}
$results->setHelper('urlQuery', $helper);
return $results;
}
示例13: setServiceManager
/**
* Set the ZeAuth Service for the plugin/helper class.
* @param \Zend\ServiceManager\ServiceManager $serviceManager
* @return \ZeAuth\Service\Auth
*/
public function setServiceManager(ServiceManager $serviceManager)
{
if (!$this->service) {
if ($serviceManager instanceof \Zend\View\HelperPluginManager) {
$this->service = $serviceManager->getServiceLocator()->get('ZeAuth');
} else {
$this->service = $serviceManager->get('ZeAuth');
}
}
return $this->service;
}
示例14: getUserList
/**
* Construct the UserList table.
*
* @param ServiceManager $sm Service manager.
*
* @return UserList
*/
public static function getUserList(ServiceManager $sm)
{
// For user anonymization console utility
if (Console::isConsole()) {
$session = new \Zend\Session\Container('List');
} else {
$sessionManager = $sm->getServiceLocator()->get('VuFind\\SessionManager');
$session = new \Zend\Session\Container('List', $sessionManager);
}
return new UserList($session);
}
示例15: getWorldCatSimilar
/**
* Factory for WorldCatSimilar module.
*
* @param ServiceManager $sm Service manager.
*
* @return WorldCatSimilar
*/
public static function getWorldCatSimilar(ServiceManager $sm)
{
return new WorldCatSimilar($sm->getServiceLocator()->get('VuFind\\Search'));
}