本文整理汇总了PHP中TYPO3\Flow\Reflection\ObjectAccess::setProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::setProperty方法的具体用法?PHP ObjectAccess::setProperty怎么用?PHP ObjectAccess::setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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;
}
示例5: 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;
}
示例6: replaceCommandWithDomainCommand
/**
* @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);
}
示例7: collectionValidatorIsValidEarlyReturnsOnUnitializedDoctrinePersistenceCollections
/**
* @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);
}
示例8: hydrate
/**
* @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;
}
示例9: buildTransformationObject
/**
* 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;
}
示例10: iHaveTheFollowingPolicies
/**
* @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);
}
示例11: ignoredClassesCanBeOverwrittenBySettings
/**
* @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));
}
示例12: setUp
public function setUp()
{
$this->factory = new \Ag\Login\Domain\Factory\AccountFactory();
$loginFactory = m::mock('\\TYPO3\\Flow\\Security\\AccountFactory');
$loginFactory->shouldReceive('createAccountWithPassword')->andReturnUsing(function ($email, $password) {
$login = new \TYPO3\Flow\Security\Account();
$login->setAccountIdentifier($email);
return $login;
});
\TYPO3\Flow\Reflection\ObjectAccess::setProperty($this->factory, 'accountFactory', $loginFactory, TRUE);
\TYPO3\Flow\Reflection\ObjectAccess::setProperty($this->factory, 'emailAddressValidator', new \TYPO3\Flow\Validation\Validator\EmailAddressValidator(), TRUE);
}
示例13: render
/**
* @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();
}
示例14: iHaveTheFollowingPolicies
/**
* WARNING: If using this step definition, IT MUST RUN AS ABSOLUTELY FIRST STEP IN A SCENARIO!
*
* @Given /^I have the following policies:$/
*/
public function iHaveTheFollowingPolicies($string)
{
if ($this->subProcess !== null) {
// This check ensures that this statement is ran *before* a subprocess is opened; as the Policy.yaml
// which is set here influences the Proxy Building Process.
throw new \Exception('Step "I have the following policies:" must run as FIRST step in a scenario, because otherwise the proxy-classes are already built in the wrong manner!');
}
self::$testingPolicyPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Policy.yaml';
file_put_contents(self::$testingPolicyPathAndFilename, $string->getRaw());
$configurationManager = $this->objectManager->get(\TYPO3\Flow\Configuration\ConfigurationManager::class);
$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::class);
\TYPO3\Flow\Reflection\ObjectAccess::setProperty($policyService, 'initialized', false, true);
}
示例15: evaluateTests
/**
* @test
* @dataProvider attributeExamples
*/
public function evaluateTests($properties, $expectedOutput)
{
$path = 'attributes/test';
$this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($path, $properties) {
$relativePath = str_replace($path . '/', '', $evaluatePath);
return ObjectAccess::getPropertyPath($properties, str_replace('/', '.', $relativePath));
}));
$typoScriptObjectName = 'TYPO3.TypoScript:Attributes';
$renderer = new AttributesImplementation($this->mockTsRuntime, $path, $typoScriptObjectName);
if ($properties !== null) {
foreach ($properties as $name => $value) {
ObjectAccess::setProperty($renderer, $name, $value);
}
}
$result = $renderer->evaluate();
$this->assertEquals($expectedOutput, $result);
}