/** * Test related method */ public function testConstruct() { $this->assertEntity($this->attribute); $this->assertEmptyCollection($this->attribute->getOptions()); $this->assertNull($this->attribute->getAvailableLocales()); $this->assertEmptyCollection($this->attribute->getTranslations()); $this->assertFalse($this->attribute->isRequired()); $this->assertFalse($this->attribute->isUnique()); $this->assertNull($this->attribute->getDefaultValue()); $this->assertFalse($this->attribute->isLocalizable()); $this->assertFalse($this->attribute->isScopable()); $this->assertFalse($this->attribute->isUseableAsGridColumn()); $this->assertFalse($this->attribute->isUseableAsGridFilter()); $this->assertNull($this->attribute->isDecimalsAllowed()); $this->assertNull($this->attribute->isNegativeAllowed()); }
/** * {@inheritdoc} */ public function guessConstraints(AbstractAttribute $attribute) { $constraints = array(); if ($attribute->isRequired()) { $constraints[] = new Assert\NotBlank(); } return $constraints; }
/** * {@inheritdoc} */ public function guessConstraints(AbstractAttribute $attribute) { $constraints = array(); if ($attribute->isRequired()) { $constraints[] = new Constraints\NotBlank(); } switch ($attribute->getBackendType()) { case AbstractAttributeType::BACKEND_TYPE_DATE: $constraints[] = new Constraints\Date(); break; case AbstractAttributeType::BACKEND_TYPE_DATETIME: $constraints[] = new Constraints\DateTime(); break; } return $constraints; }
/** * Get normalized is required for attribute * @param AbstractAttribute $attribute * * @return string */ protected function getNormalizedRequired(AbstractAttribute $attribute) { return $attribute->isRequired() ? '1' : '0'; }