/**
  */
 public function setUp()
 {
     ComposerUtility::flushCaches();
     vfsStream::setup('Packages');
     $this->mockPackageManager = $this->getMockBuilder(\TYPO3\Flow\Package\PackageManager::class)->disableOriginalConstructor()->getMock();
     ObjectAccess::setProperty($this->mockPackageManager, 'composerManifestData', array(), true);
 }
 /**
  * @return void
  */
 public function up()
 {
     $affectedViewHelperClassNames = array();
     $allPathsAndFilenames = Files::readDirectoryRecursively($this->targetPackageData['path'], '.php', TRUE);
     foreach ($allPathsAndFilenames as $pathAndFilename) {
         if (substr($pathAndFilename, -14) !== 'ViewHelper.php') {
             continue;
         }
         $fileContents = file_get_contents($pathAndFilename);
         $className = (new PhpAnalyzer($fileContents))->extractFullyQualifiedClassName();
         if ($className === NULL) {
             $this->showWarning(sprintf('could not extract class name from file "%s"', $pathAndFilename));
             continue;
         }
         /** @noinspection PhpIncludeInspection */
         require_once $pathAndFilename;
         if (!class_exists($className)) {
             $this->showWarning(sprintf('could not load class "%s" extracted from file "%s"', $className, $pathAndFilename));
             continue;
         }
         $instance = new $className();
         $escapeOutput = ObjectAccess::getProperty($instance, 'escapeOutput', TRUE);
         if ($escapeOutput !== NULL) {
             continue;
         }
         $affectedViewHelperClassNames[] = $className;
         $this->searchAndReplaceRegex('/\\R\\s*class[^\\{]+\\R?\\{(\\s*)(?=.*?\\})/s', '$0' . "\n\t" . '/**' . "\n\t" . ' * NOTE: This property has been introduced via code migration to ensure backwards-compatibility.' . "\n\t" . ' * @see AbstractViewHelper::isOutputEscapingEnabled()' . "\n\t" . ' * @var boolean' . "\n\t" . ' */' . "\n\t" . 'protected $escapeOutput = FALSE;$1', $pathAndFilename);
     }
     if ($affectedViewHelperClassNames !== array()) {
         $this->showWarning('Added "escapeOutput" property to following ViewHelpers:' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', $affectedViewHelperClassNames) . PHP_EOL . PHP_EOL . 'If an affected ViewHelper does not render HTML output, you should set this property TRUE in order to ensure sanitization of the output!');
     }
     $this->addWarningsForAffectedViewHelpers($this->targetPackageData['path']);
 }
Ejemplo n.º 3
0
 /**
  * Mocks an entity as wished
  * 
  * @param  string  $fqcn             the fully qualified class name
  * @param  boolean $persist          if the entity should be directly persisted or not
  * @param  array   $customProperties the properties to set if wished
  * @return Object
  */
 public function create($fqcn, $persist = false, $customProperties = array())
 {
     $entityConfiguration = $this->entityConfiguration[$fqcn];
     $this->validateEntityConfiguration($fqcn, $entityConfiguration);
     // create from reflection class if constructor needs arguments
     if (!empty($entityConfiguration['constructorArguments'])) {
         $reflector = new \ReflectionClass($fqcn);
         $constructorArguments = $this->getValuesFromConfigurations($entityConfiguration['constructorArguments']);
         $entity = $reflector->newInstanceArgs($constructorArguments);
     } else {
         $entity = new $fqcn();
     }
     // set the properties
     $configuredProperties = $entityConfiguration['properties'] ?: array();
     $properties = array_merge($configuredProperties, $customProperties);
     foreach ($this->getValuesFromConfigurations($properties, $persist) as $propertyName => $propertyValue) {
         $propertyCouldBeSet = ObjectAccess::setProperty($entity, $propertyName, $propertyValue);
         if (!$propertyCouldBeSet) {
             throw new \Exception($fqcn . '::$' . $propertyName . ' could not be set to ' . print_r($propertyValue, true), 1416481470);
         }
     }
     // persist if wished
     if ($persist && is_string($entityConfiguration['repository'])) {
         $this->objectManager->get($entityConfiguration['repository'])->add($entity);
         // flush this entity here...
         $this->entityManager->flush($entity);
         // add to managed entities
         $identifier = $this->persistenceManager->getIdentifierByObject($entity);
         $this->managedEntities[$identifier] = $entity;
     }
     return $entity;
 }
Ejemplo n.º 4
0
 public function assertPersistedPropertyValue($entity, $propertyName, $expectedPropertyValue, $forceDirectAccess = true)
 {
     $this->entityManager->refresh($entity);
     $persistedPropertyValue = ObjectAccess::getProperty($entity, $propertyName, $forceDirectAccess);
     $this->test->assertSame($expectedPropertyValue, $persistedPropertyValue, 'The property ' . $propertyName . ' did not have the expected persistent value');
     return $this;
 }
 /**
  * See the configuration in Testing/Objects.yaml
  * @test
  */
 public function configuredObjectDWillGetAssignedObjectFWithCorrectlyConfiguredConstructorValue()
 {
     $instance = $this->objectManager->get(\TYPO3\Flow\Tests\Functional\Object\Fixtures\PrototypeClassD::class);
     /** @var $instanceE Fixtures\PrototypeClassE */
     $instanceE = ObjectAccess::getProperty($instance, 'objectE', TRUE);
     $this->assertEquals('The constructor set value', $instanceE->getNullValue());
 }
 /**
  * @param string $term
  * @return string
  */
 public function autocompleteAction($term)
 {
     $searchProperty = $this->widgetConfiguration['searchProperty'];
     /** @var $queryResult QueryResultInterface */
     $queryResult = $this->widgetConfiguration['objects'];
     $query = clone $queryResult->getQuery();
     $constraint = $query->getConstraint();
     if ($constraint !== NULL) {
         $query->matching($query->logicalAnd($constraint, $query->like($searchProperty, '%' . $term . '%', FALSE)));
     } else {
         $query->matching($query->like($searchProperty, '%' . $term . '%', FALSE));
     }
     if (isset($this->configuration['limit'])) {
         $query->setLimit((int) $this->configuration['limit']);
     }
     $results = $query->execute();
     $output = array();
     $values = array();
     foreach ($results as $singleResult) {
         $val = ObjectAccess::getPropertyPath($singleResult, $searchProperty);
         if (isset($values[$val])) {
             continue;
         }
         $values[$val] = TRUE;
         $output[] = array('id' => $val, 'label' => $val, 'value' => $val);
     }
     return json_encode($output);
 }
 /**
  *
  */
 public function setUp()
 {
     $this->queueManager = new QueueManager();
     $this->queueManager->injectSettings(array('queues' => array('TestQueue' => array('className' => 'TYPO3\\Jobqueue\\Common\\Tests\\Unit\\Fixtures\\TestQueue'))));
     $this->jobManager = new JobManager();
     ObjectAccess::setProperty($this->jobManager, 'queueManager', $this->queueManager, true);
 }
Ejemplo n.º 8
0
 /**
  * Log a message if a post is deleted
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint
  * @Flow\Around("method(TYPO3\Neos\View\TypoScriptView->render())")
  * @return void
  */
 public function replacePlaceholdersIfNecessary(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
 {
     $result = $joinPoint->getAdviceChain()->proceed($joinPoint);
     /* @var $typoScriptView TypoScriptView */
     $typoScriptView = $joinPoint->getProxy();
     $viewVariables = ObjectAccess::getProperty($typoScriptView, 'variables', TRUE);
     if (!isset($viewVariables['value']) || !$viewVariables['value']->getNodeType()->isOfType('Sandstorm.Newsletter:Newsletter')) {
         // No newsletter, so logic does not apply
         return $result;
     }
     /* @var $httpRequest Request */
     $httpRequest = $this->controllerContext->getRequest()->getHttpRequest();
     $arguments = $httpRequest->getUri()->getArguments();
     if (!isset($arguments['hmac'])) {
         if ($this->securityContext->isInitialized() && $this->securityContext->hasRole('TYPO3.Neos:Editor')) {
             // Logged into backend, so we don't need to do anything.
             return $result;
         } else {
             // No HMAC sent -- so we return the email INCLUDING placeholders (as per customer's request)
             return $result;
             //return '<h1>Error: HMAC not included in the link.</h1>';
         }
     }
     $actualHmac = $arguments['hmac'];
     $uriWithoutHmac = str_replace('&hmac=' . $actualHmac, '', (string) $httpRequest->getUri());
     $expectedHmac = hash_hmac('sha1', urldecode($uriWithoutHmac), $this->hmacUrlSecret);
     if ($expectedHmac !== $actualHmac) {
         return '<h1>Error: Wrong link clicked.</h1>Please contact your administrator for help';
     }
     $result = preg_replace_callback(ReplacePlaceholdersInLiveImplementation::PLACEHOLDER_REGEX, function ($element) use($arguments) {
         return ObjectAccess::getPropertyPath($arguments, $element[1]);
     }, $result);
     return $result;
 }
 /**
  * @test
  */
 public function convertFromUsesAppropriatePropertyPopulationMethodsInOrderConstructorSetterPublic()
 {
     $convertedObject = $this->converter->convertFrom('irrelevant', \TYPO3\Flow\Tests\Functional\Property\Fixtures\TestClass::class, array('propertyMeantForConstructorUsage' => 'theValue', 'propertyMeantForSetterUsage' => 'theValue', 'propertyMeantForPublicUsage' => 'theValue'), new PropertyMappingConfiguration());
     $this->assertEquals('theValue set via Constructor', ObjectAccess::getProperty($convertedObject, 'propertyMeantForConstructorUsage', true));
     $this->assertEquals('theValue set via Setter', ObjectAccess::getProperty($convertedObject, 'propertyMeantForSetterUsage', true));
     $this->assertEquals('theValue', ObjectAccess::getProperty($convertedObject, 'propertyMeantForPublicUsage', true));
 }
 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
         if (isset($propertyConfiguration['type']) && in_array(trim($propertyConfiguration['type']), $this->getHandledObjectTypes())) {
             if (!isset($nodeProperties)) {
                 $nodeRecordQuery = $this->entityManager->getConnection()->prepare('SELECT properties FROM typo3_typo3cr_domain_model_nodedata WHERE persistence_object_identifier=?');
                 $nodeRecordQuery->execute([$this->persistenceManager->getIdentifierByObject($node)]);
                 $nodeRecord = $nodeRecordQuery->fetch(\PDO::FETCH_ASSOC);
                 $nodeProperties = unserialize($nodeRecord['properties']);
             }
             if (!isset($nodeProperties[$propertyName]) || !is_object($nodeProperties[$propertyName])) {
                 continue;
             }
             /** @var Asset $assetObject */
             $assetObject = $nodeProperties[$propertyName];
             $nodeProperties[$propertyName] = null;
             $stream = $assetObject->getResource()->getStream();
             if ($stream === false) {
                 continue;
             }
             fclose($stream);
             $objectType = TypeHandling::getTypeForValue($assetObject);
             $objectIdentifier = ObjectAccess::getProperty($assetObject, 'Persistence_Object_Identifier', true);
             $nodeProperties[$propertyName] = array('__flow_object_type' => $objectType, '__identifier' => $objectIdentifier);
         }
     }
     if (isset($nodeProperties)) {
         $nodeUpdateQuery = $this->entityManager->getConnection()->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET properties=? WHERE persistence_object_identifier=?');
         $nodeUpdateQuery->execute([serialize($nodeProperties), $this->persistenceManager->getIdentifierByObject($node)]);
     }
 }
 /**
  */
 public function setUp()
 {
     vfsStream::setup('Packages');
     $this->mockPackageManager = $this->getMockBuilder('TYPO3\\Flow\\Package\\PackageManager')->disableOriginalConstructor()->getMock();
     ObjectAccess::setProperty($this->mockPackageManager, 'composerManifestData', array(), TRUE);
     $this->packageFactory = new PackageFactory($this->mockPackageManager);
 }
