/** * {@inheritdoc} * * @param string|object $class The class or an object of it * @param string $path A key name. Can be dotted like address.street.name * @return \Xtype\AbstractType **/ public function keyType($class, $path) { // Allows manual overwrites if titles if ($type = $this->getManualKeyType($this->getClassName($class), $path)) { return $type; } try { // First check if path is a related key (account.owner.id) if ($this->parser->isRelatedKey($path)) { list($join, $key) = $this->parser->toJoinAndKey($path); $className = $this->pathIntrospector->classOfPath($class, $join); } else { // No related key $className = $this->getClassName($class); $key = $path; } if ($type = $this->getManualKeyType($className, $key)) { return $type; } if ($this->isDate($className, $key)) { $type = new TemporalType(); $type->setFormat($this->defaultDateFormat); return $type; } } catch (UnexpectedValueException $e) { return; } }
protected function getConfigType() { $configType = NamedFieldType::create(); $date = new DateTime(); $configType->set('boolean', BoolType::create()->setDefaultValue(true)); $configType->set('integer', NumberType::create()->setNativeType('int')->setDefaultValue(22)); $configType->set('float', NumberType::create()->setNativeType('float')->setDefaultValue(3.4)); $configType->set('temporal', TemporalType::create()->setDefaultValue($date)); $configType->set('string', StringType::create()->setDefaultValue('default')); return $configType; }