コード例 #1
0
 /**
  * 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());
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function guessConstraints(AbstractAttribute $attribute)
 {
     $constraints = array();
     if ($attribute->isRequired()) {
         $constraints[] = new Assert\NotBlank();
     }
     return $constraints;
 }
コード例 #3
0
 /**
  * {@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;
 }
コード例 #4
0
 /**
  * Get normalized is required for attribute
  * @param AbstractAttribute $attribute
  *
  * @return string
  */
 protected function getNormalizedRequired(AbstractAttribute $attribute)
 {
     return $attribute->isRequired() ? '1' : '0';
 }