/**
  * This method walks through the view configuration and applies
  * matching configurations in the order of their specifity score.
  * Possible options are currently the viewObjectName to specify
  * a different class that will be used to create the view and
  * an array of options that will be set on the view object.
  *
  * @param ActionRequest $request
  * @return array
  */
 public function getViewConfiguration(ActionRequest $request)
 {
     $cacheIdentifier = $this->createCacheIdentifier($request);
     $viewConfiguration = $this->cache->get($cacheIdentifier);
     if ($viewConfiguration === false) {
         $configurations = $this->configurationManager->getConfiguration('Views');
         $requestMatcher = new RequestMatcher($request);
         $context = new Context($requestMatcher);
         $viewConfiguration = [];
         $highestWeight = -1;
         foreach ($configurations as $order => $configuration) {
             $requestMatcher->resetWeight();
             if (!isset($configuration['requestFilter'])) {
                 $weight = $order;
             } else {
                 $result = $this->eelEvaluator->evaluate($configuration['requestFilter'], $context);
                 if ($result === false) {
                     continue;
                 }
                 $weight = $requestMatcher->getWeight() + $order;
             }
             if ($weight > $highestWeight) {
                 $viewConfiguration = $configuration;
                 $highestWeight = $weight;
             }
         }
         $this->cache->set($cacheIdentifier, $viewConfiguration);
     }
     return $viewConfiguration;
 }
