/** * @param array $values * @return void * @throws \obo\Exceptions\BadAnnotationException */ public function process(array $values) { parent::process($values); $this->targetEntity = $values["targetEntity"]; if (\strpos($this->targetEntity, "property:") === 0) { $this->targetEntityInProperty = \substr($this->targetEntity, 9); if ($this->entityInformation->existInformationForPropertyWithName($this->targetEntityInProperty)) { \obo\Services::serviceWithName(\obo\obo::ENTITIES_EXPLORER)->createDataType(\obo\DataType\StringDataType::name(), $this->entityInformation->informationForPropertyWithName($this->targetEntityInProperty)); } } if (!$this->targetEntityInProperty and !\class_exists($this->targetEntity)) { throw new \obo\Exceptions\BadAnnotationException("Relationship 'one' could not be built. Entity '{$this->targetEntity}' could not be connected because it does not exist."); } if (isset($values["cascade"])) { $this->cascadeOptions = \preg_split("#, ?#", $values["cascade"]); } if (isset($values["autoCreate"])) { if (!\is_bool($values["autoCreate"])) { throw new \obo\Exceptions\BadAnnotationException("Parameter 'autoCreate' for relationship 'one' must be boolean"); } $this->autoCreate = $values["autoCreate"]; } if (isset($values["connectViaProperty"])) { $this->connectViaProperty = $values["connectViaProperty"]; if (isset($values["ownerNameInProperty"])) { $this->ownerNameInProperty = $values["ownerNameInProperty"]; } $this->propertyInformation->columnName = ""; $this->propertyInformation->persistable = false; } if (isset($values["eager"])) { $this->eager = $values["eager"]; } if ($this->eager) { $this->entityInformation->eagerConnections[] = $this->propertyInformation->name; } $this->propertyInformation->relationship = new \obo\Relationships\One($this->targetEntity, $this->propertyInformation->name, $this->cascadeOptions); $this->propertyInformation->relationship->autoCreate = $this->autoCreate; $this->propertyInformation->relationship->ownerNameInProperty = $this->ownerNameInProperty; $this->propertyInformation->relationship->connectViaProperty = $this->connectViaProperty; $this->propertyInformation->dataType = \obo\Services::serviceWithName(\obo\obo::ENTITIES_EXPLORER)->createDataType(\obo\DataType\EntityDataType::name(), $this->propertyInformation, $this->targetEntityInProperty === null ? ["className" => $this->targetEntity] : []); }
/** * @param array $values * @return void */ public function process(array $values) { parent::process($values); $this->registerUuidGenerator = $values[0]; $this->propertyInformation->dataType = \obo\Services::serviceWithName(\obo\obo::ENTITIES_EXPLORER)->createDataType(\obo\DataType\StringDataType::name(), $this->propertyInformation); }
/** * * @param \obo\Carriers\PropertyInformationCarrier $propertyInformation * @return \obo\DataType\Base\DataType */ protected function defaultDataTypeForProperty(\obo\Carriers\PropertyInformationCarrier $propertyInformation) { if ($propertyInformation->varName === "") { return null; } if ($propertyInformation->defaultValue === false or $propertyInformation->defaultValue === true) { return $this->createDatatype(\obo\DataType\BooleanDataType::name(), $propertyInformation); } elseif (\is_numeric($propertyInformation->defaultValue) and \is_int($propertyInformation->defaultValue * 1)) { return $this->createDatatype(\obo\DataType\IntegerDataType::name(), $propertyInformation); } elseif (\is_numeric($propertyInformation->defaultValue) and \is_float($propertyInformation->defaultValue * 1)) { return $this->createDatatype(\obo\DataType\FloatDataType::name(), $propertyInformation); } elseif (is_string($propertyInformation->defaultValue)) { return $this->createDatatype(\obo\DataType\StringDataType::name(), $propertyInformation); } elseif (\is_array($propertyInformation->defaultValue)) { return $this->createDatatype(\obo\DataType\ArrayDataType::name(), $propertyInformation); } else { return null; } }