本文整理汇总了PHP中Zend\View\HelperPluginManager::getServiceLocator方法的典型用法代码示例。如果您正苦于以下问题:PHP HelperPluginManager::getServiceLocator方法的具体用法?PHP HelperPluginManager::getServiceLocator怎么用?PHP HelperPluginManager::getServiceLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\HelperPluginManager
的用法示例。
在下文中一共展示了HelperPluginManager::getServiceLocator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(HelperPluginManager $pluginManager)
{
$this->pluginManager = $pluginManager;
$this->serviceManager = $pluginManager->getServiceLocator();
$this->app = $pluginManager->getServiceLocator()->get('Application');
$this->request = $this->app->getRequest();
$this->event = $this->app->getMvcEvent();
$this->em = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
$this->translator = $this->serviceManager->get('translator');
}
示例2: __invoke
/**
* @param ContentType|null $contentType
* @param string|null $contentTypeName
*
* @return string
*/
public function __invoke(ContentType $contentType = null, $contentTypeName = null)
{
if (!is_null($contentTypeName)) {
/** @var GeneralService $generalService */
$generalService = $this->serviceLocator->getServiceLocator()->get(GeneralService::class);
$contentType = $generalService->findContentTypeByContentTypeName($contentTypeName);
}
if (is_null($contentType)) {
return null;
}
switch (trim($contentType->getContentType())) {
case 'image/jpeg':
case 'image/tiff':
case 'image/png':
$class = " fa-file-image-o";
break;
case 'application/pdf':
case 'application/postscript':
$class = "fa-file-pdf-o";
break;
case 'application/zip':
case 'application/x-zip-compressed':
$class = "fa-file-archive-o";
break;
case 'application/vnd.ms-excel':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'application/vnd.ms-excel.sheet.macroEnabled.12':
$class = "fa-file-excel-o";
break;
case 'application/mspowerpoint':
case 'application/vnd.ms-powerpoint':
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
case 'application/vnd.openxmlformats-officedocument.presentationml.template':
case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow':
$class = 'fa-file-powerpoint-o';
break;
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
case 'application/msword':
$class = "fa-file-word-o";
break;
case 'application/octet-stream':
case 'application/csv':
case 'text/xml':
$class = "fa-file-o";
break;
case 'video/mp4':
$class = "fa-file-video-o";
break;
default:
return sprintf('%s not found', $contentType->getContentType());
}
return sprintf('<i class="fa %s" title="%s"></i> ', $class, $contentType->getDescription());
}
示例3: createService
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
$acl = $this->serviceLocator->getServiceLocator()->get('UthandoUser\\Service\\Acl');
$identity = $this->getIdentityHelper();
$role = $identity() ? $identity()->getRole() : 'guest';
$service = new Navigation();
$service->setAcl($acl);
$service->setRole($role);
$service->setServiceLocator($this->serviceLocator->getServiceLocator());
return $service;
}
示例4: __invoke
/**
* @param HelperPluginManager $pluginManager
*
* @return SymfonyAssetViewHelper
* @throws \Exception
*/
public function __invoke(HelperPluginManager $pluginManager)
{
$serviceLocator = $pluginManager->getServiceLocator();
$config = $serviceLocator->get('Config');
if (false === isset($config['fadoe_symfony_asset_module'])) {
throw new \Exception('Config not found');
}
$config = $config['fadoe_symfony_asset_module'];
$packagesService = $serviceLocator->get('FaDoe\\SymfonyAssetModule\\PackagesService');
$version = $config['version'];
$versionFormat = $config['version_format'];
$basePath = $config['base_path'];
$baseUrls = $config['base_urls'];
$defaultPackage = $packagesService->createService($version, $versionFormat, $basePath, $baseUrls);
$namedPackages = [];
foreach ($config['packages'] as $key => $value) {
$version = $value['version'];
$versionFormat = $value['version_format'];
$basePath = $value['base_path'];
$baseUrls = $value['base_urls'];
$namedPackages[$key] = $packagesService->createService($version, $versionFormat, $basePath, $baseUrls);
}
$packages = new Packages($defaultPackage, $namedPackages);
return new SymfonyAssetViewHelper($packages);
}
示例5: __invoke
/**
* create a link to either
*
* @return void
*/
public function __invoke($provider = null)
{
if (!$provider) {
$pluginManager = $this->getServiceLocator();
$config = $pluginManager->getServiceLocator()->get('Config');
$provider = $config['OrgHeiglHybridAuth']['backend'];
}
$xhtml = '<a class="hybridauth" href="%2$s">%1$s</a>';
//$session = new SessionContainer('orgheiglhybridauth');
$session = $this->viewHelperManager->getServiceLocator()->get('OrgHeiglHybridAuthSession');
$urlHelper = $this->getViewHelper('url');
$currentRoute = $this->getCurrentRoute();
if ($session->offsetExists('authenticated') && true === $session->offsetGet('authenticated')) {
// Display Logged in information
$user = $session->offsetGet('user');
// TODO: This has to be localized
$user = 'Logout ' . $user->getName();
$link = $urlHelper('hybridauth/logout', array('redirect' => $currentRoute));
} else {
// Display login-button
// TODO: This has to be localized
$user = 'Login';
$link = $urlHelper('hybridauth/login', array('provider' => $provider, 'redirect' => $currentRoute));
}
return sprintf($xhtml, $user, $link);
}
示例6: __invoke
/**
* createService
*
* Create the identity view helper.
*
* @param HelperPluginManager $viewHelperManager The service manager instance.
* @param string $name The name of the service being created.
* @param string $requestedName The requested name of the service being created.
*
* @return Identity
*/
public function __invoke(HelperPluginManager $viewHelperManager, $name, $requestedName)
{
/** @var ServiceManager $serviceManager */
$serviceManager = $viewHelperManager->getServiceLocator();
$options = $this->getOptions($serviceManager, $requestedName);
if (!isset($options['auth_service'])) {
throw new ServiceNotCreatedException(sprintf('The \'auth_service\' configuration option is missing for view helper \'%s\'.', $requestedName));
}
/** @var AuthenticationServiceInterface $authenticationService */
$authenticationService = $serviceManager->get($options['auth_service']);
return new Identity($authenticationService);
}
示例7: __invoke
/**
* createService
*
* Create the form group helper.
*
* @param HelperPluginManager $viewHelperManager The view helper plugin manager.
* @param string $name The name of the service to create.
* @param string $requestedName The requested name of the service to create.
*
* @return FormGroup
*/
public function __invoke(HelperPluginManager $viewHelperManager, $name, $requestedName)
{
/** @var ServiceManager $serviceManager */
$serviceManager = $viewHelperManager->getServiceLocator();
$options = $this->getOptions($serviceManager, $requestedName);
$formRowHelper = $this->defaultRowHelper;
if (!empty($options['form_row_helper'])) {
$formRowHelper = $options['form_row_helper'];
}
/** @var FormRow $formRow */
$formRow = $viewHelperManager->get($formRowHelper);
return new FormGroup($formRow);
}
示例8: getServiceLocator
/**
* Get the service locator.
*
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->serviceLocator->getServiceLocator();
}
示例9: __invoke
/**
* @param HelperPluginManager $vhm
*
* @return SlugifyViewHelper
*/
public function __invoke($vhm)
{
/** @var Slugify $slugify */
$slugify = $vhm->getServiceLocator()->get('Cocur\\Slugify\\Slugify');
return new SlugifyViewHelper($slugify);
}
示例10: factory
/**
* @param HelperPluginManager $helperPluginManager
* @return InsertFile
*/
public static function factory(HelperPluginManager $helperPluginManager)
{
return new static($helperPluginManager->getServiceLocator());
}
示例11: __invoke
public function __invoke(HelperPluginManager $helperPluginManager)
{
$htmlPurifier = $helperPluginManager->getServiceLocator()->get('HTMLPurifier');
return new PurifierViewHelper($htmlPurifier);
}
示例12: __construct
public function __construct(HelperPluginManager $helperPluginManager)
{
$this->serviceLocator = $helperPluginManager->getServiceLocator();
$this->pluginLoader = $this->serviceLocator->get("Plugins");
}