/**
  * @return void
  */
 protected function initializeAction()
 {
     $this->objects = $this->widgetConfiguration['objects'];
     $this->configuration = Arrays::arrayMergeRecursiveOverrule($this->configuration, $this->widgetConfiguration['configuration'], true);
     $this->numberOfPages = (int) ceil(count($this->objects) / (int) $this->configuration['itemsPerPage']);
     $this->maximumNumberOfLinks = (int) $this->configuration['maximumNumberOfLinks'];
 }
 /**
  * Create a new user
  *
  * This command creates a new user which has access to the backend user interface.
  *
  * More specifically, this command will create a new user and a new account at the same time. The created account
  * is, by default, a Neos backend account using the the "Typo3BackendProvider" for authentication. The given username
  * will be used as an account identifier for that new account.
  *
  * If an authentication provider name is specified, the new account will be created for that provider instead.
  *
  * Roles for the new user can optionally be specified as a comma separated list. For all roles provided by
  * Neos, the role namespace "TYPO3.Neos:" can be omitted.
  *
  * @param string $username The username of the user to be created, used as an account identifier for the newly created account
  * @param string $password Password of the user to be created
  * @param string $firstName First name of the user to be created
  * @param string $lastName Last name of the user to be created
  * @param string $department department name of the user to be created
  * @param string $photo photo name of the user to be created
  * @param string $roles A comma separated list of roles to assign. Examples: "Editor, Acme.Foo:Reviewer"
  * @param string $authenticationProvider Name of the authentication provider to use for the new account. Example: "Typo3BackendProvider"
  * @return void
  */
 public function createPhluCommand($username, $password, $firstName, $lastName, $department, $photo, $roles = null, $authenticationProvider = null)
 {
     $user = $this->userService->getUser($username, $authenticationProvider);
     if ($user instanceof User) {
         $this->outputLine('The username "%s" is already in use', array($username));
         $this->quit(1);
     }
     try {
         if ($roles === null) {
             $user = $this->userService->createUserPhlu($username, $password, $firstName, $lastName, $department, $photo, null, $authenticationProvider);
         } else {
             $roleIdentifiers = Arrays::trimExplode(',', $roles);
             $user = $this->userService->createUserPhlu($username, $password, $firstName, $lastName, $department, $photo, $roleIdentifiers, $authenticationProvider);
         }
         $roleIdentifiers = array();
         foreach ($user->getAccounts() as $account) {
             /** @var Account $account */
             foreach ($account->getRoles() as $role) {
                 /** @var Role $role */
                 $roleIdentifiers[$role->getIdentifier()] = true;
             }
         }
         $roleIdentifiers = array_keys($roleIdentifiers);
         if (count($roleIdentifiers) === 0) {
             $this->outputLine('Created user "%s".', array($username));
             $this->outputLine('<b>Please note that this user currently does not have any roles assigned.</b>');
         } else {
             $this->outputLine('Created user "%s" and assigned the following role%s: %s.', array($username, count($roleIdentifiers) > 1 ? 's' : '', implode(', ', $roleIdentifiers)));
         }
     } catch (\Exception $exception) {
         $this->outputLine($exception->getMessage());
         $this->quit(1);
     }
 }
 /**
  * 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 \TYPO3\Flow\Mvc\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);
         $matchingConfigurations = array();
         foreach ($configurations as $order => $configuration) {
             $requestMatcher->resetWeight();
             if (!isset($configuration['requestFilter'])) {
                 $matchingConfigurations[$order]['configuration'] = $configuration;
                 $matchingConfigurations[$order]['weight'] = $order;
             } else {
                 $result = $this->eelEvaluator->evaluate($configuration['requestFilter'], $context);
                 if ($result === false) {
                     continue;
                 }
                 $matchingConfigurations[$order]['configuration'] = $configuration;
                 $matchingConfigurations[$order]['weight'] = $requestMatcher->getWeight() + $order;
             }
         }
         usort($matchingConfigurations, function ($configuration1, $configuration2) {
             return $configuration1['weight'] > $configuration2['weight'];
         });
         $viewConfiguration = array();
         foreach ($matchingConfigurations as $key => $matchingConfiguration) {
             $viewConfiguration = Arrays::arrayMergeRecursiveOverrule($viewConfiguration, $matchingConfiguration['configuration']);
         }
         $this->cache->set($cacheIdentifier, $viewConfiguration);
     }
     return $viewConfiguration;
 }
Example #4
0
 /**
  *
  * @param string $type
  * @param boolean $showHiddenProperties if TRUE, the hidden properties are shown as configured in settings "supertypeResolver.hiddenProperties" are shown as well. FALSE by default
  * @return array
  * @throws \TYPO3\Form\Exception\TypeDefinitionNotFoundException if a type definition was not found
  * @internal
  */
 public function getMergedTypeDefinition($type, $showHiddenProperties = FALSE)
 {
     if (!isset($this->configuration[$type])) {
         throw new \TYPO3\Form\Exception\TypeDefinitionNotFoundException(sprintf('Type "%s" not found. Probably some configuration is missing.', $type), 1325686909);
     }
     $mergedTypeDefinition = array();
     if (isset($this->configuration[$type]['superTypes'])) {
         foreach ($this->configuration[$type]['superTypes'] as $superTypeName => $enabled) {
             // Skip unset node types
             if ($enabled === FALSE || $enabled === NULL) {
                 continue;
             }
             // Make this setting backwards compatible with old array schema (deprecated since 2.0)
             if (!is_bool($enabled)) {
                 $superTypeName = $enabled;
             }
             $mergedTypeDefinition = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($mergedTypeDefinition, $this->getMergedTypeDefinition($superTypeName, $showHiddenProperties));
         }
     }
     $mergedTypeDefinition = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($mergedTypeDefinition, $this->configuration[$type]);
     unset($mergedTypeDefinition['superTypes']);
     if ($showHiddenProperties === FALSE && isset($this->settings['supertypeResolver']['hiddenProperties']) && is_array($this->settings['supertypeResolver']['hiddenProperties'])) {
         foreach ($this->settings['supertypeResolver']['hiddenProperties'] as $propertyName) {
             unset($mergedTypeDefinition[$propertyName]);
         }
     }
     return $mergedTypeDefinition;
 }
 /**
  * @param string $version
  * @param boolean $loadJQuery
  * @param boolean $loadEmberData
  * @param boolean $minified
  * @return string
  * @throws \Exception
  */
 public function render($version = NULL, $loadJQuery = FALSE, $loadEmberData = FALSE, $minified = TRUE)
 {
     $defaults = $this->getConfigurationArray('defaults', $version, $minified);
     $version = $this->findVersionToLoad($version);
     // Make sure the requested version has Ember-data configured
     if ($loadEmberData && $this->settings['versions'][$version]['hasData'] === FALSE) {
         throw new \Exception(sprintf('Version %s has no Ember-data configured', $version));
     }
     // Merge defaults and version configuration (version configuration overrides defaults)
     $configuration = Arrays::arrayMergeRecursiveOverrule($defaults, $this->getConfigurationArray($version, $version, $minified), FALSE, FALSE);
     // Remove jQuery
     if ($loadJQuery === FALSE && isset($configuration['requirements']['jquery'])) {
         unset($configuration['requirements']['jquery']);
     }
     // Build the includes array
     $includes = array();
     foreach ($configuration['requirements'] as $requirement) {
         $includes[] = $requirement['path'];
     }
     $includes[] = $this->getResourcePath($this->settings['paths']['ember'], $version, $minified);
     if ($loadEmberData === TRUE) {
         $includes[] = $this->getResourcePath($this->settings['paths']['ember-data'], $version, $minified);
     }
     // Generate script tags
     $baseUrl = $this->resourcePublisher->getStaticResourcesWebBaseUri();
     $includes = array_map(function ($file) use($baseUrl) {
         return sprintf('<script src="%sPackages/%s"></script>', $baseUrl, $file);
     }, $includes);
     return implode('', $includes);
 }
