public static function getDefaultContextVariables(array $configuration) { $defaultContextVariables = []; foreach ($configuration as $variableName => $objectType) { $currentPathBase =& $defaultContextVariables; $variablePathNames = explode('.', $variableName); foreach ($variablePathNames as $pathName) { if (!isset($currentPathBase[$pathName])) { $currentPathBase[$pathName] = []; } $currentPathBase =& $currentPathBase[$pathName]; } $currentPathBase = new $objectType(); } return $defaultContextVariables; }
/** * Get variables from configuration that should be set in the context by default. * For example Eel helpers are made available by this. * * @return array Array with default context variable objects. */ protected function getDefaultContextVariables() { if ($this->defaultContextVariables === null) { $this->defaultContextVariables = array(); if (isset($this->settings['defaultContext']) && is_array($this->settings['defaultContext'])) { $this->defaultContextVariables = EelUtility::getDefaultContextVariables($this->settings['defaultContext']); } $this->defaultContextVariables['request'] = $this->controllerContext->getRequest(); } return $this->defaultContextVariables; }