From cd2a2b050611e6a9b99b862712d7423fb0c1b1dd Mon Sep 17 00:00:00 2001 From: Julien Houvion Date: Thu, 7 Jul 2016 17:38:20 +0200 Subject: [PATCH] ajout de la description dans une colonne du table --- src/Table/Column/Column.php | 51 ++++++++++++++++++++++++++++++++ src/Table/Renderer/Bootstrap.php | 6 +++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/Table/Column/Column.php b/src/Table/Column/Column.php index 25cfed1..9b0335b 100644 --- a/src/Table/Column/Column.php +++ b/src/Table/Column/Column.php @@ -71,6 +71,14 @@ abstract class Column protected $visible = true; + /** + * Description de la colonne + * + * @var + */ + protected $description; + + /** * Setter for $width attribute * @@ -460,4 +468,47 @@ public function isVisible($row = null) $callable = !is_bool($this->visible) && !is_string($this->visible) && is_callable($this->visible); return (bool) ($callable ? call_user_func($this->visible, $this, $row) : $this->visible); } + + + + /** + * Setter for $description + * + * @param $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * getter for $description + * + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * Return TRUE is $description is set + * + * @return bool + */ + public function hasDescription() + { + return isset($this->description); + } + + /** + * Unset $description + * + * @return $this + */ + public function removeDescription() + { + unset($this->description); + return $this; + } } \ No newline at end of file diff --git a/src/Table/Renderer/Bootstrap.php b/src/Table/Renderer/Bootstrap.php index dbb945c..83fc16c 100644 --- a/src/Table/Renderer/Bootstrap.php +++ b/src/Table/Renderer/Bootstrap.php @@ -62,7 +62,11 @@ public function table(Table\Table $table) $hasStrainer = false; foreach($table->getColumns() as $column) { /** @var Column\Column $column */ - $head .= html('th', ['class' => 'text-center'], $column->getLabel()); + $label = $column->getLabel(); + if ($column->hasDescription()) { + $label .= ' '; + } + $head .= html('th', ['class' => 'text-center'], $label); $headers[] = $column->getName(); $hasStrainer = $hasStrainer || $column->hasStrainer(); }