Example #6
0
 /**
  * Construct a couch DB connection from basic connection parameters for one
  * given database.
  *
  * @param string $host
  * @param integer $port
  * @param string $username
  * @param string $password
  * @param array $options
  */
 public function __construct($host, $port = 5984, $username = NULL, $password = NULL, array $options = array())
 {
     $this->options['host'] = (string) $host;
     $this->options['port'] = (int) $port;
     $this->options['username'] = $username;
     $this->options['password'] = $password;
     $this->options = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->options, $options, TRUE);
 }
 /**
  * @param ElasticSearchQueryResult $queryResultObject
  * @param NodeInterface $node
  * @param array|string $path
  * @return array
  */
 public function render(ElasticSearchQueryResult $queryResultObject, NodeInterface $node, $path = NULL)
 {
     $hitArray = $queryResultObject->searchHitForNode($node);
     if (!empty($path)) {
         return \TYPO3\Flow\Utility\Arrays::getValueByPath($hitArray, $path);
     }
     return $hitArray;
 }
 /**
  * Merges the given context properties with sane defaults for the context implementation.
  *
  * @param array $contextProperties
  * @return array
  */
 protected function mergeContextPropertiesWithDefaults(array $contextProperties)
 {
     $contextProperties = $this->removeDeprecatedProperties($contextProperties);
     $defaultContextProperties = array('workspaceName' => 'live', 'currentDateTime' => $this->now, 'dimensions' => array(), 'targetDimensions' => array(), 'invisibleContentShown' => FALSE, 'removedContentShown' => FALSE, 'inaccessibleContentShown' => FALSE, 'currentSite' => NULL, 'currentDomain' => NULL);
     $mergedProperties = Arrays::arrayMergeRecursiveOverrule($defaultContextProperties, $contextProperties, TRUE);
     $this->mergeDimensionValues($contextProperties, $mergedProperties);
     $this->mergeTargetDimensionContextProperties($contextProperties, $mergedProperties, $defaultContextProperties);
     return $mergedProperties;
 }