Esempio n. 2
0
 /**
  * Gets the authentication provider configuration needed
  *
  * @return void
  */
 public function initializeObject()
 {
     $settings = $this->configurationManager->getConfiguration(\Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
     if (isset($settings['security']['authentication']['providers']['Typo3SetupProvider']['providerOptions']['keyName'])) {
         $this->keyName = $settings['security']['authentication']['providers']['Typo3SetupProvider']['providerOptions']['keyName'];
     }
 }
 /**
  * Prepares $this->nodeTypeManager with a fresh instance with all mocks and makes the given fixture data available as NodeTypes configuration
  *
  * @param array $nodeTypesFixtureData
  */
 protected function prepareNodeTypeManager(array $nodeTypesFixtureData)
 {
     $this->nodeTypeManager = new NodeTypeManager();
     $this->mockConfigurationManager = $this->getMockBuilder(ConfigurationManager::class)->disableOriginalConstructor()->getMock();
     $mockCache = $this->getMockBuilder(StringFrontend::class)->disableOriginalConstructor()->getMock();
     $mockCache->expects($this->any())->method('get')->willReturn(null);
     $this->inject($this->nodeTypeManager, 'fullConfigurationCache', $mockCache);
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with('NodeTypes')->will($this->returnValue($nodeTypesFixtureData));
     $this->inject($this->nodeTypeManager, 'configurationManager', $this->mockConfigurationManager);
 }
 /**
  * @test
  */
 public function getViewConfigurationUsedFilterConfigurationWithHigherWeight()
 {
     $matchingConfigurationOne = ['requestFilter' => 'isPackage("Neos.Flow")', 'options' => 'a value'];
     $matchingConfigurationTwo = ['requestFilter' => 'isPackage("Neos.Flow") && isFormat("html")', 'options' => 'a value with higher weight'];
     $notMatchingConfiguration = ['requestFilter' => 'isPackage("Vendor.Package")', 'options' => 'another value'];
     $viewConfigurations = [$notMatchingConfiguration, $matchingConfigurationOne, $matchingConfigurationTwo];
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with('Views')->will($this->returnValue($viewConfigurations));
     $calculatedConfiguration = $this->viewConfigurationManager->getViewConfiguration($this->mockActionRequest);
     $this->assertEquals($calculatedConfiguration, $matchingConfigurationTwo);
 }
 public function setUp()
 {
     $this->policyService = new PolicyService();
     $this->mockConfigurationManager = $this->getMockBuilder(ConfigurationManager::class)->disableOriginalConstructor()->getMock();
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with(ConfigurationManager::CONFIGURATION_TYPE_POLICY)->will($this->returnCallback(function () {
         return $this->mockPolicyConfiguration;
     }));
     $this->inject($this->policyService, 'configurationManager', $this->mockConfigurationManager);
     $this->mockObjectManager = $this->getMockBuilder(ObjectManager::class)->disableOriginalConstructor()->getMock();
     $this->inject($this->policyService, 'objectManager', $this->mockObjectManager);
     $this->mockPrivilege = $this->getAccessibleMock(AbstractPrivilege::class, ['matchesSubject'], [], '', false);
 }
 /**
  * @param string $type
  * @return void
  */
 public function indexAction($type = 'Settings')
 {
     $availableConfigurationTypes = $this->configurationManager->getAvailableConfigurationTypes();
     $this->view->assignMultiple(array('type' => $type, 'availableConfigurationTypes' => $availableConfigurationTypes));
     if (in_array($type, $availableConfigurationTypes)) {
         $this->view->assign('configuration', $this->configurationManager->getConfiguration($type));
         try {
             $this->view->assign('validationResult', $this->configurationSchemaValidator->validate($type));
         } catch (SchemaValidationException $exception) {
             $this->addFlashMessage(htmlspecialchars($exception->getMessage()), 'An error occurred during validation of the configuration.', Message::SEVERITY_ERROR, array(), 1412373972);
         }
     } else {
         $this->addFlashMessage('Configuration type not found.', '', Message::SEVERITY_ERROR, array(), 1412373998);
     }
 }
 /**
  * Returns a fresh or existing instance of the object specified by $objectName.
  *
  * This specialized get() method is able to do setter injection for properties
  * defined in the object configuration of the specified object.
  *
  * @param string $objectName The name of the object to return an instance of
  * @return object The object instance
  * @throws \Neos\Flow\ObjectManagement\Exception\CannotBuildObjectException
  * @throws \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException
  * @throws \Neos\Flow\ObjectManagement\Exception\UnknownObjectException
  */
 public function get($objectName)
 {
     if (isset($this->objects[$objectName]['i'])) {
         return $this->objects[$objectName]['i'];
     }
     if (isset($this->objectConfigurations[$objectName]) && count($this->objectConfigurations[$objectName]->getArguments()) > 0) {
         throw new Exception\CannotBuildObjectException('Cannot build object "' . $objectName . '" because constructor injection is not available in the compile time Object Manager. Refactor your code to use setter injection instead. Configuration source: ' . $this->objectConfigurations[$objectName]->getConfigurationSourceHint() . '. Build stack: ' . implode(', ', $this->objectNameBuildStack), 1297090026);
     }
     if (!isset($this->objects[$objectName])) {
         throw new Exception\UnknownObjectException('Cannot build object "' . $objectName . '" because it is unknown to the compile time Object Manager.', 1301477694);
     }
     if ($this->objects[$objectName]['s'] !== Configuration::SCOPE_SINGLETON) {
         throw new Exception\CannotBuildObjectException('Cannot build object "' . $objectName . '" because the get() method in the compile time Object Manager only supports singletons.', 1297090027);
     }
     $this->objectNameBuildStack[] = $objectName;
     $object = parent::get($objectName);
     /** @var Configuration $objectConfiguration */
     $objectConfiguration = $this->objectConfigurations[$objectName];
     /** @var Property $property */
     foreach ($objectConfiguration->getProperties() as $propertyName => $property) {
         if ($property->getAutowiring() !== Configuration::AUTOWIRING_MODE_ON) {
             continue;
         }
         switch ($property->getType()) {
             case Property::PROPERTY_TYPES_STRAIGHTVALUE:
                 $value = $property->getValue();
                 break;
             case Property::PROPERTY_TYPES_CONFIGURATION:
                 $propertyValue = $property->getValue();
                 $value = $this->configurationManager->getConfiguration($propertyValue['type'], $propertyValue['path']);
                 break;
             case Property::PROPERTY_TYPES_OBJECT:
                 $propertyObjectName = $property->getValue();
                 if (!is_string($propertyObjectName)) {
                     throw new Exception\CannotBuildObjectException('The object definition of "' . $objectName . '::' . $propertyName . '" is too complex for the compile time Object Manager. You can only use plain object names, not factories and the like. Check configuration in ' . $this->objectConfigurations[$objectName]->getConfigurationSourceHint() . ' and objects which depend on ' . $objectName . '.', 1297099659);
                 }
                 $value = $this->get($propertyObjectName);
                 break;
             default:
                 throw new Exception\CannotBuildObjectException('Invalid property type.', 1297090029);
         }
         if (method_exists($object, $setterMethodName = 'inject' . ucfirst($propertyName))) {
             $object->{$setterMethodName}($value);
         } elseif (method_exists($object, $setterMethodName = 'set' . ucfirst($propertyName))) {
             $object->{$setterMethodName}($value);
         } else {
             throw new Exception\UnresolvedDependenciesException('Could not inject configured property "' . $propertyName . '" into "' . $objectName . '" because no injection method exists, but for compile time use this is required. Configuration source: ' . $this->objectConfigurations[$objectName]->getConfigurationSourceHint() . '.', 1297110953);
         }
     }
     $initializationLifecycleMethodName = $this->objectConfigurations[$objectName]->getLifecycleInitializationMethodName();
     if (method_exists($object, $initializationLifecycleMethodName)) {
         $object->{$initializationLifecycleMethodName}();
     }
     $shutdownLifecycleMethodName = $this->objectConfigurations[$objectName]->getLifecycleShutdownMethodName();
     if (method_exists($object, $shutdownLifecycleMethodName)) {
         $this->shutdownObjects[$object] = $shutdownLifecycleMethodName;
     }
     array_pop($this->objectNameBuildStack);
     return $object;
 }
 /**
  * @test
  */
 public function flushConfigurationCachesByChangedFilesFlushesConfigurationCache()
 {
     $this->registerCache('Flow_Object_Classes');
     $this->registerCache('Flow_Object_Configuration');
     $this->mockConfigurationManager->expects($this->once())->method('flushConfigurationCache');
     $this->cacheManager->flushSystemCachesByChangedFiles('Flow_ConfigurationFiles', []);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     //
     // create a mock packageManager that only returns the the packages that contain schema files
     //
     $schemaPackages = [];
     $configurationPackages = [];
     // get all packages and select the ones we want to test
     $temporaryPackageManager = $this->objectManager->get(PackageManagerInterface::class);
     foreach ($temporaryPackageManager->getActivePackages() as $package) {
         if (in_array($package->getPackageKey(), $this->getSchemaPackageKeys())) {
             $schemaPackages[$package->getPackageKey()] = $package;
         }
         if (in_array($package->getPackageKey(), $this->getConfigurationPackageKeys())) {
             $configurationPackages[$package->getPackageKey()] = $package;
         }
     }
     $this->mockPackageManager = $this->createMock(PackageManager::class);
     $this->mockPackageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue($schemaPackages));
     //
     // create mock configurationManager and store the original one
     //
     $this->originalConfigurationManager = $this->objectManager->get(ConfigurationManager::class);
     $yamlConfigurationSource = $this->objectManager->get(\Neos\Flow\Tests\Functional\Configuration\Fixtures\RootDirectoryIgnoringYamlSource::class);
     $this->mockConfigurationManager = clone $this->originalConfigurationManager;
     $this->mockConfigurationManager->setPackages($configurationPackages);
     $this->inject($this->mockConfigurationManager, 'configurationSource', $yamlConfigurationSource);
     $this->objectManager->setInstance(ConfigurationManager::class, $this->mockConfigurationManager);
     //
     // create the configurationSchemaValidator
     //
     $this->configurationSchemaValidator = $this->objectManager->get(ConfigurationSchemaValidator::class);
     $this->inject($this->configurationSchemaValidator, 'configurationManager', $this->mockConfigurationManager);
 }
 /**
  * Parses the given configuration path expression and sets $this->actualSettingValue
  * and $this->condition accordingly
  *
  * @param string $settingComparisonExpression The configuration expression (path + optional condition)
  * @return void
  * @throws InvalidPointcutExpressionException
  */
 protected function parseConfigurationOptionPath($settingComparisonExpression)
 {
     $settingComparisonExpression = preg_split(self::PATTERN_SPLITBYEQUALSIGN, $settingComparisonExpression);
     if (isset($settingComparisonExpression[1])) {
         $matches = [];
         preg_match(self::PATTERN_MATCHVALUEINQUOTES, $settingComparisonExpression[1], $matches);
         if (isset($matches['SingleQuotedString']) && $matches['SingleQuotedString'] !== '') {
             $this->condition = $matches['SingleQuotedString'];
         } elseif (isset($matches['DoubleQuotedString']) && $matches['DoubleQuotedString'] !== '') {
             $this->condition = $matches['DoubleQuotedString'];
         } else {
             throw new InvalidPointcutExpressionException('The given condition has a syntax error (Make sure to set quotes correctly). Got: "' . $settingComparisonExpression[1] . '"', 1230047529);
         }
     }
     $configurationKeys = preg_split('/\\./', $settingComparisonExpression[0]);
     if (count($configurationKeys) > 0) {
         $settingPackageKey = array_shift($configurationKeys);
         $settingValue = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $settingPackageKey);
         foreach ($configurationKeys as $currentKey) {
             if (!isset($settingValue[$currentKey])) {
                 throw new InvalidPointcutExpressionException('The given configuration path in the pointcut designator "setting" did not exist. Got: "' . $settingComparisonExpression[0] . '"', 1230035614);
             }
             $settingValue = $settingValue[$currentKey];
         }
         $this->actualSettingValue = $settingValue;
     }
 }
