Beispiel #1
0
 /**
  * Save schema
  *
  * @param SchemaInterface $schema
  *
  * @return SchemaInterface
  */
 public function save(SchemaInterface $schema)
 {
     foreach ($schema->getAttributes() as $attribute) {
         $attribute->setSchema($schema);
         $this->em->persist($attribute);
     }
     $this->em->persist($schema);
     $this->em->flush();
     return $schema;
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     $value = $this->getOrNull($name);
     if (null === $value) {
         throw new \BadMethodCallException(sprintf('The valueset for schema "%d" does not have a value called "%s".', $this->schema->getId(), $name));
     }
     return $value;
 }
Beispiel #3
0
 /**
  * Magic getter to retrieve attribute values
  *
  * @param string $name
  *
  * @return Value
  */
 public function __get($name)
 {
     foreach ($this->values as $valueObject) {
         if ($valueObject->getAttribute()->getName() == $name) {
             return $valueObject;
         }
     }
     throw new \BadMethodCallException(sprintf('The valueset for schema "%d" does not have a value called "%s".', $this->schema->getId(), $name));
 }
Beispiel #4
0
 /**
  * Magic getter to retrieve attribute values
  *
  * @param string $name
  *
  * @return Value
  */
 public function __get($name)
 {
     foreach ($this->values as $valueObject) {
         if ($valueObject->getAttribute()->getName() == $name) {
             return $valueObject;
         }
     }
     throw new \BadMethodCallException('The valueset for schema "' . $this->schema->getName() . '" does not have a value called "' . $name . '".');
 }
Beispiel #5
0
 /**
  * Add allowed schema
  *
  * @param  SchemaInterface $schema
  *
  * @return  AttributeInterface
  */
 public function addAllowedSchema(SchemaInterface $schema)
 {
     $exists = false;
     foreach ($this->allowedSchemas as $allowedSchema) {
         if ($allowedSchema->getId() == $schema->getId()) {
             $exists = true;
         }
     }
     if (!$exists) {
         $this->allowedSchemas[] = $schema;
     }
     return $this;
 }