本文整理汇总了PHP中TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::setProperty方法的具体用法?PHP ObjectAccess::setProperty怎么用?PHP ObjectAccess::setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Extbase\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::setProperty方法的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;
}
示例2: 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);
}
示例3: throwsErrorWhenNoTidyIsInstalled
/**
* @test
*/
public function throwsErrorWhenNoTidyIsInstalled()
{
$instance = $this->createInstance();
ObjectAccess::setProperty($instance, 'hasTidy', FALSE, TRUE);
$this->setExpectedException('RuntimeException', NULL, 1352059753);
$instance->render('test');
}
示例4: 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);
}
示例5: 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);
}
}
}
示例6: extend
/**
* Extends a given default ControllerContext.
*
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
* @return ControllerContext
*/
public static function extend(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $source)
{
$controllerContext = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(ControllerContext::class);
$propertyNames = ObjectAccess::getGettableProperties($source);
foreach ($propertyNames as $propertyName => $propertyValue) {
ObjectAccess::setProperty($controllerContext, $propertyName, $propertyValue);
}
return $controllerContext;
}
示例7: itemsAreAddedToContainer
/**
* @test
* @dataProvider linkedDataProvider
*/
public function itemsAreAddedToContainer($subject, $predicate, $object, $objectType, $language, $name, $expected)
{
$this->fixture->setArguments(['subject' => $subject, 'predicate' => $predicate, 'object' => $object, 'objectType' => $objectType, 'language' => $language, 'name' => $name]);
$this->templateVariableContainer->expects($this->once())->method('remove')->with($name);
$this->templateVariableContainer->expects($this->once())->method('add')->with($name)->will($this->returnValue(''));
ObjectAccess::setProperty($this->fixture, 'templateVariableContainer', $this->templateVariableContainer, true);
$this->fixture->render();
$this->markTestIncomplete('Todo');
}
示例8: getParsedTemplateReturnsCompiledTemplateIfFound
/**
* @test
*/
public function getParsedTemplateReturnsCompiledTemplateIfFound()
{
$instance = $this->getMock($this->createInstanceClassName(), array('getTemplateIdentifier'));
$instance->expects($this->once())->method('getTemplateIdentifier');
$compiler = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler', array('has', 'get'));
$compiler->expects($this->once())->method('has')->willReturn(TRUE);
$compiler->expects($this->once())->method('get')->willReturn('foobar');
ObjectAccess::setProperty($instance, 'templateCompiler', $compiler, TRUE);
$result = $this->callInaccessibleMethod($instance, 'getParsedTemplate');
$this->assertEquals('foobar', $result);
}
示例9: createAndTestDummyControllerInstance
/**
* @return AbstractFluxController
*/
protected function createAndTestDummyControllerInstance()
{
$record = Records::$contentRecordWithoutParentAndWithoutChildren;
$record['pi_flexform'] = Xml::SIMPLE_FLEXFORM_SOURCE_DEFAULT_SHEET_ONE_FIELD;
$record['tx_fed_fcefile'] = 'Flux:Default.html';
$this->performDummyRegistration();
$controllerClassName = 'FluidTYPO3\\Flux\\Controller\\ContentController';
/** @var AbstractFluxController $instance */
$instance = $this->objectManager->get($controllerClassName);
ObjectAccess::setProperty($instance, 'extensionName', 'Flux', TRUE);
return $instance;
}
示例10: testRender
/**
* @dataProvider getRenderTestValues
* @param array $arguments
* @param mixed $selectedValue
* @param mixed $content
* @param string $expected
*/
public function testRender(array $arguments, $selectedValue, $content, $expected)
{
$instance = $this->buildViewHelperInstance($arguments, array(), NULL, 'Vhs');
$viewHelperVariableContainer = new ViewHelperVariableContainer();
$viewHelperVariableContainer->add('FluidTYPO3\\Vhs\\ViewHelpers\\Form\\SelectViewHelper', 'options', array());
$viewHelperVariableContainer->add('FluidTYPO3\\Vhs\\ViewHelpers\\Form\\SelectViewHelper', 'value', $selectedValue);
ObjectAccess::setProperty($instance, 'viewHelperVariableContainer', $viewHelperVariableContainer, TRUE);
$instance->setArguments($arguments);
$instance->setRenderChildrenClosure(function () use($content) {
return $content;
});
$result = $instance->render();
$this->assertEquals($expected, $result);
}
示例11: getNegativeTestValues
/**
* @return array
*/
public function getNegativeTestValues()
{
$bar = new Bar();
ObjectAccess::setProperty($bar, 'uid', 1, TRUE);
$foo = new Foo();
ObjectAccess::setProperty($foo, 'uid', 2, TRUE);
$objectStorage = new ObjectStorage();
$objectStorage->attach($bar);
/** @var LazyObjectStorage $lazyObjectStorage */
$lazyObjectStorage = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage', $bar, 'foo', 0);
ObjectAccess::setProperty($lazyObjectStorage, 'isInitialized', TRUE, TRUE);
$lazyObjectStorage->attach($foo);
return array(array(array('foo'), 'bar'), array('foo,baz', 'bar'), array($objectStorage, $foo), array($lazyObjectStorage, $bar));
}
示例12: renderMethodCallsRenderChildrenAndTemplateVariableContainerAddAndRemoveIfAsArgumentGiven
/**
* @test
*/
public function renderMethodCallsRenderChildrenAndTemplateVariableContainerAddAndRemoveIfAsArgumentGiven()
{
$array = array('1', '2', '3');
$arguments = array('as' => 'test', 'content' => $array, 'glue' => ',');
$mock = $this->getMock($this->getViewHelperClassName(), array('renderChildren'));
$mock->expects($this->once())->method('renderChildren')->will($this->returnValue('test'));
$mock->setArguments($arguments);
$mockContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', array('add', 'get', 'remove', 'exists'));
$mockContainer->expects($this->once())->method('exists')->with('test')->will($this->returnValue(TRUE));
$mockContainer->expects($this->exactly(2))->method('add')->with('test', '1,2,3');
$mockContainer->expects($this->once())->method('get')->with('test')->will($this->returnValue($array));
$mockContainer->expects($this->exactly(2))->method('remove')->with('test');
ObjectAccess::setProperty($mock, 'templateVariableContainer', $mockContainer, TRUE);
$mock->render();
}
示例13: createDependingRegistrations
/**
* Duplicates (all public accessable properties) the given registration the
* amount of times configured in amountOfRegistrations
*
* @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
*
* @return void
*/
public function createDependingRegistrations($registration)
{
$registrations = $registration->getAmountOfRegistrations();
for ($i = 1; $i <= $registrations - 1; $i++) {
/** @var \DERHANSEN\SfEventMgt\Domain\Model\Registration $newReg */
$newReg = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration');
$properties = ObjectAccess::getGettableProperties($registration);
foreach ($properties as $propertyName => $propertyValue) {
ObjectAccess::setProperty($newReg, $propertyName, $propertyValue);
}
$newReg->setMainRegistration($registration);
$newReg->setAmountOfRegistrations(1);
$newReg->setIgnoreNotifications(TRUE);
$this->registrationRepository->add($newReg);
}
}
示例14: createAndTestDummyControllerInstance
/**
* @return AbstractFluxController
*/
protected function createAndTestDummyControllerInstance()
{
$record = Records::$contentRecordWithoutParentAndWithoutChildren;
$record['pi_flexform'] = Xml::SIMPLE_FLEXFORM_SOURCE_DEFAULT_SHEET_ONE_FIELD;
$record['tx_fed_fcefile'] = 'Flux:Default.html';
$frontend = new TypoScriptFrontendController($GLOBALS['TYPO3_CONF_VARS'], 1, 0);
$frontend->cObj = new ContentObjectRenderer();
$frontend->cObj->start($record);
$this->performDummyRegistration();
$controllerClassName = substr(get_class($this), 0, -4);
/** @var AbstractFluxController $instance */
$instance = $this->objectManager->get($controllerClassName);
ObjectAccess::setProperty($instance, 'extensionName', 'Flux', TRUE);
ObjectAccess::getProperty($instance, 'configurationManager', TRUE)->setContentObject($frontend->cObj);
return $instance;
}
示例15: stopsRenderingWhenProviderSaysStop
/**
* @test
*/
public function stopsRenderingWhenProviderSaysStop()
{
$instance = $this->getMock('FluidTYPO3\\Flux\\Backend\\Preview', array('createShortcutIcon'));
$instance->expects($this->never())->method('createShortcutIcon');
$configurationServiceMock = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('resolveConfigurationProviders'));
$providerOne = $this->getMock('FluidTYPO3\\Flux\\Provider\\ContentProvider', array('getPreview'));
$providerOne->expects($this->once())->method('getPreview')->will($this->returnValue(array('test', 'test', FALSE)));
$providerTwo = $this->getMock('FluidTYPO3\\Flux\\Provider\\ContentProvider', array('getPreview'));
$providerTwo->expects($this->never())->method('getPreview');
$configurationServiceMock->expects($this->once())->method('resolveConfigurationProviders')->will($this->returnValue(array($providerOne, $providerTwo)));
ObjectAccess::setProperty($instance, 'configurationService', $configurationServiceMock, TRUE);
$header = 'test';
$item = 'test';
$record = Records::$contentRecordIsParentAndHasChildren;
$draw = TRUE;
$this->setup();
$instance->renderPreview($header, $item, $record, $draw);
}