Example #9
0
 /**
  * This method is called when the form of this step has been submitted
  *
  * @param array $formValues
  * @return void
  */
 public function postProcessFormValues(array $formValues)
 {
     if (empty($formValues['defaultDeploymentPath']) === FALSE) {
         $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.frontendSettings.defaultDeploymentPath', $formValues['defaultDeploymentPath']);
     }
     if (empty($formValues['defaultUser']) === FALSE) {
         $this->distributionSettings = Arrays::setValueByPath($this->distributionSettings, 'Lightwerk.SurfCaptain.frontendSettings.defaultUser', $formValues['defaultUser']);
     }
     $this->configurationSource->save(FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->distributionSettings);
 }
Example #10
0
 /**
  * @param Request $httpRequest
  * @param array $matchResults
  * @return ActionRequest
  */
 protected function createActionRequest(Request $httpRequest, array $matchResults = NULL)
 {
     $actionRequest = new ActionRequest($httpRequest);
     if ($matchResults !== NULL) {
         $requestArguments = $actionRequest->getArguments();
         $mergedArguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $matchResults);
         $actionRequest->setArguments($mergedArguments);
     }
     return $actionRequest;
 }
 /**
  * @test
  */
 public function ignoredClassesCanBeOverwrittenBySettings()
 {
     $object = new ApplicationContext('Development');
     $this->assertEquals('TYPO3\\Flow\\Core\\ApplicationContext prototype object', Debugger::renderDump($object, 10, TRUE));
     Debugger::clearState();
     $currentConfiguration = ObjectAccess::getProperty($this->configurationManager, 'configurations', TRUE);
     $configurationOverwrite['Settings']['TYPO3']['Flow']['error']['debugger']['ignoredClasses']['TYPO3\\\\Flow\\\\Core\\\\.*'] = FALSE;
     $newConfiguration = Arrays::arrayMergeRecursiveOverrule($currentConfiguration, $configurationOverwrite);
     ObjectAccess::setProperty($this->configurationManager, 'configurations', $newConfiguration, TRUE);
     $this->assertContains('rootContextString', Debugger::renderDump($object, 10, TRUE));
 }