Esempio n. 11
0
 /**
  * Flushes caches as needed if settings, routes or policies have changed
  *
  * @param array $changedFiles A list of full paths to changed files
  * @return void
  * @see flushSystemCachesByChangedFiles()
  */
 protected function flushConfigurationCachesByChangedFiles(array $changedFiles)
 {
     $aopProxyClassRebuildIsNeeded = false;
     $aopProxyClassInfluencers = '/(?:Policy|Objects|Settings)(?:\\..*)*\\.yaml/';
     $objectClassesCache = $this->getCache('Flow_Object_Classes');
     $objectConfigurationCache = $this->getCache('Flow_Object_Configuration');
     $caches = ['/Policy\\.yaml/' => ['Flow_Security_Authorization_Privilege_Method', 'Flow_Persistence_Doctrine', 'Flow_Persistence_Doctrine_Results', 'Flow_Aop_RuntimeExpressions'], '/Routes([^\\/]*)\\.yaml/' => ['Flow_Mvc_Routing_Route', 'Flow_Mvc_Routing_Resolve'], '/Views\\.yaml/' => ['Flow_Mvc_ViewConfigurations']];
     $cachesToFlush = [];
     foreach (array_keys($changedFiles) as $pathAndFilename) {
         foreach ($caches as $cacheFilePattern => $cacheNames) {
             if (preg_match($aopProxyClassInfluencers, $pathAndFilename) === 1) {
                 $aopProxyClassRebuildIsNeeded = true;
             }
             if (preg_match($cacheFilePattern, $pathAndFilename) !== 1) {
                 continue;
             }
             foreach ($caches[$cacheFilePattern] as $cacheName) {
                 $cachesToFlush[$cacheName] = $cacheFilePattern;
             }
         }
     }
     foreach ($cachesToFlush as $cacheName => $cacheFilePattern) {
         $this->systemLogger->log(sprintf('A configuration file matching the pattern "%s" has been changed, flushing related cache "%s"', $cacheFilePattern, $cacheName), LOG_INFO);
         $this->getCache($cacheName)->flush();
     }
     $this->systemLogger->log('A configuration file has been changed, flushing compiled configuration cache', LOG_INFO);
     $this->configurationManager->flushConfigurationCache();
     if ($aopProxyClassRebuildIsNeeded) {
         $this->systemLogger->log('The configuration has changed, triggering an AOP proxy class rebuild.', LOG_INFO);
         $objectConfigurationCache->remove('allAspectClassesUpToDate');
         $objectConfigurationCache->remove('allCompiledCodeUpToDate');
         $objectClassesCache->flush();
     }
 }
 /**
  * Validate a single configuration type
  *
  * @param string $configurationType the configuration typr to validate
  * @param string $path configuration path to validate, or NULL.
  * @param array $loadedSchemaFiles will be filled with a list of loaded schema files
  * @return \Neos\Error\Messages\Result
  * @throws Exception\SchemaValidationException
  */
 protected function validateSingleType($configurationType, $path, &$loadedSchemaFiles)
 {
     $availableConfigurationTypes = $this->configurationManager->getAvailableConfigurationTypes();
     if (in_array($configurationType, $availableConfigurationTypes) === false) {
         throw new Exception\SchemaValidationException('The configuration type "' . $configurationType . '" was not found. Only the following configuration types are supported: "' . implode('", "', $availableConfigurationTypes) . '"', 1364984886);
     }
     $configuration = $this->configurationManager->getConfiguration($configurationType);
     // find schema files for the given type and path
     $schemaFileInfos = [];
     $activePackages = $this->packageManager->getActivePackages();
     foreach ($activePackages as $package) {
         $packageKey = $package->getPackageKey();
         $packageSchemaPath = Files::concatenatePaths([$package->getResourcesPath(), 'Private/Schema']);
         if (is_dir($packageSchemaPath)) {
             foreach (Files::getRecursiveDirectoryGenerator($packageSchemaPath, '.schema.yaml') as $schemaFile) {
                 $schemaName = substr($schemaFile, strlen($packageSchemaPath) + 1, -strlen('.schema.yaml'));
                 $schemaNameParts = explode('.', str_replace('/', '.', $schemaName), 2);
                 $schemaType = $schemaNameParts[0];
                 $schemaPath = isset($schemaNameParts[1]) ? $schemaNameParts[1] : null;
                 if ($schemaType === $configurationType && ($path === null || strpos($schemaPath, $path) === 0)) {
                     $schemaFileInfos[] = ['file' => $schemaFile, 'name' => $schemaName, 'path' => $schemaPath, 'packageKey' => $packageKey];
                 }
             }
         }
     }
     if (count($schemaFileInfos) === 0) {
         throw new Exception\SchemaValidationException('No schema files found for configuration type "' . $configurationType . '"' . ($path !== null ? ' and path "' . $path . '".' : '.'), 1364985056);
     }
     $result = new Result();
     foreach ($schemaFileInfos as $schemaFileInfo) {
         $loadedSchemaFiles[] = $schemaFileInfo['file'];
         if ($schemaFileInfo['path'] !== null) {
             $data = Arrays::getValueByPath($configuration, $schemaFileInfo['path']);
         } else {
             $data = $configuration;
         }
         if (empty($data)) {
             $result->addNotice(new Notice('No configuration found, skipping schema "%s".', 1364985445, [substr($schemaFileInfo['file'], strlen(FLOW_PATH_ROOT))]));
         } else {
             $parsedSchema = Yaml::parse($schemaFileInfo['file']);
             $validationResultForSingleSchema = $this->schemaValidator->validate($data, $parsedSchema);
             if ($schemaFileInfo['path'] !== null) {
                 $result->forProperty($schemaFileInfo['path'])->merge($validationResultForSingleSchema);
             } else {
                 $result->merge($validationResultForSingleSchema);
             }
         }
     }
     return $result;
 }
