Skip to content

Commit

Permalink
replaced class name strings with class-name::class (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokspflanze authored and ThaDafinser committed Nov 11, 2016
1 parent 64d436a commit ce1dc5d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/ZfcDatagrid/DataSource/Doctrine2/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function useCustomPaginator()
}

/**
* @return \Doctrine\ORM\Tools\Pagination\Paginator
* @return Doctrine2Paginator|ZfcDatagridPaginator
*/
private function getPaginator()
{
Expand Down
2 changes: 1 addition & 1 deletion src/ZfcDatagrid/DataSource/PhpArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function getSortArrayParameter($sortCondition)

switch (get_class($sortCondition['column']->getType())) {

case 'ZfcDatagrid\Column\Type\Number':
case Column\Type\Number::class:
$numeric = SORT_NUMERIC;
$sortArray[] = $numeric;
break;
Expand Down
8 changes: 4 additions & 4 deletions src/ZfcDatagrid/Renderer/AbstractExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ abstract class AbstractExport extends AbstractRenderer
* @var array
*/
protected $allowedColumnTypes = [
'ZfcDatagrid\Column\Type\DateTime',
'ZfcDatagrid\Column\Type\Number',
'ZfcDatagrid\Column\Type\PhpArray',
'ZfcDatagrid\Column\Type\PhpString',
Column\Type\DateTime::class,
Column\Type\Number::class,
Column\Type\PhpArray::class,
Column\Type\PhpString::class,
];

/**
Expand Down
28 changes: 14 additions & 14 deletions src/ZfcDatagrid/Renderer/BootstrapTable/View/Helper/TableRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __invoke($row, array $cols, AbstractAction $rowClickAction = nul
}

foreach ($cols as $col) {
/* @var $col \ZfcDatagrid\Column\AbstractColumn */
/* @var $col Column\AbstractColumn */

$value = $row[$col->getUniqueId()];

Expand All @@ -111,50 +111,50 @@ public function __invoke($row, array $cols, AbstractAction $rowClickAction = nul

switch (get_class($col->getType())) {

case 'ZfcDatagrid\Column\Type\Number':
case Column\Type\Number::class:
$cssStyles[] = 'text-align: right';
break;

case 'ZfcDatagrid\Column\Type\PhpArray':
case Column\Type\PhpArray::class:
$value = '<pre>'.print_r($value, true).'</pre>';
break;
}

$styles = array_merge($rowStyles, $col->getStyles());
foreach ($styles as $style) {
/* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */
/* @var $style Column\Style\AbstractStyle */
if ($style->isApply($row) === true) {
switch (get_class($style)) {

case 'ZfcDatagrid\Column\Style\Bold':
case Column\Style\Bold::class:
$cssStyles[] = 'font-weight: bold';
break;

case 'ZfcDatagrid\Column\Style\Italic':
case Column\Style\Italic::class:
$cssStyles[] = 'font-style: italic';
break;

case 'ZfcDatagrid\Column\Style\Color':
case Column\Style\Color::class:
$cssStyles[] = 'color: #'.$style->getRgbHexString();
break;

case 'ZfcDatagrid\Column\Style\BackgroundColor':
case Column\Style\BackgroundColor::class:
$cssStyles[] = 'background-color: #'.$style->getRgbHexString();
break;

case 'ZfcDatagrid\Column\Style\Align':
case Column\Style\Align::class:
$cssStyles[] = 'text-align: '.$style->getAlignment();
break;

case 'ZfcDatagrid\Column\Style\Strikethrough':
case Column\Style\Strikethrough::class:
$value = '<s>'.$value.'</s>';
break;

case 'ZfcDatagrid\Column\Style\CSSClass':
case Column\Style\CSSClass::class:
$classes[] = $style->getClass();
break;

case 'ZfcDatagrid\Column\Style\Html':
case Column\Style\Html::class:
// do NOTHING! just pass the HTML!
break;

Expand All @@ -166,10 +166,10 @@ public function __invoke($row, array $cols, AbstractAction $rowClickAction = nul
}

if ($col instanceof Column\Action) {
/* @var $col \ZfcDatagrid\Column\Action */
/* @var $col Column\Action */
$actions = [];
foreach ($col->getActions() as $action) {
/* @var $action \ZfcDatagrid\Column\Action\AbstractAction */
/* @var $action Column\Action\AbstractAction */
if ($action->isDisplayed($row) === true) {
$action->setTitle($this->translate($action->getTitle()));
$actions[] = $action->toHtml($row);
Expand Down
47 changes: 24 additions & 23 deletions src/ZfcDatagrid/Renderer/PHPExcel/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPExcel_Worksheet_PageSetup;
use Zend\Http\Headers;
use Zend\Http\Response\Stream as ResponseStream;
use ZfcDatagrid\Column;
use ZfcDatagrid\Renderer\AbstractExport;

class Renderer extends AbstractExport
Expand Down Expand Up @@ -70,7 +71,7 @@ public function execute()
$xColumn = 0;
$yRow = $optionsRenderer['startRowData'];
foreach ($this->getColumnsToExport() as $col) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
/* @var $column Column\AbstractColumn */
$sheet->setCellValueByColumnAndRow($xColumn, $yRow, $this->translate($col->getLabel()));

$sheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($xColumn))->setWidth($col->getWidth());
Expand All @@ -85,41 +86,41 @@ public function execute()
foreach ($this->getData() as $row) {
$xColumn = 0;
foreach ($this->getColumnsToExport() as $col) {
/* @var $col \ZfcDatagrid\Column\AbstractColumn */
/* @var $col Column\AbstractColumn */

$value = $row[$col->getUniqueId()];
if (is_array($value)) {
$value = implode(PHP_EOL, $value);
}

/* @var $column \ZfcDatagrid\Column\AbstractColumn */
/* @var $column Column\AbstractColumn */
$currentColumn = PHPExcel_Cell::stringFromColumnIndex($xColumn);
$cell = $sheet->getCell($currentColumn.$yRow);

switch (get_class($col->getType())) {

case 'ZfcDatagrid\Column\Type\Number':
case Column\Type\Number::class:
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
break;

case 'ZfcDatagrid\Column\Type\DateTime':
/* @var $dateType \ZfcDatagrid\Column\Type\DateTime */
case Column\Type\DateTime::class:
/* @var $dateType Column\Type\DateTime */
$dateType = $col->getType();

if (! $value instanceof \DateTime && is_scalar($value)) {
$value = \DateTime::createFromFormat($dateType->getSourceDateTimeFormat(), $value);
$value->setTimezone(new \DateTimeZone($dateType->getSourceTimezone()));
}

$value->setTimezone(new \DateTimeZone($dateType->getOutputTimezone()));
$cell->setValue(\PHPExcel_Shared_Date::PHPToExcel($value));

if ($dateType->getOutputPattern()) {
$outputPattern = $dateType->getOutputPattern();
} else {
$outputPattern = \PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME;
}

$cell->$cell->getStyle()
->getNumberFormat()
->setFormatCode($outputPattern);
Expand All @@ -138,25 +139,25 @@ public function execute()
*/
$styles = array_merge($this->getRowStyles(), $col->getStyles());
foreach ($styles as $style) {
/* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */
/* @var $style Column\Style\AbstractStyle */
if ($style->isApply($row) === true) {
switch (get_class($style)) {

case 'ZfcDatagrid\Column\Style\Bold':
case Column\Style\Bold::class:
$columnStyle->getFont()->setBold(true);
break;

case 'ZfcDatagrid\Column\Style\Italic':
case Column\Style\Italic::class:
$columnStyle->getFont()->setItalic(true);
break;

case 'ZfcDatagrid\Column\Style\Color':
case Column\Style\Color::class:
$columnStyle->getFont()
->getColor()
->setRGB($style->getRgbHexString());
break;

case 'ZfcDatagrid\Column\Style\BackgroundColor':
case Column\Style\BackgroundColor::class:
$columnStyle->getFill()->applyFromArray([
'type' => \PHPExcel_Style_Fill::FILL_SOLID,
'color' => [
Expand All @@ -165,18 +166,18 @@ public function execute()
]);
break;

case 'ZfcDatagrid\Column\Style\Align':
case Column\Style\Align::class:
switch ($style->getAlignment()) {
case \ZfcDatagrid\Column\Style\Align::$RIGHT:
case Column\Style\Align::$RIGHT:
$columnStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
break;
case \ZfcDatagrid\Column\Style\Align::$LEFT:
case Column\Style\Align::$LEFT:
$columnStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
break;
case \ZfcDatagrid\Column\Style\Align::$CENTER:
case Column\Style\Align::$CENTER:
$columnStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
break;
case \ZfcDatagrid\Column\Style\Align::$JUSTIFY:
case Column\Style\Align::$JUSTIFY:
$columnStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);
break;
default:
Expand All @@ -186,11 +187,11 @@ public function execute()

break;

case 'ZfcDatagrid\Column\Style\Strikethrough':
case Column\Style\Strikethrough::class:
$columnStyle->getFont()->setStrikethrough(true);
break;

case 'ZfcDatagrid\Column\Style\Html':
case Column\Style\Html::class:
// @todo strip the html?
break;

Expand Down Expand Up @@ -313,7 +314,7 @@ protected function calculateColumnWidth(\PHPExcel_Worksheet $sheet, array $colum

$factor = $paperWidth / 100;
foreach ($columns as $column) {
/* @var $column \ZfcDatagrid\Column\AbstractColumn */
/* @var $column Column\AbstractColumn */
$column->setWidth($column->getWidth() * $factor);
}
}
Expand Down
37 changes: 19 additions & 18 deletions src/ZfcDatagrid/Renderer/TCPDF/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
use Zend\Http\Headers;
use Zend\Http\Response\Stream as ResponseStream;
use ZfcDatagrid\Column\Style;
use ZfcDatagrid\Column\Type;
use ZfcDatagrid\Library\ImageResize;
use ZfcDatagrid\Renderer\AbstractExport;

class Renderer extends AbstractExport
{
protected $allowedColumnTypes = [
'ZfcDatagrid\Column\Type\DateTime',
'ZfcDatagrid\Column\Type\Image',
'ZfcDatagrid\Column\Type\Number',
'ZfcDatagrid\Column\Type\PhpArray',
'ZfcDatagrid\Column\Type\PhpString',
Type\DateTime::class,
Type\Image::class,
Type\Number::class,
Type\PhpArray::class,
Type\PhpString::class,
];

/**
Expand Down Expand Up @@ -225,7 +226,7 @@ protected function getRowHeight(array $row)

switch (get_class($col->getType())) {

case 'ZfcDatagrid\Column\Type\Image':
case Type\Image::class:
// "min" height for such a column
$height = $col->getType()->getResizeHeight() + $contentPadding;
break;
Expand Down Expand Up @@ -345,48 +346,48 @@ protected function printTableRow(array $row, $rowHeight)

$styles = array_merge($this->getRowStyles(), $col->getStyles());
foreach ($styles as $style) {
/* @var $style \ZfcDatagrid\Column\Style\AbstractStyle */
/* @var $style Style\AbstractStyle */
if ($style->isApply($row) === true) {
switch (get_class($style)) {

case 'ZfcDatagrid\Column\Style\Bold':
case Style\Bold::class:
$this->setBold();
break;

case 'ZfcDatagrid\Column\Style\Italic':
case Style\Italic::class:
$this->setItalic();
break;

case 'ZfcDatagrid\Column\Style\Color':
case Style\Color::class:
$this->setColor($style->getRgbArray());
break;

case 'ZfcDatagrid\Column\Style\BackgroundColor':
case Style\BackgroundColor::class:
$this->setBackgroundColor($style->getRgbArray());
$backgroundColor = true;
break;

case 'ZfcDatagrid\Column\Style\Strikethrough':
case Style\Strikethrough::class:
$text = '<del>'.$text.'</del>';
$isHtml = true;
break;

case 'ZfcDatagrid\Column\Style\Html':
case Style\Html::class:
$isHtml = true;
break;

case 'ZfcDatagrid\Column\Style\Align':
case Style\Align::class:
switch ($style->getAlignment()) {
case \ZfcDatagrid\Column\Style\Align::$RIGHT:
case Style\Align::$RIGHT:
$this->setTextAlignment('R');
break;
case \ZfcDatagrid\Column\Style\Align::$LEFT:
case Style\Align::$LEFT:
$this->setTextAlignment('L');
break;
case \ZfcDatagrid\Column\Style\Align::$CENTER:
case Style\Align::$CENTER:
$this->setTextAlignment('C');
break;
case \ZfcDatagrid\Column\Style\Align::$JUSTIFY:
case Style\Align::$JUSTIFY:
$this->setTextAlignment('J');
break;
default:
Expand Down
Loading

0 comments on commit ce1dc5d

Please sign in to comment.