Пример #1
0
 /**
  * @test
  */
 public function getAssignedPartyOfAccountCachesParty()
 {
     $this->mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('723e3913-f803-42c8-a44c-fd7115f555c3'));
     $this->mockPartyRepository->expects($this->once())->method('findOneHavingAccount')->with($this->account)->will($this->returnValue($this->party));
     $this->party->addAccount($this->account);
     $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account);
     $this->assertSame($this->party, $assignedParty);
     $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account);
     $this->assertSame($this->party, $assignedParty);
 }
 /**
  * @param NodeInterface $node
  * @return string
  * @throws NeosException
  */
 public function render(NodeInterface $node)
 {
     if ($this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess') === false) {
         return '';
     }
     /** @var $actionRequest ActionRequest */
     $actionRequest = $this->controllerContext->getRequest();
     $innerView = new StandaloneView($actionRequest);
     $innerView->setTemplatePathAndFilename('resource://Neos.Neos/Private/Templates/Backend/Content/Container.html');
     $innerView->setFormat('html');
     $innerView->setPartialRootPath('resource://Neos.Neos/Private/Partials');
     $user = $this->partyService->getAssignedPartyOfAccount($this->securityContext->getAccount());
     $innerView->assignMultiple(array('node' => $node, 'modules' => $this->menuHelper->buildModuleList($this->controllerContext), 'sites' => $this->menuHelper->buildSiteList($this->controllerContext), 'user' => $user));
     return $innerView->render();
 }
 /**
  * Retrieves an existing user by the given username
  *
  * @param string $username The username
  * @param string $authenticationProviderName Name of the authentication provider to use. Example: "Typo3BackendProvider"
  * @return User The user, or null if the user does not exist
  * @throws Exception
  * @api
  */
 public function getUser($username, $authenticationProviderName = null)
 {
     if ($authenticationProviderName !== null && isset($this->runtimeUserCache['a_' . $authenticationProviderName][$username])) {
         return $this->runtimeUserCache['a_' . $authenticationProviderName][$username];
     } elseif (isset($this->runtimeUserCache['u_' . $username])) {
         return $this->runtimeUserCache['u_' . $username];
     }
     $account = $this->accountRepository->findByAccountIdentifierAndAuthenticationProviderName($username, $authenticationProviderName ?: $this->defaultAuthenticationProviderName);
     if (!$account instanceof Account) {
         return null;
     }
     $user = $this->partyService->getAssignedPartyOfAccount($account);
     if (!$user instanceof User) {
         throw new Exception(sprintf('Unexpected user type "%s". An account with the identifier "%s" exists, but the corresponding party is not a Neos User.', get_class($user), $username), 1422270948);
     }
     if ($authenticationProviderName !== null) {
         if (!isset($this->runtimeUserCache['a_' . $authenticationProviderName])) {
             $this->runtimeUserCache['a_' . $authenticationProviderName] = [];
         }
         $this->runtimeUserCache['a_' . $authenticationProviderName][$username] = $user;
     } else {
         $this->runtimeUserCache['u_' . $username] = $user;
     }
     return $user;
 }
 /**
  * @param array $module
  * @return mixed
  * @throws DisabledModuleException
  */
 public function indexAction(array $module)
 {
     $moduleRequest = new ActionRequest($this->request);
     $moduleRequest->setArgumentNamespace('moduleArguments');
     $moduleRequest->setControllerObjectName($module['controller']);
     $moduleRequest->setControllerActionName($module['action']);
     if (isset($module['format'])) {
         $moduleRequest->setFormat($module['format']);
     }
     if ($this->request->hasArgument($moduleRequest->getArgumentNamespace()) === true && is_array($this->request->getArgument($moduleRequest->getArgumentNamespace()))) {
         $moduleRequest->setArguments($this->request->getArgument($moduleRequest->getArgumentNamespace()));
     }
     foreach ($this->request->getPluginArguments() as $argumentNamespace => $argument) {
         $moduleRequest->setArgument('--' . $argumentNamespace, $argument);
     }
     $modules = explode('/', $module['module']);
     $moduleConfiguration = Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $modules));
     $moduleConfiguration['path'] = $module['module'];
     if (!$this->menuHelper->isModuleEnabled($moduleConfiguration['path'])) {
         throw new DisabledModuleException(sprintf('The module "%s" is disabled. You can enable it with the "enabled" flag in Settings.yaml.', $module['module']), 1437148922);
     }
     $moduleBreadcrumb = array();
     $path = array();
     foreach ($modules as $moduleIdentifier) {
         array_push($path, $moduleIdentifier);
         $config = Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $path));
         $moduleBreadcrumb[implode('/', $path)] = $config;
     }
     $moduleRequest->setArgument('__moduleConfiguration', $moduleConfiguration);
     $moduleResponse = new Response($this->response);
     $this->dispatcher->dispatch($moduleRequest, $moduleResponse);
     if ($moduleResponse->hasHeader('Location')) {
         $this->redirectToUri($moduleResponse->getHeader('Location'), 0, $moduleResponse->getStatusCode());
     } elseif ($moduleRequest->getFormat() !== 'html') {
         $mediaType = MediaTypes::getMediaTypeFromFilename('file.' . $moduleRequest->getFormat());
         if ($mediaType !== 'application/octet-stream') {
             $this->controllerContext->getResponse()->setHeader('Content-Type', $mediaType);
         }
         return $moduleResponse->getContent();
     } else {
         $user = $this->partyService->getAssignedPartyOfAccount($this->securityContext->getAccount());
         $sites = $this->menuHelper->buildSiteList($this->controllerContext);
         $this->view->assignMultiple(array('moduleClass' => implode('-', $modules), 'moduleContents' => $moduleResponse->getContent(), 'title' => $moduleRequest->hasArgument('title') ? $moduleRequest->getArgument('title') : $moduleConfiguration['label'], 'rootModule' => array_shift($modules), 'submodule' => array_shift($modules), 'moduleConfiguration' => $moduleConfiguration, 'moduleBreadcrumb' => $moduleBreadcrumb, 'user' => $user, 'modules' => $this->menuHelper->buildModuleList($this->controllerContext), 'sites' => $sites));
     }
 }