Skip to content

Commit

Permalink
[ISSUE-2] More filters and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Teixeira committed Mar 11, 2013
1 parent 4d04058 commit a87a789
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Having
*/
class HavingRange extends OperatorAbstract
class Having extends OperatorAbstract
{
/**
* @param array $value
Expand Down
24 changes: 12 additions & 12 deletions Grid/GridAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function getData()
foreach ($filters as $filter) {
/** @var \PedroTeixeira\Bundle\GridBundle\Grid\Column $column */
foreach ($this->columns as $column) {
if ($filter['name'] == $column->getIndex() && !empty($filter['value'])) {
if ($filter['name'] == $column->getIndex() && $filter['value'] != '') {
$column->getFilter()->execute($this->getQueryBuilder(), $filter['value']);
}
}
Expand Down Expand Up @@ -281,8 +281,18 @@ public function getData()

$rowColumn = ' ';

// Array
if (array_key_exists($column->getField(), $row)) {

$rowColumn = $row[$column->getField()];

// Array scalar
} else if (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) {

$rowColumn = $row[0][$column->getField()];

// Object
if (method_exists($row, 'get' . ucfirst($column->getField()))) {
} else if (method_exists($row, 'get' . ucfirst($column->getField()))) {

$method = 'get' . ucfirst($column->getField());
$rowColumn = $row->$method();
Expand All @@ -294,16 +304,6 @@ public function getData()
$rowColumn = $row[0]->$method();

// Array
} else if (array_key_exists($column->getField(), $row)) {

$rowColumn = $row[$column->getField()];

// Array scalar
} else if (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) {

$rowColumn = $row[0][$column->getField()];

// Twig
} else if ($column->getTwig()) {

$rowColumn = $this->templating->render(
Expand Down
4 changes: 3 additions & 1 deletion Grid/Render/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class Date extends RenderAbstract
*/
public function render()
{
return $this->getValue()->format($this->getDateFormat());
if ($this->getValue() instanceof \DateTime) {
return $this->getValue()->format($this->getDateFormat());
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions Grid/Render/Url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace PedroTeixeira\Bundle\GridBundle\Grid\Render;

/**
* Render Url
*/
class Url extends RenderAbstract
{
/**
* @return string
*/
public function render()
{
return '<a href="' . $this->getValue() . '" target="_blank">' . $this->getValue() . '</a>';
}
}
21 changes: 21 additions & 0 deletions Grid/Render/YesNo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace PedroTeixeira\Bundle\GridBundle\Grid\Render;

/**
* Render YesNo
*/
class YesNo extends RenderAbstract
{
/**
* @return string
*/
public function render()
{
if ($this->getValue()) {
return '<i class="icon-ok"></i>';
} else {
return '<i class="icon-remove"></i>';
}
}
}

0 comments on commit a87a789

Please sign in to comment.