Exemplo n.º 1
0
 /**
  * Maps an individual column in to a Form element
  *
  * @param Column $column
  * @return ElementInterface
  */
 protected function mapColumn(Column $column, $fks)
 {
     $attributes = ['name' => $column->getName(), 'id' => str_replace('_', '-', $column->getName()), 'class' => null];
     if ($this->helper->isEmail($column)) {
         $element = new Email($attributes);
     } elseif ($this->helper->isPassword($column)) {
         $element = new Password($attributes);
     } elseif ($this->helper->isHidden($column)) {
         $element = new Hidden($attributes);
     } elseif ($this->helper->isBoolean($column)) {
         $element = new Boolean($attributes);
     } elseif ($this->helper->isDate($column)) {
         $element = new Date($attributes);
     } elseif ($this->helper->isSelect($column, $fks)) {
         $element = new Select($attributes);
     } elseif ($this->helper->isTextArea($column)) {
         $element = new TextArea($attributes);
     } elseif ($this->helper->isString($column)) {
         $attributes['maxlength'] = $column->getLength();
         $element = new Text($attributes);
     } elseif ($this->helper->isNumeric($column)) {
         $element = new Numeric($attributes);
     } else {
         $element = new Text($attributes);
     }
     $element->setRequired($column->getNotnull());
     return $element;
 }
Exemplo n.º 2
0
 public function testHasCommentTag()
 {
     $helper = new ColumnHelper();
     $column = $this->getMockBuilder(Column::class)->disableOriginalConstructor()->getMock();
     $column->expects($this->at(0))->method('getComment')->willReturn(' slkdjflskdj flskdjfl skdjfs ldkf #email');
     $column->expects($this->at(1))->method('getComment')->willReturn('#email slkdfjs lkdjfl skdjflsk');
     $column->expects($this->at(2))->method('getComment')->willReturn('skdjfls dkjf #email ggg');
     $column->expects($this->at(3))->method('getComment')->willReturn('ffemail');
     $result = $helper->hasCommentTag($column, 'email');
     $this->assertTrue($result);
     $result = $helper->hasCommentTag($column, 'email');
     $this->assertTrue($result);
     $result = $helper->hasCommentTag($column, 'email');
     $this->assertTrue($result);
     $result = $helper->hasCommentTag($column, 'email');
     $this->assertFalse($result);
 }