Esempio n. 13
0
 /**
  * @param string $driver
  * @param string $user
  * @param string $password
  * @param string $host
  * @return array
  */
 protected function buildConnectionSettingsArray($driver, $user, $password, $host)
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
     $connectionSettings = $settings['persistence']['backendOptions'];
     $connectionSettings['driver'] = $driver;
     $connectionSettings['user'] = $user;
     $connectionSettings['password'] = $password;
     $connectionSettings['host'] = $host;
     if ($connectionSettings['driver'] === 'pdo_pgsql') {
         $connectionSettings['dbname'] = 'template1';
         return $connectionSettings;
     } else {
         unset($connectionSettings['dbname']);
         return $connectionSettings;
     }
 }
 /**
  * Generate a schema for the given configuration or YAML file.
  *
  * ./flow configuration:generateschema --type Settings --path Neos.Flow.persistence
  *
  * The schema will be output to standard output.
  *
  * @param string $type Configuration type to create a schema for
  * @param string $path path to the subconfiguration separated by "." like "Neos.Flow"
  * @param string $yaml YAML file to create a schema for
  * @return void
  */
 public function generateSchemaCommand($type = null, $path = null, $yaml = null)
 {
     $data = null;
     if ($yaml !== null && is_file($yaml) && is_readable($yaml)) {
         $data = Yaml::parse($yaml);
     } elseif ($type !== null) {
         $data = $this->configurationManager->getConfiguration($type);
         if ($path !== null) {
             $data = Arrays::getValueByPath($data, $path);
         }
     }
     if (empty($data)) {
         $this->outputLine('Data was not found or is empty');
         $this->quit(1);
     }
     $this->outputLine(Yaml::dump($this->schemaGenerator->generate($data), 99));
 }
 /**
  * Loads all node types into memory.
  *
  * @return void
  */
 protected function loadNodeTypes()
 {
     $this->fullNodeTypeConfigurations = $this->fullConfigurationCache->get('fullNodeTypeConfigurations');
     $fillFullConfigurationCache = !is_array($this->fullNodeTypeConfigurations);
     $completeNodeTypeConfiguration = $this->configurationManager->getConfiguration('NodeTypes');
     foreach (array_keys($completeNodeTypeConfiguration) as $nodeTypeName) {
         if (!is_array($completeNodeTypeConfiguration[$nodeTypeName])) {
             continue;
         }
         $nodeType = $this->loadNodeType($nodeTypeName, $completeNodeTypeConfiguration, isset($this->fullNodeTypeConfigurations[$nodeTypeName]) ? $this->fullNodeTypeConfigurations[$nodeTypeName] : null);
         if ($fillFullConfigurationCache) {
             $this->fullNodeTypeConfigurations[$nodeTypeName] = $nodeType->getFullConfiguration();
         }
     }
     if ($fillFullConfigurationCache) {
         $this->fullConfigurationCache->set('fullNodeTypeConfigurations', $this->fullNodeTypeConfigurations);
     }
     $this->fullNodeTypeConfigurations = null;
 }
 /**
  * FIXME: Not yet completely refactored to new proxy mechanism
  *
  * @param array $argumentConfigurations
  * @return string
  */
 protected function buildMethodParametersCode(array $argumentConfigurations)
 {
     $preparedArguments = [];
     foreach ($argumentConfigurations as $argument) {
         if ($argument === null) {
             $preparedArguments[] = 'NULL';
         } else {
             $argumentValue = $argument->getValue();
             switch ($argument->getType()) {
                 case ConfigurationArgument::ARGUMENT_TYPES_OBJECT:
                     if ($argumentValue instanceof Configuration) {
                         $argumentValueObjectName = $argumentValue->getObjectName();
                         if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
                             $preparedArguments[] = 'new \\' . $argumentValueObjectName . '(' . $this->buildMethodParametersCode($argumentValue->getArguments(), $this->objectConfigurations) . ')';
                         } else {
                             $preparedArguments[] = '\\Neos\\Flow\\Core\\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')';
                         }
                     } else {
                         if (strpos($argumentValue, '.') !== false) {
                             $settingPath = explode('.', $argumentValue);
                             $settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
                             $argumentValue = Arrays::getValueByPath($settings, $settingPath);
                         }
                         $preparedArguments[] = '\\Neos\\Flow\\Core\\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')';
                     }
                     break;
                 case ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE:
                     $preparedArguments[] = var_export($argumentValue, true);
                     break;
                 case ConfigurationArgument::ARGUMENT_TYPES_SETTING:
                     $preparedArguments[] = '\\Neos\\Flow\\Core\\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))';
                     break;
             }
         }
     }
     return implode(', ', $preparedArguments);
 }
