コード例 #1
0
 /**
  * @author Andreas Glaser
  */
 public function testAttributes()
 {
     $attributesHelper = new AttributesHelper();
     $attributesHelper->setId('myid')->addClass('myclass')->addData('mydata1', 'cheese')->addData('mydata2', 'bacon')->addStyle('height', '100%')->addStyle('width', '200px')->set('href', 'http://andreas.glaser.me');
     $this->assertEquals(' id="myid" class="myclass" href="http://andreas.glaser.me" data-mydata1="cheese" data-mydata2="bacon" style="height:100%;width:200px;"', $attributesHelper->render());
     $attributesHelper->removeClass('myclass');
     $attributesHelper->removeData('mydata2');
     $attributesHelper->removeId();
     $this->assertEquals(' href="http://andreas.glaser.me" data-mydata1="cheese" style="height:100%;width:200px;"', $attributesHelper->render());
     $this->assertEquals(' id="my-id" class="testclass" data-important="info" data-cheese="delicious" style="color:red;font-size:1em;"', AttributesHelper::f(['id' => 'my-id', 'CLASS' => 'testclass', 'data-important' => 'info', 'data-cheese' => 'delicious', 'style' => 'color:red;font-size:1em'])->render());
 }
コード例 #2
0
ファイル: Cell.php プロジェクト: andreas-glaser/php-helpers
 /**
  * @param \AndreasGlaser\Helpers\Interfaces\RendererInterface|null $renderer
  *
  * @return string
  * @author Andreas Glaser
  */
 public function render(RendererInterface $renderer = null)
 {
     if ($renderer) {
         return $renderer->render($this);
     }
     return '<td' . $this->attributes->render() . '>' . $this->content . '</td>';
 }
コード例 #3
0
ファイル: Row.php プロジェクト: andreas-glaser/php-helpers
 /**
  * @param \AndreasGlaser\Helpers\Interfaces\RendererInterface|null $renderer
  *
  * @return string
  * @author Andreas Glaser
  */
 public function render(RendererInterface $renderer = null)
 {
     if ($renderer) {
         return $renderer->render($this);
     }
     $html = '<tr' . $this->attributes->render() . '>';
     foreach ($this->getCells() as $cell) {
         $html .= $cell->render();
     }
     $html .= '</tr>';
     return $html;
 }