/** * @param InstanceManagerInterface $instanceManager * @param TrackingHelperOptions $options */ public function __construct(InstanceManagerInterface $instanceManager, TrackingHelperOptions $options) { $this->instanceManager = $instanceManager; $instance = $instanceManager->getInstanceFromRequest(); $name = strtolower($instance->getName()); $this->options = $options->getInstance($name); }
public function provide($container) { $instance = $this->instanceManager->getInstanceFromRequest(); $pages = []; try { $container = $this->navigationManager->findContainerByNameAndInstance($container, $instance); } catch (ContainerNotFoundException $e) { return []; } $key = hash('sha256', serialize($container)); if ($this->storage->hasItem($key)) { return $this->storage->getItem($key); } foreach ($container->getPages() as $page) { $addPage = $this->buildPage($page); $hasUri = isset($addPage['uri']); $hasMvc = isset($addPage['action']) || isset($addPage['controller']) || isset($addPage['route']); $hasProvider = isset($addPage['provider']); if ($hasUri || $hasMvc || $hasProvider) { $pages[] = $addPage; } } $this->storage->setItem($key, $pages); return $pages; }
public function __invoke($source) { try { $instance = $this->instanceManager->getInstanceFromRequest(); return $this->aliasManager->findAliasBySource($source, $instance); } catch (Exception $e) { return $source; } }
public function switchAction() { $instance = $this->params('instance'); try { $this->instanceManager->switchInstance($instance); } catch (InstanceNotFoundException $e) { $this->getResponse()->setStatusCode(404); return; } return $this->redirect()->toRoute('home'); }
/** * {@inheritDoc} */ public function getActiveInstance(InstanceManagerInterface $instanceManager) { if (!array_key_exists('HTTP_HOST', (array) $_SERVER)) { return $instanceManager->getDefaultInstance(); } if (!is_object($this->instance)) { $subDomain = explode('.', $_SERVER['HTTP_HOST'])[0]; $this->instance = $instanceManager->findInstanceBySubDomain($subDomain); } return $this->instance; }
/** * {@inheritDoc} */ public function getActiveInstance(InstanceManagerInterface $instanceManager) { if (!is_object($this->instance)) { $container = $this->getContainer(); if (!$container->offsetExists('instance')) { $this->instance = $instanceManager->getDefaultInstance(); } else { $this->instance = $instanceManager->getInstance($container->offsetGet('instance')); } } return $this->instance; }
public function indexAction() { $instance = $this->instanceManager->getInstanceFromRequest(); $this->assertGranted('navigation.manage', $instance); $containers = $this->navigationManager->findContainersByInstance($instance); $view = new ViewModel(['containers' => $containers]); $view->setTemplate('navigation/containers'); return $view; }
public function findAll($page, $limit = 100) { $className = $this->getClassResolver()->resolveClassName('Event\\Entity\\EventLogInterface'); $instance = $this->instanceManager->getInstanceFromRequest(); $dql = 'SELECT e FROM ' . $className . ' e ' . ' WHERE e.instance = ' . $instance->getId() . ' ORDER BY e.id DESC'; $paginator = new DoctrinePaginatorFactory($this->objectManager); $paginator = $paginator->createPaginator($dql, $page, $limit); $paginator->setFilter($this->persistentEventLogFilterChain); return $paginator; }
/** * @param object $object * @param FormInterface $form * @return object * @throws RuntimeException */ protected function bind($object, FormInterface $form) { $processingForm = clone $form; $data = $processingForm->getData(FormInterface::VALUES_AS_ARRAY); $processingForm->bind($object); $processingForm->setData($data); if (!$processingForm->isValid()) { throw new RuntimeException(print_r($processingForm->getMessages(), true)); } if ($object instanceof ParameterKeyInterface) { $instance = $this->instanceManager->getInstanceFromRequest(); } else { $instance = $object; } $this->assertGranted('navigation.manage', $instance); $this->objectManager->persist($object); return $object; }
/** * {@inheritDoc} */ public function search($query) { $query = $result = preg_replace('@([\\+\\-\\&\\|\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:])@is', '\\\\1', $query); $queryClass = $this->client->createSelect(); $instance = $this->instanceManager->getInstanceFromRequest(); $queryClass->createFilterQuery('ínstanceFilter')->setQuery('instance:(' . $instance->getId() . ')'); $hl = $queryClass->getHighlighting(); $hl->setFields('content'); $hl->setSimplePrefix('<strong>'); $hl->setSimplePostfix('</strong>'); $queryClass->setFields(['*', 'score']); $disMax = $queryClass->getDisMax(); $disMax->setQueryFields('title^4 content keywords^2 type^3'); $queryClass->setQuery($query); $queryClass->addSort('score', $queryClass::SORT_DESC); $queryClass->setQueryDefaultOperator($queryClass::QUERY_OPERATOR_AND); $adapter = new SolrPaginator($this->client, $queryClass); $adapter->setTranslator($this->translator); $paginator = new Paginator($adapter); return $paginator; }
public function renderSelect() { $data = ['instances' => $this->instanceManager->findAllInstances(), 'current' => $this->instanceManager->getInstanceFromRequest()]; return $this->getView()->partial('instance/helper/select', $data); }
public function __invoke() { $currentInstance = $this->instanceManager->getInstanceFromRequest(); return $currentInstance->getLanguage()->getCode(); }
/** * @param BrandHelperOptions $brandHelperOptions * @param InstanceManagerInterface $instanceManager */ public function __construct(BrandHelperOptions $brandHelperOptions, InstanceManagerInterface $instanceManager) { $key = $instanceManager->getInstanceFromRequest()->getName(); $this->instanceManager = $instanceManager; $this->options = $brandHelperOptions->getInstance($key); }