Ejemplo n.º 12
0
 /**
  * @param string $type
  * @param array $bookableRequests
  * @return Registration\AbstractBookable[]
  */
 protected function requestBookable($type, $bookableRequests)
 {
     /** @var \T3DD\Backend\Domain\Repository\Registration\AbstractBookableRepository $repository */
     $repository = $this->{strtolower($type) . 'Repository'};
     $fractionBase = (int) isset($this->configuration[$type]['fractionBase']) ? $this->configuration[$type]['fractionBase'] : static::DEFAULT_FRACTION_BASE;
     $availableQuota = (int) isset($this->configuration[$type]['availableQuota']) ? $this->configuration[$type]['availableQuota'] * $fractionBase : 0;
     $spentQuota = $repository->getSpentQuota();
     $requestedBookables = [];
     foreach ($bookableRequests as $bookableRequest) {
         $requestFraction = round($fractionBase / $bookableRequest['divisor']);
         $quotaApplies = (bool) isset($bookableRequest['quotaApplies']) ? $bookableRequest['quotaApplies'] : TRUE;
         $className = 'T3DD\\Backend\\Domain\\Model\\Registration\\' . $type;
         $requestedBookable = new $className();
         $requestedBookable->setFraction($requestFraction);
         $requestedBookable->setQuotaApplies($quotaApplies);
         \TYPO3\Flow\Reflection\ObjectAccess::setProperty($bookableRequest['participant'], $type, $requestedBookable);
         if (!$quotaApplies) {
             $requestedBookable->setBookingState(Registration\AbstractBookable::BOOKING_STATE_PENDING);
         } else {
             $spentQuota += $requestFraction;
             if ($spentQuota > $availableQuota) {
                 $requestedBookable->setBookingState(Registration\AbstractBookable::BOOKING_STATE_WAITING);
             } else {
                 $requestedBookable->setBookingState(Registration\AbstractBookable::BOOKING_STATE_PENDING);
             }
         }
         $requestedBookables[] = $requestedBookable;
         $repository->add($requestedBookable);
     }
     return $requestedBookables;
 }
 /**
  * @Flow\Before("method(TYPO3\Neos\Controller\Backend\ContentController->uploadAssetAction())")
  * @param JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function rewriteSiteAssetCollection(JoinPointInterface $joinPoint)
 {
     if ($this->lookupNodeFilter === NULL || $this->lookupPropertyName === NULL) {
         return;
     }
     /** @var ContentController $contentController */
     $contentController = $joinPoint->getProxy();
     /** @var ActionRequest $actionRequest */
     $actionRequest = ObjectAccess::getProperty($contentController, 'request', TRUE);
     $nodeContextPath = $actionRequest->getInternalArgument('__node');
     if ($nodeContextPath === NULL) {
         return;
     }
     $node = $this->propertyMapper->convert($nodeContextPath, NodeInterface::class);
     $flowQuery = new FlowQuery(array($node));
     /** @var NodeInterface $documentNode */
     $documentNode = $flowQuery->closest($this->lookupNodeFilter)->get(0);
     if (!$documentNode->hasProperty($this->lookupPropertyName)) {
         return;
     }
     /** @var AssetCollection $assetCollection */
     $assetCollection = $this->assetCollectionRepository->findByIdentifier($documentNode->getProperty($this->lookupPropertyName));
     if ($assetCollection === NULL) {
         return;
     }
     /** @var Asset $asset */
     $asset = $joinPoint->getMethodArgument('asset');
     $assetCollection->addAsset($asset);
     $this->assetCollectionRepository->update($assetCollection);
 }
 public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
 {
     // 1. Make Gedmo\Translatable\Entity\Translation known to Doctrine, so that it can participate in Database Schema Generation
     //
     // Internally, we use a MappingDriverChain for that, which delegates almost all of its behavior to the already-existing
     // FlowAnnotationDriver. We additionally add the (default doctrine) Annotation Driver for the Gedmo namespace.
     //
     // Note: We replace FlowAnnotationDriver *on a very low level* with the *MappingDriverChain* object; because this class
     // is only used inside EntityManagerFactory -- so we know quite exactly what methods are called on that object.
     $bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'beforeInvokeStep', function ($step) use($bootstrap) {
         if ($step->getIdentifier() === 'typo3.flow:resources') {
             $flowAnnotationDriver = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver');
             $driverChain = new MappingDriverChainWithFlowAnnotationDriverAsDefault($flowAnnotationDriver);
             $driverChain->addDriver(new AnnotationDriver(ObjectAccess::getProperty($flowAnnotationDriver, 'reader', TRUE), FLOW_PATH_PACKAGES . 'Libraries/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity'), 'Gedmo');
             $bootstrap->getObjectManager()->setInstance('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver', $driverChain);
         }
     });
     // 2. Work around a bug in TYPO3\Flow\Persistence\Doctrine\PersistenceManager::onFlush which expects that all objects in the
     //    Doctrine subsystem are entities known to Flow.
     //
     // The line $this->reflectionService->getClassSchema($entity)->getModelType() triggers a fatal error, for get_class($entity) == 'Gedmo\Translatable\Entity\Translation'
     // because this class is known only to Doctrine (see 1. above), but not to the Flow reflection service.
     //
     // As a workaround, we just add an empty placeholder class schema to the Class Schemata cache, right before the class schema is saved
     // inside the TYPO3\Flow\Core\Bootstrap::bootstrapShuttingDown signal (which is fired directly after "finishedCompiletimeRun").
     $bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Bootstrap', 'finishedCompiletimeRun', function () use($bootstrap) {
         $classSchemataCache = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Reflection_RuntimeClassSchemata');
         if (!$classSchemataCache->has('Gedmo_Translatable_Entity_Translation')) {
             $classSchemataCache->set('Gedmo_Translatable_Entity_Translation', new ClassSchema('Gedmo\\Translatable\\Entity\\Translation'));
         }
     });
 }
 /**
  * Add DQL function
  *
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @Flow\Before("method(TYPO3\Flow\Persistence\Doctrine\Service->runDql())")
  * @return void
  */
 public function addDqlFunction(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
 {
     $entityManager = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($joinPoint->getProxy(), 'entityManager', TRUE);
     $configuration = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($entityManager, 'config', TRUE);
     $configuration->addCustomStringFunction('DAY', 'Lelesys\\Plugin\\News\\Doctrine\\Query\\Mysql\\Day');
     $configuration->addCustomStringFunction('MONTH', 'Lelesys\\Plugin\\News\\Doctrine\\Query\\Mysql\\Month');
     $configuration->addCustomStringFunction('YEAR', 'Lelesys\\Plugin\\News\\Doctrine\\Query\\Mysql\\Year');
 }
 /**
  * The input is assumed to be an array or Collection of objects. Groups this input by the $groupingKey property of each element.
  *
  * @param array|Collection $set
  * @param string $groupingKey
  * @return array
  */
 public function groupBy($set, $groupingKey)
 {
     $result = array();
     foreach ($set as $element) {
         $result[ObjectAccess::getPropertyPath($element, $groupingKey)][] = $element;
     }
     return $result;
 }
 /**
  * @test
  */
 public function collectionValidatorIsValidEarlyReturnsOnUnitializedDoctrinePersistenceCollections()
 {
     $entityManager = $this->getMock(\Doctrine\ORM\EntityManager::class, array(), array(), '', false);
     $collection = new \Doctrine\Common\Collections\ArrayCollection(array());
     $persistentCollection = new \Doctrine\ORM\PersistentCollection($entityManager, '', $collection);
     \TYPO3\Flow\Reflection\ObjectAccess::setProperty($persistentCollection, 'initialized', false, true);
     $this->mockValidatorResolver->expects($this->never())->method('createValidator');
     $this->validator->validate($persistentCollection);
 }
 /**
  * @param JoinPointInterface $joinPoint
  * @return mixed Result of the target method
  * @Flow\Around("class(TYPO3\Flow\Cli\Request) && method(.*->getCommand())")
  */
 public function replaceCommandWithDomainCommand(JoinPointInterface $joinPoint)
 {
     /** @var Request $proxy */
     $proxy = $joinPoint->getProxy();
     if ($proxy->getControllerObjectName() === DomainCommandController::class) {
         ObjectAccess::setProperty($proxy, 'command', $this->buildDomainCommand($proxy->getControllerCommandName()), TRUE);
     }
     return $joinPoint->getAdviceChain()->proceed($joinPoint);
 }
Ejemplo n.º 19
0
 /**
  * @param string $propertyPath
  * @return string
  */
 public function render($propertyPath = 'party.name')
 {
     $tokens = $this->securityContext->getAuthenticationTokens();
     foreach ($tokens as $token) {
         if ($token->isAuthenticated()) {
             return (string) \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($token->getAccount(), $propertyPath);
         }
     }
     return '';
 }
Ejemplo n.º 20
0
 /**
  * Returns TRUE if the given node is of the node type this filter expects.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node
  * @return boolean
  */
 public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node)
 {
     if ($this->withSubTypes === TRUE) {
         return $this->nodeTypeManager->getNodeType($node->getNodeType())->isOfType($this->nodeTypeName);
     } else {
         $nodeData = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($node, 'nodeData', TRUE);
         $nodeType = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($nodeData, 'nodeType', TRUE);
         return $nodeType === $this->nodeTypeName;
     }
 }
Ejemplo n.º 21
0
 /**
  * @param array $row
  * @return object
  */
 public function hydrate(array $row)
 {
     $dto = $this->getNewDtoInstance();
     foreach ($row as $column => $value) {
         if (ObjectAccess::isPropertySettable($dto, $column)) {
             ObjectAccess::setProperty($dto, $column, $value);
         }
     }
     return $dto;
 }
Ejemplo n.º 22
0
 /**
  * @return void
  */
 public function up()
 {
     $this->processConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, function (array &$configuration) {
         $presetsConfiguration = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($configuration, 'TYPO3.Form.presets');
         if (!is_array($presetsConfiguration)) {
             return;
         }
         $presetsConfiguration = $this->renameTranslationPackage($presetsConfiguration);
         $configuration['TYPO3']['Form']['presets'] = $presetsConfiguration;
     }, true);
 }
 /**
  * Builds a transformation object from the given configuration.
  *
  * @param array $transformationConfiguration
  * @return \TYPO3\TYPO3CR\Migration\Transformations\TransformationInterface
  * @throws \TYPO3\TYPO3CR\Migration\Exception\MigrationException if a given setting is not supported
  */
 protected function buildTransformationObject($transformationConfiguration)
 {
     $transformationClassName = $this->resolveTransformationClassName($transformationConfiguration['type']);
     $transformation = new $transformationClassName();
     foreach ($transformationConfiguration['settings'] as $settingName => $settingValue) {
         if (!\TYPO3\Flow\Reflection\ObjectAccess::setProperty($transformation, $settingName, $settingValue)) {
             throw new \TYPO3\TYPO3CR\Migration\Exception\MigrationException('Cannot set setting "' . $settingName . '" on transformation "' . $transformationClassName . '" , check your configuration.', 1343293094);
         }
     }
     return $transformation;
 }
