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


PHP Reflection\ObjectAccess类代码示例

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


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

示例1: render

 /**
  * Set (override) the variable in $name.
  *
  * @param string $name
  * @param mixed $value
  * @return void
  */
 public function render($name, $value = NULL)
 {
     if ($value === NULL) {
         $value = $this->renderChildren();
     }
     if (FALSE === strpos($name, '.')) {
         if ($this->templateVariableContainer->exists($name) === TRUE) {
             $this->templateVariableContainer->remove($name);
         }
         $this->templateVariableContainer->add($name, $value);
     } elseif (1 == substr_count($name, '.')) {
         $parts = explode('.', $name);
         $objectName = array_shift($parts);
         $path = implode('.', $parts);
         if (FALSE === $this->templateVariableContainer->exists($objectName)) {
             return NULL;
         }
         $object = $this->templateVariableContainer->get($objectName);
         try {
             \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($object, $path, $value);
             // Note: re-insert the variable to ensure unreferenced values like arrays also get updated
             $this->templateVariableContainer->remove($objectName);
             $this->templateVariableContainer->add($objectName, $object);
         } catch (\Exception $error) {
             return NULL;
         }
     }
     return NULL;
 }
开发者ID:olek07,项目名称:GiGaBonus,代码行数:36,代码来源:SetVariableViewHelper.php

