当前位置: 首页>>代码示例>>PHP>>正文


PHP Reflection\ObjectAccess类代码示例

本文整理汇总了PHP中TYPO3\Flow\Reflection\ObjectAccess的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess类的具体用法?PHP ObjectAccess怎么用?PHP ObjectAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  */
 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);
 }
开发者ID:fcool,项目名称:flow-development-collection,代码行数:9,代码来源:PackageTest.php

示例2: up

 /**
  * @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']);
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:36,代码来源:Version20150214130800.php

示例3: create

 /**
  * 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;
 }
开发者ID:econic,项目名称:testing,代码行数:40,代码来源:EntityFactory.php

示例4: assertPersistedPropertyValue

 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;
 }
开发者ID:econic,项目名称:testing,代码行数:7,代码来源:PersistenceTester.php

示例5: configuredObjectDWillGetAssignedObjectFWithCorrectlyConfiguredConstructorValue

 /**
  * 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());
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:11,代码来源:ConfigurationTest.php

示例6: autocompleteAction

 /**
  * @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);
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:32,代码来源:AutocompleteController.php

示例7: setUp

 /**
  *
  */
 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);
 }
开发者ID:architectesch,项目名称:jobqueue-common,代码行数:10,代码来源:JobManagerTest.php

示例8: replacePlaceholdersIfNecessary

 /**
  * 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;
 }
开发者ID:sandstorm,项目名称:newsletter,代码行数:41,代码来源:TypoScriptViewAspect.php

示例9: convertFromUsesAppropriatePropertyPopulationMethodsInOrderConstructorSetterPublic

 /**
  * @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));
 }
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:10,代码来源:ObjectConverterTest.php

示例10: execute

 /**
  * 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)]);
     }
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:37,代码来源:AssetTransformation.php

示例11: setUp

 /**
  */
 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);
 }
开发者ID:sengkimlong,项目名称:Flow3-Authentification,代码行数:9,代码来源:PackageFactoryTest.php

示例12: requestBookable

 /**
  * @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;
 }
开发者ID:HofUniversityIWS,项目名称:backend,代码行数:36,代码来源:BookableService.php

示例13: rewriteSiteAssetCollection

 /**
  * @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);
 }
开发者ID:bwaidelich,项目名称:Wwwision.AssetConstraints,代码行数:35,代码来源:ContentControllerAspect.php

示例14: boot

 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'));
         }
     });
 }
开发者ID:sandstorm,项目名称:gedmotranslatableconnector,代码行数:32,代码来源:Package.php

示例15: addDqlFunction

 /**
  * 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');
 }
开发者ID:abedsujan,项目名称:Lelesys.Plugin.News,代码行数:15,代码来源:DqlFunctionAspect.php


注:本文中的TYPO3\Flow\Reflection\ObjectAccess类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。