Ejemplo n.º 24
0
 /**
  * Advice for uncached segments when rendering from a cached version
  *
  * @Flow\AfterReturning("method(TYPO3\TypoScript\Core\Cache\RuntimeContentCache->evaluateUncached())")
  * @param JoinPointInterface $joinPoint
  */
 public function registerEvaluateUncached(JoinPointInterface $joinPoint)
 {
     $path = $joinPoint->getMethodArgument('path');
     $proxy = $joinPoint->getProxy();
     /** @var Runtime $runtime */
     $runtime = ObjectAccess::getProperty($proxy, 'runtime', TRUE);
     $mocVarnishIgnoreUncached = $runtime->evaluate($path . '/__meta/cache/mocVarnishIgnoreUncached');
     if ($mocVarnishIgnoreUncached !== TRUE) {
         $this->evaluatedUncached = TRUE;
     }
 }
Ejemplo n.º 25
0
 /**
  * @param array $options
  * @return void
  */
 public function addOptions(array $options)
 {
     foreach ($options as $key => $value) {
         $setterName = $setterName = ObjectAccess::buildSetterMethodName($key);
         if (method_exists($this, $setterName)) {
             $this->{$setterName}($value);
         } else {
             $this->setOption($key, $value);
         }
     }
 }
Ejemplo n.º 26
0
 /**
  * Finds ort as per entered search string
  *
  * @param string $searchString The entered search string
  * @return \TYPO3\Flow\Persistence\QueryResultInterface The ort
  */
 public function findOrtBySearchString($searchString)
 {
     $searchString = trim($searchString);
     $searchString = '%' . $searchString . '%';
     $query = $this->createQuery();
     /** @var $queryBuilder \Doctrine\ORM\QueryBuilder **/
     $queryBuilder = ObjectAccess::getProperty($query, 'queryBuilder', true);
     $queryBuilder->resetDQLParts()->select('ort')->from('\\Subugoe\\GermaniaSacra\\Domain\\Model\\Ort', 'ort')->innerJoin('ort.bistum', 'bistum')->where('ort.ort LIKE :ort')->orderBy('ort.ort', 'ASC');
     $queryBuilder->setParameter('ort', $searchString);
     return $query->execute();
 }
 /**
  * @Given /^I have the following policies:$/
  */
 public function iHaveTheFollowingPolicies($string)
 {
     self::$testingPolicyPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Policy.yaml';
     file_put_contents(self::$testingPolicyPathAndFilename, $string->getRaw());
     $configurationManager = $this->objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
     $configurations = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($configurationManager, 'configurations', TRUE);
     unset($configurations[\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_POLICY]);
     \TYPO3\Flow\Reflection\ObjectAccess::setProperty($configurationManager, 'configurations', $configurations, TRUE);
     $policyService = $this->objectManager->get('TYPO3\\Flow\\Security\\Policy\\PolicyService');
     \TYPO3\Flow\Reflection\ObjectAccess::setProperty($policyService, 'initialized', FALSE, TRUE);
 }
