mmucklo /
DtcGridBundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Dtc\GridBundle\Grid\Column; |
||
| 4 | |||
| 5 | use Dtc\GridBundle\Grid\Source\GridSourceInterface; |
||
| 6 | use Symfony\Component\Routing\RouterInterface; |
||
|
0 ignored issues
–
show
|
|||
| 7 | |||
| 8 | class ActionGridColumn extends AbstractGridColumn |
||
| 9 | { |
||
| 10 | protected static $spinnerHtml = '<i class="fa fa-circle-o-notch fa-spin dtc-grid-hidden"></i> '; |
||
| 11 | |||
| 12 | protected $actions; |
||
| 13 | protected $idField; |
||
| 14 | |||
| 15 | /** @var RouterInterface */ |
||
| 16 | protected $router; |
||
| 17 | protected $gridSourceId; |
||
| 18 | |||
| 19 | public function __construct($field, array $actions, $idField = 'id') |
||
| 20 | { |
||
| 21 | $this->actions = $actions; |
||
| 22 | $this->idField = $idField; |
||
| 23 | $this->label = 'Actions'; |
||
| 24 | $this->field = $field; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function format($object, GridSourceInterface $gridsource) |
||
| 28 | { |
||
| 29 | $method = 'get'.ucfirst($this->idField); |
||
| 30 | $id = $object->$method(); |
||
| 31 | $idHtml = htmlspecialchars($id); |
||
| 32 | $content = ''; |
||
| 33 | foreach ($this->actions as $action => $options) { |
||
| 34 | $label = $options['label']; |
||
| 35 | if ($content) { |
||
| 36 | $content .= ' '; |
||
| 37 | } |
||
| 38 | $route = isset($options['route']) ? $options['route'] : ''; |
||
| 39 | switch ($options['action']) { |
||
| 40 | case 'show': |
||
| 41 | if (!$route) { |
||
| 42 | $route = 'dtc_grid_show'; |
||
| 43 | } |
||
| 44 | $uri = $this->router->generate($route, ['identifier' => $id, 'id' => $this->gridSourceId]); |
||
| 45 | $uri = htmlspecialchars($uri); |
||
| 46 | $content .= "<button class=\"btn btn-primary grid-show\" data-route=\"$uri\" data-id=\"$idHtml\""; |
||
| 47 | $content .= "onclick=\"dtc_grid_show(this)\">$label</button>"; |
||
| 48 | break; |
||
| 49 | case 'delete': |
||
| 50 | if (!$route) { |
||
| 51 | $route = 'dtc_grid_delete'; |
||
| 52 | } |
||
| 53 | $uri = $this->router->generate($route, ['identifier' => $id, 'id' => $this->gridSourceId]); |
||
| 54 | $uri = htmlspecialchars($uri); |
||
| 55 | $content .= "<button class=\"btn btn-primary grid-delete\" data-route=\"$uri\" data-id=\"$idHtml\""; |
||
| 56 | $content .= 'onclick="dtc_grid_delete(this)">'.static::$spinnerHtml."$label</button>"; |
||
| 57 | break; |
||
| 58 | default: |
||
| 59 | $uri = ''; |
||
| 60 | if ($route) { |
||
| 61 | $uri = $this->router->generate($route, ['identifier' => $id, 'id' => $this->gridSourceId]); |
||
| 62 | $uri = htmlspecialchars($uri); |
||
| 63 | } |
||
| 64 | $content .= '<button class="btn'; |
||
| 65 | if (isset($options['button_class'])) { |
||
| 66 | $content .= ' '.htmlspecialchars($options['button_class']); |
||
| 67 | } |
||
| 68 | $content .= "\" data-route=\"$uri\" data-id=\"$idHtml\""; |
||
| 69 | if (isset($options['onclick'])) { |
||
| 70 | $content .= ' onclick="'.htmlspecialchars($options['onclick']).'"'; |
||
| 71 | } |
||
| 72 | $content .= ">$label</button>"; |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | return $content; |
||
| 77 | } |
||
| 78 | |||
| 79 | public function setRouter(RouterInterface $router) |
||
| 80 | { |
||
| 81 | $this->router = $router; |
||
| 82 | } |
||
| 83 | |||
| 84 | public function setGridSourceId($gridSourceId) |
||
| 85 | { |
||
| 86 | $this->gridSourceId = $gridSourceId; |
||
| 87 | } |
||
| 88 | } |
||
| 89 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths