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


PHP PropertyAccessor::setValue方法代码示例

本文整理汇总了PHP中Symfony\Component\PropertyAccess\PropertyAccessor::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP PropertyAccessor::setValue方法的具体用法?PHP PropertyAccessor::setValue怎么用?PHP PropertyAccessor::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\PropertyAccess\PropertyAccessor的用法示例。


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

示例1: getConstraintViolation

 protected function getConstraintViolation(ConstraintViolation $constraintViolation, array &$messages)
 {
     $path = new PropertyPath($constraintViolation->getPropertyPath());
     $elements = $path->getElements();
     $elements[] = $constraintViolation->getConstraint()->validatedBy();
     $this->propertyAccessor->setValue($messages, $this->buildPath($elements), $constraintViolation->getMessage());
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:7,代码来源:ConstraintViolationMapper.php

示例2: create

 /**
  * {@inheritdoc}
  */
 public function create(&$node, $singlePath, $value)
 {
     if (!$this->isWritable($node, $singlePath)) {
         throw new InvalidPathException(sprintf('Path %s could not be created in object of type %s', $singlePath, gettype($node)));
     }
     $this->propertyAccess->setValue($node, $singlePath, $value);
 }
开发者ID:chili-labs,项目名称:json-pointer,代码行数:10,代码来源:PropertyAccessAccessor.php

示例3: convert

 /**
  * {@inheritdoc}
  */
 public function convert($value)
 {
     $ref = new \ReflectionClass($this->class);
     $data = $ref->newInstanceWithoutConstructor();
     $this->propertyAccessor->setValue($data, $this->label, $value);
     return (object) $data;
 }
开发者ID:mcdir,项目名称:SonatraFormExtensionsBundle,代码行数:10,代码来源:NewTagConverter.php

示例4: reverseTransform

 /**
  * Transforms date string to DateTime object
  *
  * @param object                $modelData
  * @param PropertyPathInterface $propertyPath
  * @param mixed                 $value
  */
 public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value)
 {
     if (false === ($date = $this->createDateFromString($value))) {
         $date = null;
     }
     $this->propertyAccessor->setValue($modelData, $propertyPath, $date);
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:14,代码来源:DateTransformer.php

示例5: transform

 /**
  * Applies the given mapping on a given object or array.
  *
  * @param  object|array $raw         The input object or array
  * @param  array        $mapping     The mapping
  * @param  object|array $transformed The output object or array.
  * @return array
  */
 public function transform($raw, array $mapping, $transformed = [])
 {
     foreach ($mapping as $destination => $source) {
         $value = $this->propertyAccessor->isReadable($raw, $source) ? $this->propertyAccessor->getValue($raw, $source) : null;
         $this->propertyAccessor->setValue($transformed, $destination, $value);
     }
     return $transformed;
 }
开发者ID:alebon,项目名称:graviton,代码行数:16,代码来源:MappingTransformer.php

示例6: addWhereCondition

 /**
  * {@inheritdoc}
  */
 protected function addWhereCondition($entityClassName, $tableAlias, $fieldName, $columnExpr, $columnAlias, $filterName, array $filterData)
 {
     $filter = ['column' => $this->getFilterByExpr($entityClassName, $tableAlias, $fieldName, $columnExpr), 'filter' => $filterName, 'filterData' => $filterData];
     if ($columnAlias) {
         $filter['columnAlias'] = $columnAlias;
     }
     $this->accessor->setValue($this->filters, $this->currentFilterPath, $filter);
     $this->incrementCurrentFilterPath();
 }
开发者ID:antrampa,项目名称:platform,代码行数:12,代码来源:GroupingOrmQueryConverter.php

示例7: duplicateTranslatableEntity

 private function duplicateTranslatableEntity(LocaleAwareInterface $entity, array $properties, LocaleInterface $targetLocale)
 {
     $duplicate = clone $entity;
     foreach ($properties as $propertyName) {
         $value = sprintf('%s-%s', $this->propertyAccessor->getValue($entity, $propertyName), $targetLocale->getCode());
         $this->propertyAccessor->setValue($duplicate, $propertyName, $value);
         $duplicate->setLocale($targetLocale->getCode());
         $this->doctrineHelper->getEntityManager()->persist($duplicate);
     }
 }
开发者ID:WellCommerce,项目名称:LocaleBundle,代码行数:10,代码来源:LocaleCopier.php

示例8: copyTranslatableEntity

 protected function copyTranslatableEntity(LocaleAwareInterface $entity, LocaleInterface $targetLocale)
 {
     $duplicate = clone $entity;
     foreach ($entity->getCopyingSensitiveProperties() as $propertyName) {
         $value = sprintf('%s-%s', $this->propertyAccessor->getValue($entity, $propertyName), $targetLocale->getCode());
         $this->propertyAccessor->setValue($duplicate, $propertyName, $value);
         $duplicate->setLocale($targetLocale->getCode());
         $this->entityManager->persist($duplicate);
     }
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:10,代码来源:LocaleCopier.php

示例9: setData

 /**
  * @param AssociationTypeInterface $associationType
  * @param string                   $field
  * @param mixed                    $data
  */
 protected function setData(AssociationTypeInterface $associationType, $field, $data)
 {
     if ('labels' === $field) {
         foreach ($data as $localeCode => $label) {
             $associationType->setLocale($localeCode);
             $translation = $associationType->getTranslation();
             $translation->setLabel($label);
         }
     } else {
         $this->accessor->setValue($associationType, $field, $data);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:AssociationTypeUpdater.php

示例10: reverseTransform

 /**
  * @inheritdoc
  */
 public function reverseTransform($value)
 {
     if (is_null($value)) {
         return null;
     }
     if (!is_numeric($value) && $this->tags && $this->property) {
         $object = $this->metadata->newInstance();
         $this->propertyAccessor->setValue($object, $this->property, $value);
         return $object;
     }
     return $this->em->getRepository($this->class)->find($value);
 }
开发者ID:snovichkov,项目名称:Select2Bundle,代码行数:15,代码来源:EntityToPropertyTransformer.php

示例11: fillFromArray

 /**
  * @param object $entity
  * @param array  $data
  */
 protected function fillFromArray($entity, array $data)
 {
     foreach ($data as $key => $value) {
         try {
             $this->guessTypeAndConvert($key, $value);
             $this->propertyAccessor->setValue($entity, $key, $value);
         } catch (NoSuchPropertyException $e) {
             if ($key !== 'reference') {
                 printf('--- Unknown property %s. Omitted.' . PHP_EOL, $key);
             }
         }
     }
 }
开发者ID:ruslan-polutsygan,项目名称:dev-bundle,代码行数:17,代码来源:LoadFixturesHelperTrait.php

示例12: setValue

 private function setValue(&$item, $key, $value, $options = [])
 {
     $this->debug && $this->logger->info("Value adding is started.");
     switch ($options['type']) {
         case "string":
         case "text":
         case "integer":
         case "collection":
         case "bool":
             if (isset($options['modifier'])) {
                 $value = $this->modify($value, $options['modifier'], $item);
             }
             break;
         case "date":
             if (!array_key_exists('format', $options)) {
                 $options['format'] = "Y-m-d H:i:s";
             }
             $value = !empty($value) ? \DateTime::createFromFormat($options['format'], $value) : new \DateTime();
             break;
         case "object":
             $value = $this->setObjectValue($item, $key, $value, $options);
             break;
     }
     if (array_key_exists('value', $options)) {
         $value = $options['value'];
     }
     $value ? $this->accessor->setValue($item, $key, $value) : $this->logger->alert("Value is null for {$key}.");
     $this->debug && $this->logger->info("Value adding is completed.");
 }
开发者ID:gitter-badger,项目名称:importbundle,代码行数:29,代码来源:ImportManager.php

示例13: setDefaultOptions

 /**
  * @param Attribute $attribute
  * @param array $options
  */
 public function setDefaultOptions(Attribute $attribute, array $options)
 {
     $attributeOptions = [];
     $attributeDefaultValues = [];
     foreach ($options as $optionData) {
         $order = $this->getOption($optionData, 'order', 0);
         $data = $this->getOption($optionData, 'data', []);
         $masterOptionId = $this->getOption($optionData, 'master_option_id');
         $masterOption = $attribute->getOptionById($masterOptionId);
         if (!$masterOption) {
             $masterOption = new AttributeOption();
             $attribute->addOption($masterOption);
         }
         foreach ($data as $localeId => $localeData) {
             $localeValue = $this->getOption($localeData, 'value', '');
             $option = $this->generateOption($masterOption, $localeId, $localeValue, $order);
             $attributeOptions[] = $option;
             if (!empty($localeData['is_default'])) {
                 $attributeDefaultValues[] = $this->generateOptionDefaultValue($attribute, $option, $localeId);
             }
         }
     }
     $this->propertyAccessor->setValue($attribute, 'options', $attributeOptions);
     $this->propertyAccessor->setValue($attribute, 'defaultValues', $attributeDefaultValues);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:29,代码来源:DefaultsTransformerHelper.php

示例14: testSetTypeHint

 public function testSetTypeHint()
 {
     $date = new \DateTimeImmutable();
     $object = new TestClass('Kévin');
     $this->propertyAccessor->setValue($object, 'date', $date);
     $this->assertSame($date, $object->getDate());
 }
开发者ID:tifabien,项目名称:symfony,代码行数:7,代码来源:PropertyAccessorTest.php

示例15: testSetValueDeepWithMagicGetter

 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']);
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:7,代码来源:PropertyAccessorTest.php


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