Example #12
0
 /**
  * @param string $persistenceIdentifier the persistence identifier for the form.
  * @param string $factoryClass The fully qualified class name of the factory (which has to implement \TYPO3\Form\Factory\FormFactoryInterface)
  * @param string $presetName name of the preset to use
  * @param array $overrideConfiguration factory specific configuration
  * @return string the rendered form
  */
 public function render($persistenceIdentifier = NULL, $factoryClass = 'TYPO3\\Form\\Factory\\ArrayFormFactory', $presetName = 'default', array $overrideConfiguration = array())
 {
     if (isset($persistenceIdentifier)) {
         $overrideConfiguration = Arrays::arrayMergeRecursiveOverrule($this->formPersistenceManager->load($persistenceIdentifier), $overrideConfiguration);
     }
     $factory = $this->objectManager->get($factoryClass);
     $formDefinition = $factory->build($overrideConfiguration, $presetName);
     $response = new Response($this->controllerContext->getResponse());
     $form = $formDefinition->bind($this->controllerContext->getRequest(), $response);
     return $form->render();
 }
 /**
  * Executes this task
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  * @throws \TYPO3\Surf\Exception\TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     parent::execute($node, $application, $deployment, $options);
     $settingsPatch = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($this->resourcePath . '/Settings.yaml'));
     $settings = (array) \Symfony\Component\Yaml\Yaml::parse(FLOW_PATH_ROOT . '/Configuration/Settings.yaml');
     $settings = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($settings, $settingsPatch);
     $patchedSettings = $this->temporaryPath . '/Settings.yaml';
     file_put_contents($patchedSettings, \Symfony\Component\Yaml\Yaml::dump($settings, 999));
     $patchedSettingsTargetPath = $deployment->getApplicationReleasePath($application) . '/Configuration/Settings.yaml';
     $this->copy($patchedSettings, $patchedSettingsTargetPath);
 }
 /**
  * Merges the given context properties with sane defaults for the context implementation.
  *
  * @param array $contextProperties
  * @return array
  */
 protected function mergeContextPropertiesWithDefaults(array $contextProperties)
 {
     $contextProperties = $this->removeDeprecatedProperties($contextProperties);
     $defaultContextProperties = array('workspaceName' => 'live', 'currentDateTime' => $this->now, 'dimensions' => array(), 'targetDimensions' => array(), 'invisibleContentShown' => false, 'removedContentShown' => false, 'inaccessibleContentShown' => false, 'currentSite' => null, 'currentDomain' => null);
     if (!isset($contextProperties['currentSite'])) {
         $defaultContextProperties = $this->setDefaultSiteAndDomainFromCurrentRequest($defaultContextProperties);
     }
     $mergedProperties = Arrays::arrayMergeRecursiveOverrule($defaultContextProperties, $contextProperties, true);
     $this->mergeDimensionValues($contextProperties, $mergedProperties);
     $this->mergeTargetDimensionContextProperties($contextProperties, $mergedProperties, $defaultContextProperties);
     return $mergedProperties;
 }
 /**
  * @return void
  */
 protected function initializeView(FluidView $fluidView)
 {
     $user = $this->getUserData($this['username']);
     $excludedProjects = Arrays::trimExplode(',', $this['excludedprojects']);
     $decodedProjects = $this->getProjectsData($user['id']);
     $projects = [];
     foreach ($decodedProjects['objects'] as $project) {
         if (!in_array($project['slug'], $excludedProjects)) {
             $projects[] = $project;
         }
     }
     $fluidView->assign('projects', $projects);
 }
 /**
  * @param string $packageKey
  * @param array $classNames
  * @return void
  */
 public function findModelImplementations($packageKey, array &$classNames)
 {
     // TODO: OPTIMIZE and CLEANUP!
     $this->ignoredProperties = \TYPO3\Flow\Utility\Arrays::getValueByPath($this->settings, 'properties._exclude');
     foreach ($this->getModelNames() as $entityClassName) {
         if (substr($entityClassName, 0, strlen($packageKey)) === str_replace('.', '\\', $packageKey)) {
             if (isset($classNames[$entityClassName])) {
                 continue;
             }
             $classNames[$entityClassName] = $this->findModelProperties($entityClassName);
         }
     }
 }
 /**
  * @param string $grantType One of this' interface GRANT_TYPE_* constants
  * @param array $additionalParameters Additional parameters for the request
  * @return mixed
  * @throws \Flowpack\OAuth2\Client\Exception
  * @see http://tools.ietf.org/html/rfc6749#section-4.1.3
  */
 protected function requestAccessToken($grantType, $additionalParameters = array())
 {
     $parameters = array('grant_type' => $grantType, 'client_id' => $this->clientIdentifier, 'client_secret' => $this->clientSecret);
     $parameters = Arrays::arrayMergeRecursiveOverrule($parameters, $additionalParameters, FALSE, FALSE);
     $request = Request::create(new Uri($this->endpointUri), 'POST', $parameters);
     $request->setHeader('Content-Type', 'application/x-www-form-urlencoded');
     $response = $this->requestEngine->sendRequest($request);
     if ($response->getStatusCode() !== 200) {
         throw new OAuth2Exception(sprintf('The response when requesting the access token was not as expected, code and message was: %d %s', $response->getStatusCode(), $response->getContent()), 1383749757);
     }
     $responseComponents = json_decode($response->getContent(), true);
     return $responseComponents['access_token'];
 }
 /**
  * Iterate through the segments of the current request path
  * find the corresponding module configuration and set controller & action
  * accordingly
  *
  * @param string $value
  * @return boolean|integer
  */
 protected function matchValue($value)
 {
     $format = pathinfo($value, PATHINFO_EXTENSION);
     if ($format !== '') {
         $value = substr($value, 0, strlen($value) - strlen($format) - 1);
     }
     $segments = Arrays::trimExplode('/', $value);
     $currentModuleBase = $this->settings['modules'];
     if ($segments === array() || !isset($currentModuleBase[$segments[0]])) {
         return self::MATCHRESULT_NOSUCHMODULE;
     }
     $modulePath = array();
     $level = 0;
     $moduleConfiguration = null;
     $moduleController = null;
     $moduleAction = 'index';
     foreach ($segments as $segment) {
         if (isset($currentModuleBase[$segment])) {
             $modulePath[] = $segment;
             $moduleConfiguration = $currentModuleBase[$segment];
             if (isset($moduleConfiguration['controller'])) {
                 $moduleController = $moduleConfiguration['controller'];
             } else {
                 $moduleController = null;
             }
             if (isset($moduleConfiguration['submodules'])) {
                 $currentModuleBase = $moduleConfiguration['submodules'];
             } else {
                 $currentModuleBase = array();
             }
         } else {
             if ($level === count($segments) - 1) {
                 $moduleMethods = array_change_key_case(array_flip(get_class_methods($moduleController)), CASE_LOWER);
                 if (array_key_exists($segment . 'action', $moduleMethods)) {
                     $moduleAction = $segment;
                     break;
                 }
             }
             return self::MATCHRESULT_NOSUCHMODULE;
         }
         $level++;
     }
     if ($moduleController === null) {
         return self::MATCHRESULT_NOCONTROLLER;
     }
     $this->value = array('module' => implode('/', $modulePath), 'controller' => $moduleController, 'action' => $moduleAction);
     if ($format !== '') {
         $this->value['format'] = $format;
     }
     return self::MATCHRESULT_FOUND;
 }
 /**
  * Notify SSO servers about the logged out client
  *
  * All active authentication tokens of type SingleSignOnToken will be
  * used to get the registered global session id and send a request
  * to the session service on the SSO server.
  *
  * @return void
  */
 public function logout()
 {
     $allConfiguration = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow');
     $tokens = $this->securityContext->getAuthenticationTokensOfType('Flowpack\\SingleSignOn\\Client\\Security\\SingleSignOnToken');
     foreach ($tokens as $token) {
         $providerName = $token->getAuthenticationProviderName();
         $serverIdentifier = \TYPO3\Flow\Utility\Arrays::getValueByPath($allConfiguration, 'security.authentication.providers.' . $providerName . '.providerOptions.server');
         if ($serverIdentifier !== NULL) {
             $ssoClient = $this->ssoClientFactory->create();
             $ssoServer = $this->ssoServerFactory->create($serverIdentifier);
             $ssoServer->destroySession($ssoClient, $token->getGlobalSessionId());
         }
     }
 }
 /**
  * @return void
  */
 protected function initializeAction()
 {
     $this->parentNode = $this->widgetConfiguration['parentNode'];
     $this->nodes = $this->widgetConfiguration['nodes'];
     $this->nodeTypeFilter = $this->widgetConfiguration['nodeTypeFilter'] ?: null;
     $this->configuration = Arrays::arrayMergeRecursiveOverrule($this->configuration, $this->widgetConfiguration['configuration'], true);
     $this->maximumNumberOfNodes = $this->configuration['maximumNumberOfNodes'];
     $numberOfNodes = $this->parentNode === null ? count($this->nodes) : $this->parentNode->getNumberOfChildNodes($this->nodeTypeFilter);
     if ($this->maximumNumberOfNodes > 0 && $numberOfNodes > $this->maximumNumberOfNodes) {
         $numberOfNodes = $this->maximumNumberOfNodes;
     }
     $this->numberOfPages = ceil($numberOfNodes / (int) $this->configuration['itemsPerPage']);
     $this->maximumNumberOfLinks = (int) $this->configuration['maximumNumberOfLinks'];
 }
 /**
  * Convert (and optionally filter) code coverage data generated by functional tests,
  * such that file references inside point not to the code cache inside Data/Temporary/....,
  * but to the Classes/ directory of the packages.
  *
  * <b>Example Usage:</b>
  * phpunit -c Build/BuildEssentials/FunctionalTests.xml --coverage-php Build/Reports/RawFunctionalTestCoverageReport.php
  * ./flow codeCoverage:convert Build/Reports/RawFunctionalTestCoverageReport.php Build/Reports/FunctionalTestCoverageReport.php --packages 'Your.Packages,Separated.By.Comma'
  *
  * The "--packages" argument is optional; but using it results in a huge speed boost;
  * as only the classes from the specified packages are included in the coverage result.
  *
  * @param string $codeCoverageFile Path to the code coverage file generated with "--coverage-php" of phpunit.
  * @param string $outFile Path to the converted code coverage file
  * @param string $packages The comma-separated list of packages to filter for. These packages must be installed here.
  * @param string $context The Flow context which has been used during the functional test run. Only needs to be modified if tests are ran in a special context.
  */
 public function convertCommand($codeCoverageFile, $outFile, $packages = '*', $context = 'Testing')
 {
     // Load $packages which should be taken into account while conversion
     $packageKeys = $packages;
     if ($packageKeys === '*') {
         $packages = $this->packageManager->getActivePackages();
     } else {
         $packages = array();
         foreach (\TYPO3\Flow\Utility\Arrays::trimExplode(',', $packageKeys) as $packageKey) {
             $packages[] = $this->packageManager->getPackage($packageKey);
         }
     }
     // For all $packages which should be used, build up a "cache-file-name" -> "real-file-name" mapping.
     $reverseIndexOfCacheFileNamesToClassFiles = array();
     foreach ($packages as $package) {
         /* @var $package \TYPO3\Flow\Package\PackageInterface */
         foreach ($package->getClassFiles() as $className => $fileName) {
             $cacheFileName = str_replace('\\', '_', $className);
             $reverseIndexOfCacheFileNamesToClassFiles[$cacheFileName] = $package->getPackagePath() . $fileName;
         }
     }
     // Modify the coverage report
     /* @var $coverage \Php_CodeCoverage */
     $coverage = unserialize(file_get_contents($codeCoverageFile));
     $coverageData = $coverage->getData();
     $baseDirectoryLength = strlen(FLOW_PATH_ROOT . 'Data/Temporary/' . $context . '/Cache/Code/Flow_Object_Classes/');
     $adjustedCoverageData = array();
     foreach ($coverageData as $fullCacheFileName => $coverageDataForFile) {
         $shortCacheFileName = substr($fullCacheFileName, $baseDirectoryLength, -4);
         if (isset($reverseIndexOfCacheFileNamesToClassFiles[$shortCacheFileName])) {
             $classFileInPackage = $reverseIndexOfCacheFileNamesToClassFiles[$shortCacheFileName];
             $numberOfLinesOfFile = count(file($classFileInPackage));
             if (isset($adjustedCoverageData[$classFileInPackage])) {
                 throw new \Sandstorm\Fuzzer\Exception('Coverage data already found for class file "' . $classFileInPackage . '". This should never happen; so we do not override it. It is probably a bug in Fuzzer.', 1367238729);
             }
             $adjustedCoverageData[$classFileInPackage] = array();
             foreach ($coverageDataForFile as $lineNumber => $coveredBy) {
                 if ($lineNumber <= $numberOfLinesOfFile) {
                     $adjustedCoverageData[$classFileInPackage][$lineNumber] = $coveredBy;
                 }
             }
         }
     }
     // Save the new coverage report
     $adjustedCoverage = new PhpunitCodeCoverage();
     $adjustedCoverage->setData($adjustedCoverageData);
     $adjustedCoverage->setTests($coverage->getTests());
     file_put_contents($outFile, serialize($adjustedCoverage));
 }
 /**
  * @param mixed $includeFields
  */
 public function setIncludeFields($includeFields)
 {
     if (is_array($includeFields)) {
         $includeFields = join(',', $includeFields);
     }
     $this->includeFields = array();
     if (is_string($includeFields)) {
         foreach (Arrays::trimExplode(',', $includeFields) as $includeField) {
             if (!$includeField) {
                 continue;
             }
             $this->includeFields[$includeField] = $includeField;
         }
     }
 }
 /**
  * Update global Piwik settings
  *
  * @param array $piwik
  * @return void
  */
 public function updateAction(array $piwik)
 {
     $configurationPath = $this->packageManager->getPackage('Portachtzig.Neos.Piwik')->getConfigurationPath();
     $settings = $this->configurationSource->load($configurationPath . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
     $piwik['host'] = preg_replace("(^https?://)", "", $piwik['host']);
     $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.host', $piwik['host']);
     $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.protocol', $piwik['protocol']);
     $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.token_auth', $piwik['token_auth']);
     if (array_key_exists('idSite', $piwik)) {
         $settings = Arrays::setValueByPath($settings, 'Portachtzig.Neos.Piwik.idSite', $piwik['idSite']);
     }
     $this->configurationSource->save($configurationPath . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $settings);
     $this->configurationManager->flushConfigurationCache();
     $this->redirect('index');
 }
Example #24
0
 /**
  * @param mixed $sparseFields
  */
 public function setSparseFields($sparseFields)
 {
     if (is_array($sparseFields)) {
         $sparseFields = join(',', $sparseFields);
     }
     $this->sparseFields = array();
     if (is_string($sparseFields)) {
         foreach (Arrays::trimExplode(',', $sparseFields) as $sparseField) {
             if (!$sparseField) {
                 continue;
             }
             $this->sparseFields[$sparseField] = $sparseField;
         }
     }
 }
 /**
  * @param JobConfigurationInterface $jobConfiguration
  * @param string $persistenceIdentifier the persistence identifier for the form.
  * @param string $factoryClass The fully qualified class name of the factory (which has to implement \TYPO3\Form\Factory\FormFactoryInterface)
  * @param string $presetName name of the preset to use
  * @param array $overrideConfiguration factory specific configuration
  * @return string the rendered form
  */
 public function render(JobConfigurationInterface $jobConfiguration, $persistenceIdentifier = null, $factoryClass = 'TYPO3\\Form\\Factory\\ArrayFormFactory', $presetName = 'default', array $overrideConfiguration = [])
 {
     if (isset($persistenceIdentifier)) {
         $overrideConfiguration = Arrays::arrayMergeRecursiveOverrule($this->formPersistenceManager->load($persistenceIdentifier), $overrideConfiguration);
     }
     $factory = $this->objectManager->get($factoryClass);
     /** @var FormDefinition $formDefinition */
     $formDefinition = $factory->build($overrideConfiguration, $presetName);
     ObjectAccess::setProperty($formDefinition, 'identifier', 'options', true);
     $this->postProcessFormDefinition($jobConfiguration, $formDefinition);
     $response = new Response($this->controllerContext->getResponse());
     $form = $formDefinition->bind($this->controllerContext->getRequest(), $response);
     $form->getRequest()->setArgumentNamespace('--options');
     return $form->render();
 }
Example #26
0
 public function compileSchema()
 {
     $schema = (array) $this->configurationManager->getConfiguration('Expose', $this->className);
     SettingsValidator::validate($schema, $this->supportedClassSettings);
     if (isset($schema['properties'])) {
         foreach ($schema['properties'] as $propertyName => $propertySettings) {
             SettingsValidator::validate($propertySettings, $this->supportedPropertySettings);
         }
     }
     $arrayKeys = array('listProperties', 'searchProperties', 'filterProperties');
     foreach ($arrayKeys as $key) {
         if (isset($schema[$key]) && is_string($schema[$key])) {
             $schema[$key] = Arrays::trimExplode(',', $schema[$key]);
         }
     }
     return $schema;
 }
 /**
  * @param array $module
  * @return mixed
  */
 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->securityContext->getPartyByType('TYPO3\\Neos\\Domain\\Model\\User');
         $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));
     }
 }
 /**
  * Create follow up issue to given issue
  *
  * @param array $issue
  */
 public function createAction($issue)
 {
     $redmineClient = new Redmine\Client($this->settings['Redmine']['url'], $this->settings['Redmine']['apiKey']);
     $id = $issue['related_id'];
     unset($issue['related_id']);
     $params = $issue;
     // get additional issue data and assign to new issue
     $res = $redmineClient->api('issue')->show($id);
     $params['project_id'] = Arrays::getValueByPath($res, 'issue.project.id');
     $params['category_id'] = Arrays::getValueByPath($res, 'issue.category.id');
     $newIssue = $redmineClient->api('issue')->create($params);
     // create relation
     $relation['issue_to_id'] = $id;
     $relation['relation_type'] = self::RELATION_TYPE;
     $json = json_encode(array('relation' => $relation));
     $redmineClient->post('/issues/' . (string) $newIssue->id . '/relations.json', $json);
     $this->view->assign('value', json_decode(json_encode((array) $newIssue), 1));
 }
 /**
  * Merges the TYPO3.Ice settings with the current settings before calling the render() method
  *
  * @return string
  */
 public function initializeArgumentsAndRender()
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Ice');
     if ($this->controllerContext->getRequest()->getControllerPackageKey() !== 'TYPO3.Ice') {
         $packageSettings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->controllerContext->getRequest()->getControllerPackageKey());
         if (!empty($packageSettings['extendIceSettings'])) {
             $settings = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($settings, $packageSettings);
         } else {
             $settings = $packageSettings;
         }
     }
     if (isset($settings['projectElementTypes'])) {
         $supertypeResolver = new \TYPO3\Ice\Utility\SupertypeResolver($settings['projectElementTypes']);
         $settings['projectElementTypes'] = $supertypeResolver->getCompleteMergedTypeDefinition(TRUE);
     }
     $this->settings = $settings;
     return parent::initializeArgumentsAndRender();
 }
 /**
  *
  * @param string $objectName
  * @param array $overrideProperties
  * @param boolean $addObjectToPersistence
  * @return object
  */
 public function buildObject($objectName, $overrideProperties = array(), $addObjectToPersistence = FALSE)
 {
     if (!isset($this->fixtureDefinitions[$objectName])) {
         throw new \Exception('Object name ' . $objectName . ' not configured in fixture definitions');
     }
     $properties = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->fixtureDefinitions[$objectName], $overrideProperties);
     $className = isset($properties['__type']) ? $properties['__type'] : $this->baseType;
     unset($properties['__type']);
     $object = new $className();
     foreach ($properties as $propertyName => $propertyValue) {
         if (\TYPO3\Flow\Reflection\ObjectAccess::isPropertySettable($object, $propertyName)) {
             \TYPO3\Flow\Reflection\ObjectAccess::setProperty($object, $propertyName, $propertyValue);
         }
     }
     $this->setCustomProperties($object, $properties, $addObjectToPersistence);
     if ($addObjectToPersistence) {
         $this->addObjectToPersistence($object);
     }
     return $object;
 }