| Total Complexity | 10 |
| Total Lines | 80 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class ImageColumn extends DataColumn |
||
| 10 | { |
||
| 11 | |||
| 12 | protected $width = 25; |
||
| 13 | |||
| 14 | protected $height = 25; |
||
| 15 | |||
| 16 | protected $format = 'html'; |
||
| 17 | |||
| 18 | protected $alt; |
||
| 19 | |||
| 20 | protected $emptyValue = '-'; |
||
| 21 | |||
| 22 | public function getCellContent($entity) |
||
| 23 | { |
||
| 24 | $value = (string)$this->getCellValue($entity); |
||
| 25 | if (!empty($value)) { |
||
| 26 | if ($this->format === 'html') { |
||
| 27 | return $this->template->renderBlock('grid_img', [ |
||
| 28 | 'src' => $value, |
||
| 29 | 'width' => $this->width, |
||
| 30 | 'height' => $this->height, |
||
| 31 | 'alt' => $this->getAlt($entity) |
||
| 32 | ]); |
||
| 33 | } |
||
| 34 | return htmlspecialchars($value); |
||
| 35 | } else { |
||
| 36 | return $this->emptyValue; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return int |
||
| 42 | */ |
||
| 43 | public function getWidth(): int |
||
| 44 | { |
||
| 45 | return $this->width; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param int $width |
||
| 50 | */ |
||
| 51 | protected function setWidth(int $width): void |
||
| 52 | { |
||
| 53 | $this->width = $width; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return int |
||
| 58 | */ |
||
| 59 | public function getHeight(): int |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param int $height |
||
| 66 | */ |
||
| 67 | protected function setHeight(int $height): void |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param $entity |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | public function getAlt($entity): string |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param callable $alt |
||
| 85 | */ |
||
| 86 | protected function setAlt(callable $alt): void |
||
| 89 | } |
||
| 90 | } |
||
| 91 |