/** * 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; }
/** * {@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; }
/** * 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)); }
/** * 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 . '".'); }
/** * 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; }