Esempio n. 17
0
 /**
  * Checks if a routes configuration was set and otherwise loads the configuration from the configuration manager.
  *
  * @return void
  */
 protected function initializeRoutesConfiguration()
 {
     if ($this->routesConfiguration === null) {
         $this->routesConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
     }
 }
Esempio n. 18
0
 /**
  * @return void
  * @internal
  */
 public function initializeObject()
 {
     $this->formSettings = $this->configurationManager->getConfiguration(\Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Form');
 }
 /**
  * @test
  */
 public function injectionOfOtherConfigurationTypes()
 {
     $classWithInjectedConfiguration = new Fixtures\ClassWithInjectedConfiguration();
     $this->assertSame($this->configurationManager->getConfiguration('Views'), $classWithInjectedConfiguration->getInjectedViewsConfiguration());
 }
 /**
  * Parses the global policy configuration and initializes roles and privileges accordingly
  *
  * @return void
  * @throws SecurityException
  */
 protected function initialize()
 {
     if ($this->initialized) {
         return;
     }
     $this->policyConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_POLICY);
     $this->emitConfigurationLoaded($this->policyConfiguration);
     $this->initializePrivilegeTargets();
     $privilegeTargetsForEverybody = $this->privilegeTargets;
     $this->roles = [];
     $everybodyRole = new Role('Neos.Flow:Everybody');
     $everybodyRole->setAbstract(true);
     if (isset($this->policyConfiguration['roles'])) {
         foreach ($this->policyConfiguration['roles'] as $roleIdentifier => $roleConfiguration) {
             if ($roleIdentifier === 'Neos.Flow:Everybody') {
                 $role = $everybodyRole;
             } else {
                 $role = new Role($roleIdentifier);
                 if (isset($roleConfiguration['abstract'])) {
                     $role->setAbstract((bool) $roleConfiguration['abstract']);
                 }
             }
             if (isset($roleConfiguration['privileges'])) {
                 foreach ($roleConfiguration['privileges'] as $privilegeConfiguration) {
                     $privilegeTargetIdentifier = $privilegeConfiguration['privilegeTarget'];
                     if (!isset($this->privilegeTargets[$privilegeTargetIdentifier])) {
                         throw new SecurityException(sprintf('privilege target "%s", referenced in role configuration "%s" is not defined!', $privilegeTargetIdentifier, $roleIdentifier), 1395869320);
                     }
                     $privilegeTarget = $this->privilegeTargets[$privilegeTargetIdentifier];
                     if (!isset($privilegeConfiguration['permission'])) {
                         throw new SecurityException(sprintf('No permission set for privilegeTarget "%s" in Role "%s"', $privilegeTargetIdentifier, $roleIdentifier), 1395869331);
                     }
                     $privilegeParameters = isset($privilegeConfiguration['parameters']) ? $privilegeConfiguration['parameters'] : [];
                     try {
                         $privilege = $privilegeTarget->createPrivilege($privilegeConfiguration['permission'], $privilegeParameters);
                     } catch (\Exception $exception) {
                         throw new SecurityException(sprintf('Error for privilegeTarget "%s" in Role "%s": %s', $privilegeTargetIdentifier, $roleIdentifier, $exception->getMessage()), 1401886654, $exception);
                     }
                     $role->addPrivilege($privilege);
                     if ($roleIdentifier === 'Neos.Flow:Everybody') {
                         unset($privilegeTargetsForEverybody[$privilegeTargetIdentifier]);
                     }
                 }
             }
             $this->roles[$roleIdentifier] = $role;
         }
     }
     // create ABSTAIN privilege for all uncovered privilegeTargets
     /** @var PrivilegeTarget $privilegeTarget */
     foreach ($privilegeTargetsForEverybody as $privilegeTarget) {
         if ($privilegeTarget->hasParameters()) {
             continue;
         }
         $everybodyRole->addPrivilege($privilegeTarget->createPrivilege(PrivilegeInterface::ABSTAIN));
     }
     $this->roles['Neos.Flow:Everybody'] = $everybodyRole;
     // Set parent roles
     /** @var Role $role */
     foreach ($this->roles as $role) {
         if (isset($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'])) {
             foreach ($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'] as $parentRoleIdentifier) {
                 $role->addParentRole($this->roles[$parentRoleIdentifier]);
             }
         }
     }
     $this->emitRolesInitialized($this->roles);
     $this->initialized = true;
 }
 /**
  * Initializes the Configuration Manager, the Flow settings and the Environment service
  *
  * @param Bootstrap $bootstrap
  * @return void
  * @throws FlowException
  */
 public static function initializeConfiguration(Bootstrap $bootstrap)
 {
     $context = $bootstrap->getContext();
     $environment = new Environment($context);
     $environment->setTemporaryDirectoryBase(FLOW_PATH_TEMPORARY_BASE);
     $bootstrap->setEarlyInstance(Environment::class, $environment);
     $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);
     $configurationManager = new ConfigurationManager($context);
     $configurationManager->setTemporaryDirectoryPath($environment->getPathToTemporaryDirectory());
     $configurationManager->injectConfigurationSource(new YamlSource());
     $configurationManager->setPackages($packageManager->getActivePackages());
     $configurationManager->loadConfigurationCache();
     $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
     $lockManager = new LockManager($settings['utility']['lockStrategyClassName'], ['lockDirectory' => Files::concatenatePaths([$environment->getPathToTemporaryDirectory(), 'Lock'])]);
     Lock::setLockManager($lockManager);
     $packageManager->injectSettings($settings);
     $bootstrap->getSignalSlotDispatcher()->dispatch(ConfigurationManager::class, 'configurationManagerReady', [$configurationManager]);
     $bootstrap->setEarlyInstance(ConfigurationManager::class, $configurationManager);
 }