Ejemplo n.º 28
0
 /**
  * Updates the identifier credential from the GET/POST vars, if the GET/POST parameters
  * are available. Sets the authentication status to AUTHENTICATION_NEEDED, if credentials have been sent.
  *
  * Note: You need to send the password in this parameter:
  *       __authentication[_OurBrand_][Quiz][Security][IdentifierToken][identifier]
  *
  * @param \TYPO3\Flow\Mvc\ActionRequest $actionRequest The current action request
  * @return void
  */
 public function updateCredentials(\TYPO3\Flow\Mvc\ActionRequest $actionRequest)
 {
     $postArguments = $actionRequest->getInternalArguments();
     $username = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($postArguments, '__authentication._OurBrand_.Quiz.Security.IdentifierToken.username');
     $password = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($postArguments, '__authentication._OurBrand_.Quiz.Security.IdentifierToken.password');
     if (!empty($username) && !empty($password)) {
         $this->credentials['username'] = $username;
         $this->credentials['password'] = $password;
         $this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
     }
 }
 /**
  * @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));
 }
 /**
  * Returns contents of Composer manifest - or part there of.
  *
  * @param string $manifestPath
  * @param string $configurationPath Optional. Only return the part of the manifest indexed by configurationPath
  * @return array|mixed
  */
 public static function getComposerManifest($manifestPath, $configurationPath = null)
 {
     $composerManifest = static::readComposerManifest($manifestPath);
     if ($composerManifest === null) {
         return null;
     }
     if ($configurationPath !== null) {
         return ObjectAccess::getPropertyPath($composerManifest, $configurationPath);
     } else {
         return $composerManifest;
     }
 }