public function buildFieldFormatterForField(Field $field) { switch ($field->getType()) { case Field::TYPE_DATE: case Field::TYPE_DATETIME: $formatString = $field->getFormatString(); if ($formatString === null) { $formatString = $field->getType() === Field::TYPE_DATE ? DateTimeFieldFormatter::DEFAULT_DATE_FORMAT_STRING : DateTimeFieldFormatter::DEFAULT_DATETIME_FORMAT_STRING; } return new DateTimeFieldFormatter($formatString); break; case Field::TYPE_STRING: return new StringFieldFormatter(); case Field::TYPE_NUMBER: return new NumberFieldFormatter(); case Field::TYPE_BOOL: return new BoolFieldFormatter(); default: throw new \InvalidArgumentException(sprintf('unknown field type[%s], cannot create related formatter', $field->getType())); } }
public function buildFieldHydratorForField(Field $field) { switch ($field->getType()) { case Field::TYPE_STRING: return new StringFieldHydrator(); break; case Field::TYPE_DATETIME: return new DateTimeFieldHydrator(); break; case Field::TYPE_DATE: return new DateFieldHydrator(); break; case Field::TYPE_NUMBER: return new NumberFieldHydrator(); break; case Field::TYPE_BOOL: return new BoolFieldHydrator(); break; default: throw new \InvalidArgumentException(sprintf('unknown field type[%s], cannot create related FieldHydrator', $field->getType())); } }
private function buildSelectFieldClause(Field $field) { $resource = $field->getResource(); return $resource->getResourceUniqueIdentifier() . '.' . $field->getName() . ' as ' . $resource->getResourceUniqueIdentifier() . '_' . $field->getAlias(); }
public function test_that_a_field_to_string_returns_alias() { $field = new Field($this->buildFakeResource(), 'myCoolField', 'my_cool_field', Field::TYPE_STRING); $this->assertEquals('myCoolField', $field->__toString()); }