public function testSetValueDeepWithMagicGetter() { $obj = new TestClassMagicGet('foo'); $obj->publicProperty = array('foo' => array('bar' => 'some_value')); $this->propertyAccessor->setValue($obj, 'publicProperty[foo][bar]', 'Updated'); $this->assertSame('Updated', $obj->publicProperty['foo']['bar']); }
/** * Set value * * @param string $name * @param mixed $value * @param boolean $changeModified * @return WorkflowData */ public function set($name, $value, $changeModified = true) { try { $propertyPath = $this->getMappedPath($name); if ($changeModified && (!$this->has($name) || $this->propertyAccessor->getValue($this->data, $propertyPath) !== $value)) { $this->modified = true; } $this->propertyAccessor->setValue($this->data, $propertyPath, $value); return $this; } catch (\Exception $e) { return $this; } }
/** * @param AbstractAddress $from * @param AbstractAddress $to * @param string $property */ protected function setValue(AbstractAddress $from, AbstractAddress $to, $property) { if (!$this->propertyAccessor) { $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); } try { $value = $this->propertyAccessor->getValue($from, $property); if (!$value || $value instanceof Collection && $value->isEmpty()) { return; } $this->propertyAccessor->setValue($to, $property, $value); } catch (NoSuchPropertyException $e) { } }
/** * {@inheritdoc} */ public function replaceOption($id, $optionName, $oldOptionValue, $newOptionValue) { $options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS); $path = $this->getPropertyPath($optionName); try { $value = $this->propertyAccessor->getValue($options, $path); } catch (NoSuchPropertyException $ex) { $value = null; } if (!$value instanceof OptionValueBag) { $value = $this->createOptionValueBag($value); } $value->replace($oldOptionValue, $newOptionValue); $this->propertyAccessor->setValue($options, $path, $value); $this->rawLayout->setProperty($id, RawLayout::OPTIONS, $options); }
/** * @dataProvider getPathsWithMissingIndex */ public function testSetValueThrowsNoExceptionIfIndexNotFound($collection, $path) { $this->propertyAccessor->setValue($collection, $path, 'Updated'); $this->assertSame('Updated', $this->propertyAccessor->getValue($collection, $path)); }
public function testTicket5755() { $object = new Ticket5775Object(); $this->propertyAccessor->setValue($object, 'property', 'foobar'); $this->assertEquals('foobar', $object->getProperty()); }