/**
  * @Flow\Around("method(TYPO3\Neos\Domain\Repository\DomainRepository->findOneByActiveRequest())")
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return mixed
  */
 public function cacheDomainForActiveRequest(JoinPointInterface $joinPoint)
 {
     if ($this->domainForActiveRequest === FALSE || $this->environment->getContext()->isTesting()) {
         $domain = $joinPoint->getAdviceChain()->proceed($joinPoint);
         $this->domainForActiveRequest = $domain;
     }
     return $this->domainForActiveRequest;
 }
 /**
  * Initializes the controller
  */
 protected function initializeAction()
 {
     $context = $this->env->getContext();
     if ($context == 'Development') {
         $this->context = 'DEV';
     } else {
         $this->context = 'PRD';
     }
 }
 /**
  * Handle an exception depending on the context with an HTML message or XML comment
  *
  * @param array $typoScriptPath path causing the exception
  * @param \Exception $exception exception to handle
  * @param integer $referenceCode
  * @return string
  */
 protected function handle($typoScriptPath, \Exception $exception, $referenceCode)
 {
     $context = $this->environment->getContext();
     if ($context->isDevelopment()) {
         $handler = new HtmlMessageHandler();
     } else {
         $handler = new XmlCommentHandler();
     }
     $handler->setRuntime($this->getRuntime());
     return $handler->handleRenderingException($typoScriptPath, $exception);
 }
 /**
  * Initializes the controller
  */
 protected function initializeAction()
 {
     $context = $this->env->getContext();
     if ($context == 'Development') {
         $this->context = 'DEV';
     } else {
         $this->context = 'PRD';
     }
     $this->connection = new Es\ElasticSearchConnection();
     $this->connection->init();
 }
 /**
  * Initializes the controller
  */
 protected function initializeAction()
 {
     date_default_timezone_set('UTC');
     $context = $this->env->getContext();
     if ($context == 'Development') {
         $this->context = 'DEV';
     } else {
         $this->context = 'PRD';
     }
     $this->connection = new Es\ElasticSearchConnection();
     $this->connection->init();
     $this->sprintConfig = $this->ConfigurationManager->getConfiguration('Sprints');
 }
 protected function initializeAction()
 {
     date_default_timezone_set('UTC');
     $this->connection = new Es\ElasticSearchConnection();
     $this->connection->init();
     $context = $this->env->getContext();
     if ($context == 'Development') {
         $this->context = 'DEV';
     } else {
         $this->context = 'PRD';
     }
     if (isset($_GET['page'])) {
         $this->currentPage = intval($_GET['page']);
     }
 }
 /**
  * Verifies the authentication token.
  *
  * @param string $authenticationHash
  * @param string $parameters
  *
  */
 private function verifyAuthentication($authenticationHash, $parameters)
 {
     if (md5($this->settings['webserviceKey'] . $parameters) == $authenticationHash || $this->environment->getContext() == 'Development') {
         return TRUE;
     }
     return FALSE;
 }
 /**
  * renders the exception to nice html content element to display, edit, remove, ...
  *
  * @param string $typoScriptPath - path causing the exception
  * @param \Exception $exception - exception to handle
  * @param integer $referenceCode - might be unset
  * @return string
  */
 protected function handle($typoScriptPath, \Exception $exception, $referenceCode)
 {
     $handler = new ContextDependentHandler();
     $handler->setRuntime($this->runtime);
     $output = $handler->handleRenderingException($typoScriptPath, $exception);
     $currentContext = $this->getRuntime()->getCurrentContext();
     if (isset($currentContext['node'])) {
         /** @var NodeInterface $node */
         $node = $currentContext['node'];
         $applicationContext = $this->environment->getContext();
         if ($applicationContext->isProduction() && $this->privilegeManager->isPrivilegeTargetGranted('TYPO3.Neos:Backend.GeneralAccess') && $node->getContext()->getWorkspaceName() !== 'live') {
             $output = '<div class="neos-rendering-exception"><div class="neos-rendering-exception-title">Failed to render element' . $output . '</div></div>';
         }
         return $this->contentElementWrappingService->wrapContentObject($node, $output, $typoScriptPath);
     }
     return $output;
 }
 /**
  * Extract metadata from the content and store it
  *
  * @param string $entryIdentifier The entry identifier
  * @param string $content The raw content including serialized metadata
  * @return string The content without metadata
  * @throws InvalidDataException
  */
 protected function extractMetadata($entryIdentifier, $content)
 {
     $separatorIndex = strpos($content, self::SEPARATOR);
     if ($separatorIndex === FALSE) {
         $exception = new InvalidDataException('Could not find cache metadata in entry with identifier ' . $entryIdentifier, 1433155925);
         if ($this->environment->getContext()->isProduction()) {
             $this->systemLogger->logException($exception);
         } else {
             throw $exception;
         }
     }
     $metadataJson = substr($content, 0, $separatorIndex);
     $metadata = json_decode($metadataJson, TRUE);
     if ($metadata === NULL) {
         $exception = new InvalidDataException('Invalid cache metadata in entry with identifier ' . $entryIdentifier, 1433155926);
         if ($this->environment->getContext()->isProduction()) {
             $this->systemLogger->logException($exception);
         } else {
             throw $exception;
         }
     }
     $this->metadata[$entryIdentifier] = $metadata;
     return substr($content, $separatorIndex + 1);
 }
 /**
  * @return boolean
  */
 protected function hasFrozenCacheInProduction()
 {
     return $this->environment->getContext()->isProduction() && $this->reflectionDataRuntimeCache->getBackend()->isFrozen();
 }
 /**
  * Initializes the view with common variables.
  *
  * @param \TYPO3\Flow\Mvc\View\ViewInterface $view
  * @return void
  */
 protected function initializeView(\TYPO3\Flow\Mvc\View\ViewInterface $view)
 {
     // We don't need to do all this for json responses.
     if ($this->request->hasArgument('json')) {
         return;
     }
     // Are user an Editor?
     $isEditor = 0;
     if ($this->securityContext->hasRole('_OurBrand_.Business:worker')) {
         $isEditor = 1;
     }
     // Are user an Admin?
     $isAdmin = 0;
     if ($this->currentUser->isAdministrator()) {
         $isAdmin = 1;
     }
     $inDev = 0;
     if (strstr($_SERVER['HTTP_HOST'], '.local')) {
         $inDev = 1;
     }
     // Get file stamp
     $fileStamp = time();
     if ($this->environment->getContext() == 'Production' && file_exists(FLOW_PATH_ROOT . 'Data/Temporary/Production/Configuration/ProductionConfigurations.php')) {
         $fileStamp = @filemtime(FLOW_PATH_ROOT . 'Data/Temporary/Production/Configuration/ProductionConfigurations.php');
     }
     // Exercise categories
     $exerciseCategoryRepository = new \_OurBrand_\Quiz\Domain\Repository\ExerciseCategoryRepository();
     $exerciseCategories = $exerciseCategoryRepository->findAll();
     $subjectRepository = new \_OurBrand_\Quiz\Domain\Repository\SubjectRepository();
     $this->view->assign('archiveUri', $this->getArchiveUri());
     $this->view->assign('UIPath', $this->settings['UIPath']);
     $this->view->assign('isEditor', $isEditor);
     $this->view->assign('isAdmin', $isAdmin);
     $this->view->assign('inDev', $inDev);
     $this->view->assign('logintime', $fileStamp);
     // When was system updated?
     $this->view->assign('exerciseCategories', $exerciseCategories);
     $this->view->assign('user', $this->currentUser);
     if ($this->request->hasArgument('exercise') || $this->request->hasArgument('currentExercise')) {
         $exercise = $this->getExerciseFromArgument();
         if (is_a($exercise, '\\_OurBrand_\\Quiz\\Domain\\Model\\Exercise')) {
             // Set type
             $objectName = explode('\\', get_class($exercise));
             $exerciseType = $this->exerciseTypeRepository->findOneByObjectName(array_pop($objectName));
             $exercise->setType($exerciseType);
             $durations = $this->getDurationsForExercise($this->settings['exercise']['durations']);
             $this->view->assign('editExerciseDurations', $durations);
             $this->view->assign('editExerciseCategories', $this->getExerciseCategories($exercise));
             $this->view->assign('editExerciseDifficulties', $this->getDifficultiesForExercise());
             $this->view->assign('previewExerciseDuration', $this->getExerciseDurationLabel($exercise));
             $this->view->assign('previewExerciseSkill', $this->getExerciseSkillLabel($exercise));
             $this->view->assign('previewExerciseDifficulty', $this->getExerciseDifficultyLabel($exercise));
             $this->view->assign('previewExerciseIsHintSet', $exercise->getHint() != '' ? 1 : 0);
             $this->view->assign('previewExerciseIsExplanationSet', $exercise->getExplanation() != '' ? 1 : 0);
             $this->view->assign('subjectOptions', $subjectRepository->findAll());
             $this->view->assign('subjectPlaceholder', $this->translateById('quiz.placeholder.subject'));
         }
         $quiz = $exercise->getQuiz();
     } else {
         if ($this->request->hasArgument('quiz')) {
             $quiz = $this->getQuizFromArgument();
         }
     }
     // Get/Set duration.
     $duration = 0;
     if (isset($quiz) && is_a($quiz, '\\_OurBrand_\\Quiz\\Domain\\Model\\Quiz')) {
         $duration = $quiz->getDuration();
     }
     $this->view->assign('duration', gmdate("H:i", $duration));
 }
 /**
  * Initialize the reflection service lazily
  *
  * This method must be run only after all dependencies have been injected.
  *
  * @return void
  */
 protected function initialize()
 {
     $this->context = $this->environment->getContext();
     if ($this->context->isProduction() && $this->reflectionDataRuntimeCache->getBackend()->isFrozen()) {
         $this->classReflectionData = $this->reflectionDataRuntimeCache->get('__classNames');
         $this->annotatedClasses = $this->reflectionDataRuntimeCache->get('__annotatedClasses');
         $this->loadFromClassSchemaRuntimeCache = true;
     } else {
         $this->loadClassReflectionCompiletimeCache();
     }
     $this->annotationReader = new AnnotationReader();
     foreach ($this->settings['reflection']['ignoredTags'] as $tagName => $ignoreFlag) {
         // Make this setting backwards compatible with old array schema (deprecated since 3.0)
         if (is_numeric($tagName) && is_string($ignoreFlag)) {
             AnnotationReader::addGlobalIgnoredName($ignoreFlag);
         }
         if ($ignoreFlag === true) {
             AnnotationReader::addGlobalIgnoredName($tagName);
         }
     }
     AnnotationRegistry::registerLoader([$this->classLoader, 'loadClass']);
     $this->initialized = true;
 }
 public function initializeServeAction()
 {
     if ($this->environment->getContext()->isDevelopment()) {
         $this->targetDirectory = 'app';
     }
 }
 /**
  * Initialize the reflection service lazily
  *
  * This method must be run only after all dependencies have been injected.
  *
  * @return void
  */
 protected function initialize()
 {
     $this->context = $this->environment->getContext();
     if ($this->context->isProduction() && $this->reflectionDataRuntimeCache->getBackend()->isFrozen()) {
         $this->classReflectionData = $this->reflectionDataRuntimeCache->get('__classNames');
         $this->annotatedClasses = $this->reflectionDataRuntimeCache->get('__annotatedClasses');
         $this->loadFromClassSchemaRuntimeCache = TRUE;
     } else {
         $this->loadClassReflectionCompiletimeCache();
     }
     $this->annotationReader = new AnnotationReader();
     foreach ($this->settings['reflection']['ignoredTags'] as $tag) {
         AnnotationReader::addGlobalIgnoredName($tag);
     }
     AnnotationRegistry::registerLoader(array($this->classLoader, 'loadClass'));
     $this->initialized = TRUE;
 }