Esempio n. 22
0
 /**
  * Initializes the Configuration Manager, the Flow settings and the Environment service
  *
  * @param Bootstrap $bootstrap
  * @return void
  * @throws FlowException
  */
 public static function initializeConfiguration(Bootstrap $bootstrap)
 {
     $context = $bootstrap->getContext();
     $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);
     $configurationManager = new ConfigurationManager($context);
     $configurationManager->injectConfigurationSource(new YamlSource());
     $configurationManager->loadConfigurationCache();
     $configurationManager->setPackages($packageManager->getActivePackages());
     $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
     $environment = new Environment($context);
     if (isset($settings['utility']['environment']['temporaryDirectoryBase'])) {
         $defaultTemporaryDirectoryBase = FLOW_PATH_DATA . '/Temporary';
         if (FLOW_PATH_TEMPORARY_BASE !== $defaultTemporaryDirectoryBase) {
             throw new FlowException(sprintf('It seems like the PHP default temporary base path has been changed from "%s" to "%s" via the FLOW_PATH_TEMPORARY_BASE environment variable. If that variable is present, the Neos.Flow.utility.environment.temporaryDirectoryBase setting must not be specified!', $defaultTemporaryDirectoryBase, FLOW_PATH_TEMPORARY_BASE), 1447707261);
         }
         $environment->setTemporaryDirectoryBase($settings['utility']['environment']['temporaryDirectoryBase']);
     } else {
         $environment->setTemporaryDirectoryBase(FLOW_PATH_TEMPORARY_BASE);
     }
     $configurationManager->setTemporaryDirectoryPath($environment->getPathToTemporaryDirectory());
     $lockManager = new LockManager($settings['utility']['lockStrategyClassName'], ['lockDirectory' => Files::concatenatePaths([$environment->getPathToTemporaryDirectory(), 'Lock'])]);
     Lock::setLockManager($lockManager);
     $packageManager->injectSettings($settings);
     $bootstrap->getSignalSlotDispatcher()->dispatch(ConfigurationManager::class, 'configurationManagerReady', [$configurationManager]);
     $bootstrap->setEarlyInstance(ConfigurationManager::class, $configurationManager);
     $bootstrap->setEarlyInstance(Environment::class, $environment);
 }
 /**
  * @param ConfigurationManager $configurationManager
  * @return void
  */
 public function injectConfigurationManager(ConfigurationManager $configurationManager)
 {
     $this->contentDimensionsConfiguration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.ContentRepository.contentDimensions');
 }
 /**
  * Return the specified settings
  *
  * Examples::
  *
  *     Configuration.setting('Neos.Flow.core.context') == 'Production'
  *
  *     Configuration.setting('Acme.Demo.speedMode') == 'light speed'
  *
  * @param string $settingPath
  * @return mixed
  */
 public function setting($settingPath)
 {
     return $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $settingPath);
 }