示例2: isDirtyObject

 /**
  * Checks if object was changed or not
  *
  * @param object $object
  * @return bool
  */
 public static function isDirtyObject($object)
 {
     foreach (array_keys($object->_getProperties()) as $propertyName) {
         try {
             $property = ObjectAccess::getProperty($object, $propertyName);
         } catch (PropertyNotAccessibleException $e) {
             // if property can not be accessed
             continue;
         }
         /**
          * std::Property (string, int, etc..),
          * PHP-Objects (DateTime, RecursiveIterator, etc...),
          * TYPO3-Objects (user, page, etc...)
          */
         if (!$property instanceof ObjectStorage) {
             if ($object->_isDirty($propertyName)) {
                 return true;
             }
         } else {
             /**
              * ObjectStorage
              */
             if ($property->_isDirty()) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:olek07,项目名称:GiGaBonus,代码行数:35,代码来源:ObjectUtility.php

示例3: createsValidFieldInterfaceComponents

 /**
  * @test
  */
 public function createsValidFieldInterfaceComponents()
 {
     $instance = $this->buildViewHelperInstance($this->defaultArguments);
     $instance->render();
     $component = $instance->getComponent(ObjectAccess::getProperty($instance, 'renderingContext', TRUE), ObjectAccess::getProperty($instance, 'arguments', TRUE));
     $this->assertInstanceOf('FluidTYPO3\\Flux\\Form\\WizardInterface', $component);
 }
开发者ID:kersten,项目名称:flux,代码行数:10,代码来源:AbstractWizardViewHelperTestCase.php

示例4: getAnnotationValueFromClass

 /**
  * @param string $className
  * @param string $annotationName
  * @param string|boolean $propertyName
  * @return array|boolean
  */
 public static function getAnnotationValueFromClass($className, $annotationName, $propertyName = NULL)
 {
     $reflection = new ClassReflection($className);
     $sample = new $className();
     $annotations = array();
     if (NULL === $propertyName) {
         if (FALSE === $reflection->isTaggedWith($annotationName)) {
             return FALSE;
         }
         $annotations = $reflection->getTagValues($annotationName);
     } elseif (FALSE === $propertyName) {
         $properties = ObjectAccess::getGettablePropertyNames($sample);
         foreach ($properties as $reflectedPropertyName) {
             if (FALSE === property_exists($className, $reflectedPropertyName)) {
                 continue;
             }
             $propertyAnnotationValues = self::getPropertyAnnotations($reflection, $reflectedPropertyName, $annotationName);
             if (NULL !== $propertyAnnotationValues) {
                 $annotations[$reflectedPropertyName] = $propertyAnnotationValues;
             }
         }
     } else {
         $annotations = self::getPropertyAnnotations($reflection, $propertyName, $annotationName);
     }
     $annotations = self::parseAnnotation($annotations);
     return NULL !== $propertyName && TRUE === isset($annotations[$propertyName]) ? $annotations[$propertyName] : $annotations;
 }
开发者ID:busynoggin,项目名称:flux,代码行数:33,代码来源:AnnotationUtility.php

示例5: performControllerExcecution

 /**
  * @param ControllerPipe $instance
  * @param string $controllerClassName
  * @return mixed
  */
 protected function performControllerExcecution(ControllerPipe $instance, $controllerClassName)
 {
     $controllerMock = $this->getMockForAbstractClass('FluidTYPO3\\Flux\\Controller\\AbstractFluxController', array(), $controllerClassName, TRUE, TRUE, TRUE, array('renderAction', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'canProcessRequest', 'mapRequestArgumentsToControllerArguments', 'checkRequestHash', 'buildControllerContext', 'setViewConfiguration', 'resolveView'));
     $controllerMock->expects($this->once())->method('initializeActionMethodArguments');
     $controllerMock->expects($this->once())->method('initializeActionMethodValidators');
     $controllerMock->expects($this->once())->method('renderAction')->will($this->returnValue($this->defaultData));
     $controllerMock->expects($this->once())->method('canProcessRequest')->will($this->returnValue(TRUE));
     $signalSlotDispatcherMock = $this->getMock('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher', array('dispatch'));
     $configurationManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager', array('isFeatureEnabled'));
     $configurationManagerMock->expects($this->any())->method('isFeatureEnabled')->will($this->returnValue(TRUE));
     $propertyMappingServiceMock = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\MvcPropertyMappingConfigurationService', array('initializePropertyMappingConfigurationFromRequest'));
     $argumentsMock = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('getIterator'));
     $argumentsMock->expects($this->atLeastOnce())->method('getIterator')->will($this->returnValue(new \ArrayIterator(array(new Argument('test', 'string')))));
     ObjectAccess::setProperty($controllerMock, 'objectManager', $this->objectManager, TRUE);
     ObjectAccess::setProperty($controllerMock, 'configurationManager', $configurationManagerMock, TRUE);
     ObjectAccess::setProperty($controllerMock, 'mvcPropertyMappingConfigurationService', $propertyMappingServiceMock, TRUE);
     ObjectAccess::setProperty($controllerMock, 'arguments', $argumentsMock, TRUE);
     ObjectAccess::setProperty($controllerMock, 'signalSlotDispatcher', $signalSlotDispatcherMock, TRUE);
     $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
     $response = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response', array('getContent'));
     $response->expects($this->once())->method('getContent')->will($this->returnValue($this->defaultData));
     $request = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request', array('getControllerActionName', 'getMethodParameters', 'getDispatched'));
     $request->expects($this->at(0))->method('getDispatched')->will($this->returnValue(FALSE));
     $request->expects($this->atLeastOnce())->method('getControllerActionName')->will($this->returnValue('render'));
     $dispatcherMock = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher', array('resolveController'), array($objectManagerMock));
     ObjectAccess::setProperty($dispatcherMock, 'signalSlotDispatcher', $signalSlotDispatcherMock, TRUE);
     ObjectAccess::setProperty($dispatcherMock, 'objectManager', $this->objectManager, TRUE);
     $dispatcherMock->expects($this->once())->method('resolveController')->will($this->returnValue($controllerMock));
     $objectManagerMock->expects($this->at(0))->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request')->will($this->returnValue($request));
     $objectManagerMock->expects($this->at(1))->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->will($this->returnValue($response));
     $objectManagerMock->expects($this->at(2))->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher')->will($this->returnValue($dispatcherMock));
     ObjectAccess::setProperty($instance, 'objectManager', $objectManagerMock, TRUE);
     return $instance->conduct($this->defaultData);
 }
开发者ID:JostBaron,项目名称:flux,代码行数:39,代码来源:ControllerPipeTest.php

示例6: getStructure

 /**
  * @param \Iterator|\TYPO3\CMS\Extbase\DomainObject\AbstractEntity[] $iterator
  * @return array
  */
 protected function getStructure($iterator)
 {
     $structure = array();
     if (!$iterator instanceof \Iterator) {
         $iterator = array($iterator);
     }
     foreach ($iterator as $entity) {
         $dataMap = $this->dataMapFactory->buildDataMap(get_class($entity));
         $tableName = $dataMap->getTableName();
         $identifier = $tableName . ':' . $entity->getUid();
         $properties = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettableProperties($entity);
         $structureItem = array();
         foreach ($properties as $propertyName => $propertyValue) {
             $columnMap = $dataMap->getColumnMap($propertyName);
             if ($columnMap !== NULL) {
                 $propertyName = $columnMap->getColumnName();
             }
             if ($propertyValue instanceof \Iterator) {
                 $structureItem[$propertyName] = $this->getStructure($propertyValue);
             } else {
                 $structureItem[$propertyName] = $propertyValue;
             }
         }
         $structure[$identifier] = $structureItem;
     }
     return $structure;
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:31,代码来源:BlogController.php

示例7: render

 /**
  * @return mixed
  */
 public function render()
 {
     $nodes = array();
     foreach ($this->childViewHelperNodes as $viewHelperNode) {
         $viewHelper = $viewHelperNode->getUninitializedViewHelper();
         $arguments = $viewHelper->prepareArguments();
         $givenArguments = $viewHelperNode->getArguments();
         $viewHelperReflection = new \ReflectionClass($viewHelper);
         $viewHelperDescription = $viewHelperReflection->getDocComment();
         $viewHelperDescription = htmlentities($viewHelperDescription);
         $viewHelperDescription = '[CLASS DOC]' . LF . $viewHelperDescription . LF;
         $renderMethodDescription = $viewHelperReflection->getMethod('render')->getDocComment();
         $renderMethodDescription = htmlentities($renderMethodDescription);
         $renderMethodDescription = implode(LF, array_map('trim', explode(LF, $renderMethodDescription)));
         $renderMethodDescription = '[RENDER METHOD DOC]' . LF . $renderMethodDescription . LF;
         $argumentDefinitions = array();
         foreach ($arguments as &$argument) {
             $name = $argument->getName();
             $argumentDefinitions[$name] = ObjectAccess::getGettableProperties($argument);
         }
         $sections = array($viewHelperDescription, DebuggerUtility::var_dump($argumentDefinitions, '[ARGUMENTS]', 4, TRUE, FALSE, TRUE), DebuggerUtility::var_dump($givenArguments, '[CURRENT ARGUMENTS]', 4, TRUE, FALSE, TRUE), $renderMethodDescription);
         array_push($nodes, implode(LF, $sections));
     }
     return '<pre>' . implode(LF . LF, $nodes) . '</pre>';
 }
开发者ID:chrmue01,项目名称:typo3-starter-kit,代码行数:28,代码来源:DebugViewHelper.php

示例8: render

 /**
  * @param string $propertyName
  * @param mixed $object
  * @return mixed
  */
 public function render($propertyName, $subject = NULL)
 {
     if ($subject === NULL) {
         $subject = $this->renderChildren();
     }
     return \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyPath($subject, $propertyName);
 }
开发者ID:plobacher,项目名称:extbasebookexample,代码行数:12,代码来源:PropertyViewHelper.php

示例9: process

 /**
  * Processing the focus point crop (fallback to LocalCropScaleMaskHelper)
  *
  * @param TaskInterface $task
  *
  * @return array|NULL
  */
 public function process(TaskInterface $task)
 {
     $configuration = $task->getConfiguration();
     $crop = $configuration['crop'] ? json_decode($configuration['crop']) : null;
     if ($crop instanceof \stdClass && isset($crop->x)) {
         // if crop is enable release the process
         return parent::process($task);
     }
     $sourceFile = $task->getSourceFile();
     try {
         if (self::$deepCheck === false) {
             self::$deepCheck = true;
             $ratio = $this->getCurrentRatioConfiguration();
             $this->dimensionService->getRatio($ratio);
             $newFile = $this->focusCropService->getCroppedImageSrcByFile($sourceFile, $ratio);
             $file = ResourceFactory::getInstance()->retrieveFileOrFolderObject($newFile);
             $targetFile = $task->getTargetFile();
             ObjectAccess::setProperty($targetFile, 'originalFile', $file, true);
             ObjectAccess::setProperty($targetFile, 'originalFileSha1', $file->getSha1(), true);
             ObjectAccess::setProperty($targetFile, 'storage', $file->getStorage(), true);
             ObjectAccess::setProperty($task, 'sourceFile', $file, true);
             ObjectAccess::setProperty($task, 'targetFile', $targetFile, true);
         }
     } catch (\Exception $ex) {
     }
     self::$deepCheck = false;
     return parent::process($task);
 }
开发者ID:mcmz,项目名称:focuspoint,代码行数:35,代码来源:LocalCropScaleMaskHelper.php

示例10: throwsErrorWhenNoTidyIsInstalled

 /**
  * @test
  */
 public function throwsErrorWhenNoTidyIsInstalled()
 {
     $instance = $this->createInstance();
     ObjectAccess::setProperty($instance, 'hasTidy', FALSE, TRUE);
     $this->setExpectedException('RuntimeException', NULL, 1352059753);
     $instance->render('test', 'utf8');
 }
开发者ID:smichaelsen,项目名称:vhs,代码行数:10,代码来源:TidyViewHelperTest.php

示例11: supportsForeignMatchFields

 /**
  * @test
  */
 public function supportsForeignMatchFields()
 {
     $arguments = array('name' => 'test', 'foreignMatchFields' => array('test' => 'test'));
     $instance = $this->buildViewHelperInstance($arguments, array());
     $component = $instance->getComponent(ObjectAccess::getProperty($instance, 'renderingContext', TRUE), ObjectAccess::getProperty($instance, 'arguments', TRUE));
     $this->assertEquals($arguments['foreignMatchFields'], $component->getForeignMatchFields());
 }
开发者ID:busynoggin,项目名称:flux,代码行数:10,代码来源:FalViewHelperTest.php

示例12: supportsUseOfControllerAndActionSeparator

 /**
  * @test
  */
 public function supportsUseOfControllerAndActionSeparator()
 {
     $arguments = array('label' => 'Test field', 'controllerExtensionName' => 'Flux', 'pluginName' => 'API', 'controllerName' => 'Flux', 'actions' => array(), 'disableLocalLanguageLabels' => FALSE, 'excludeActions' => array(), 'localLanguageFileRelativePath' => '/Resources/Private/Language/locallang_db.xml', 'prefixOnRequiredArguments' => '*', 'subActions' => array(), 'separator' => ' :: ');
     $instance = $this->buildViewHelperInstance($arguments, array(), NULL, $arguments['extensionName'], $arguments['pluginName']);
     $instance->initializeArgumentsAndRender();
     $component = $instance->getComponent(ObjectAccess::getProperty($instance, 'renderingContext', TRUE), ObjectAccess::getProperty($instance, 'arguments', TRUE));
     $this->assertSame($arguments['separator'], $component->getSeparator());
 }
开发者ID:fluidtypo3,项目名称:flux,代码行数:11,代码来源:ControllerActionsViewHelperTest.php

示例13: render

 /**
  * Get a Property from Field by given Marker and Form
  *
  * @param string $marker Field Marker
  * @param Form $form
  * @param string $property Field Property
  * @return string Property
  */
 public function render($marker, Form $form, $property)
 {
     $field = $this->fieldRepository->findByMarkerAndForm($marker, $form->getUid());
     if ($field !== null) {
         return ObjectAccess::getProperty($field, $property);
     }
     return '';
 }
开发者ID:VladStawizki,项目名称:ipl-logistik.de,代码行数:16,代码来源:GetFieldPropertyFromMarkerAndFormViewHelper.php

示例14: loadSettings

 /**
  * @param array $settings
  * @return void
  */
 public function loadSettings(array $settings)
 {
     foreach ($settings as $name => $value) {
         if (TRUE === property_exists($this, $name)) {
             ObjectAccess::setProperty($this, $name, $value);
         }
     }
 }
开发者ID:kersten,项目名称:flux,代码行数:12,代码来源:AbstractPipe.php

示例15: getOptions

 /**
  * Render the option tags.
  *
  * @param $optionOverride added by nnaddress
  * @return array an associative array of options, key will be the value of the option tag
  */
 protected function getOptions($optionOverride = NULL)
 {
     if (!$this->arguments['renderSubGroups']) {
         return parent::getOptions();
     }
     if (!is_array($this->arguments['options']) && !$this->arguments['options'] instanceof \Traversable) {
         return array();
     }
     $options = array();
     $optionsArgument = $optionOverride ? $optionOverride : $this->arguments['options'];
     foreach ($optionsArgument as $key => $value) {
         if (is_object($value)) {
             // Added by NN Address
             $childOptions = $this->getOptions($value->getChildGroups());
             if ($this->hasArgument('optionValueField')) {
                 $key = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyPath($value, $this->arguments['optionValueField']);
                 if (is_object($key)) {
                     if (method_exists($key, '__toString')) {
                         $key = (string) $key;
                     } else {
                         throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('Identifying value for object of class "' . get_class($value) . '" was an object.', 1247827428);
                     }
                 }
                 // TODO: use $this->persistenceManager->isNewObject() once it is implemented
             } elseif ($this->persistenceManager->getIdentifierByObject($value) !== NULL) {
                 $key = $this->persistenceManager->getIdentifierByObject($value);
             } elseif (method_exists($value, '__toString')) {
                 $key = (string) $value;
             } else {
                 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('No identifying value for object of class "' . get_class($value) . '" found.', 1247826696);
             }
             if ($this->hasArgument('optionLabelField')) {
                 $value = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyPath($value, $this->arguments['optionLabelField']);
                 if (is_object($value)) {
                     if (method_exists($value, '__toString')) {
                         $value = (string) $value;
                     } else {
                         throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('Label value for object of class "' . get_class($value) . '" was an object without a __toString() method.', 1247827553);
                     }
                 }
             } elseif (method_exists($value, '__toString')) {
                 $value = (string) $value;
                 // TODO: use $this->persistenceManager->isNewObject() once it is implemented
             } elseif ($this->persistenceManager->getIdentifierByObject($value) !== NULL) {
                 $value = $this->persistenceManager->getIdentifierByObject($value);
             }
         }
         $options[$key] = $value;
         // Added by NN Address
         if (sizeof($childOptions) > 0) {
             $options = $options + $childOptions;
         }
     }
     if ($this->arguments['sortByOptionLabel']) {
         asort($options, SORT_LOCALE_STRING);
     }
     return $options;
 }
开发者ID:Tricept,项目名称:nn_address,代码行数:64,代码来源:SelectViewHelper.php


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