Exemple #1
0
 /**
  * Batch set a given list of attribute values.
  *
  * @param array $values
  */
 public function setValues(array $values)
 {
     foreach ($this->type->getAttributes()->getKeys() as $attribute_name) {
         if (array_key_exists($attribute_name, $values)) {
             $this->setValue($attribute_name, $values[$attribute_name]);
         }
     }
     return $this->isValid();
 }
Exemple #2
0
 /**
  * Creates a entity with fake data for the given type.
  *
  * @param EntityTypeInterface $type type to create entities for
  * @param array $options For valid options see fake() method
  * @param EntityInterface $parent Parent entity to create entity within
  *
  * @return entity newly created with fake data
  *
  * @throws \Trellis\Runtime\Entity\InvalidValueException in case of fake data being invalid for the given attribute
  * @throws \Trellis\Runtime\Entity\BadValueException in case of invalid locale option string
  * @throws \Trellis\Common\Error\RuntimeException on EmbeddedEntityListAttribute misconfiguration
  */
 public function createFakeEntity(EntityTypeInterface $type, array $options = array(), EntityInterface $parent = null)
 {
     $options[self::OPTION_MARK_CLEAN] = true;
     $entity = $type->createEntity([], $parent);
     $this->fake($entity, $options);
     return $entity;
 }