-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/translations' into develop
- Loading branch information
Showing
66 changed files
with
997 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\DataGrid\Config; | ||
|
||
/** | ||
* Class DataGridConfiguration | ||
* @package Pfilsx\DataGrid\Config | ||
* @internal | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
protected $template; | ||
|
||
protected $noDataMessage; | ||
|
||
protected $paginationLimit; | ||
|
||
protected $paginationEnabled; | ||
|
||
protected $showTitles; | ||
|
||
protected $translationDomain; | ||
|
||
public function __construct(array $config = []) | ||
{ | ||
foreach ($config as $key => $value) { | ||
$key = str_replace('_', '', $key); | ||
$setter = 'set' . $key; | ||
if (method_exists($this, $setter)) { | ||
$this->$setter($value); | ||
} | ||
} | ||
} | ||
|
||
public function getTemplate(): ?string | ||
{ | ||
return $this->template; | ||
} | ||
|
||
public function setTemplate(string $template): void | ||
{ | ||
$this->template = $template; | ||
} | ||
|
||
public function getNoDataMessage(): ?string | ||
{ | ||
return $this->noDataMessage; | ||
} | ||
|
||
public function setNoDataMessage(string $message): void | ||
{ | ||
$this->noDataMessage = $message; | ||
} | ||
|
||
public function setPaginationEnabled(bool $value): void | ||
{ | ||
$this->paginationEnabled = $value; | ||
} | ||
|
||
public function setPaginationLimit(int $limit): void | ||
{ | ||
$this->paginationLimit = $limit; | ||
} | ||
|
||
public function setShowTitles(bool $showTitles): void | ||
{ | ||
$this->showTitles = $showTitles; | ||
} | ||
|
||
public function setTranslationDomain(?string $domain): void | ||
{ | ||
$this->translationDomain = $domain; | ||
} | ||
|
||
public function getConfigsArray(): array | ||
{ | ||
return [ | ||
'template' => $this->getTemplate(), | ||
'paginationEnabled' => $this->getPaginationEnabled(), | ||
'paginationLimit' => $this->getPaginationLimit(), | ||
'noDataMessage' => $this->getNoDataMessage(), | ||
'showTitles' => $this->getShowTitles(), | ||
'translationDomain' => $this->getTranslationDomain() | ||
]; | ||
} | ||
|
||
public function merge(ConfigurationInterface $configuration): ConfigurationInterface | ||
{ | ||
$result = clone $this; | ||
foreach ($configuration->getConfigsArray() as $key => $value) { | ||
if ($value !== null) { | ||
$setter = 'set' . ucfirst($key); | ||
$result->$setter($value); | ||
} | ||
} | ||
return $result; | ||
} | ||
|
||
public function getPaginationLimit(): ?int | ||
{ | ||
return $this->paginationLimit; | ||
} | ||
|
||
public function getPaginationEnabled(): ?bool | ||
{ | ||
return $this->paginationEnabled; | ||
} | ||
|
||
public function getShowTitles(): ?bool | ||
{ | ||
return $this->showTitles; | ||
} | ||
|
||
public function getTranslationDomain(): ?string | ||
{ | ||
return $this->translationDomain; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\DataGrid\Config; | ||
|
||
|
||
class ConfigurationContainer implements ConfigurationContainerInterface | ||
{ | ||
/** | ||
* @var ConfigurationInterface[] | ||
*/ | ||
private $instances = []; | ||
|
||
public function __construct(array $config) | ||
{ | ||
$this->instances['default'] = new Configuration([ | ||
'template' => '@DataGrid/grid.blocks.html.twig', | ||
'no_data_message' => 'No data found', | ||
'show_titles' => true, | ||
'pagination_enabled' => true, | ||
'pagination_limit' => 10, | ||
'translation_domain' => null | ||
]); | ||
if (!empty($config['instances'])){ | ||
foreach ($config['instances'] as $key => $configuration) { | ||
$this->instances[$key] = new Configuration($configuration); | ||
} | ||
} | ||
} | ||
|
||
public function getInstance(string $name): ConfigurationInterface | ||
{ | ||
return array_key_exists($name, $this->instances) ? $this->instances[$name] : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\DataGrid\Config; | ||
|
||
|
||
interface ConfigurationContainerInterface | ||
{ | ||
public function __construct(array $config); | ||
|
||
public function getInstance(string $name): ConfigurationInterface; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\DataGrid\Config; | ||
|
||
/** | ||
* Interface DataGridConfigurationInterface | ||
* @package Pfilsx\DataGrid\Config | ||
* @internal | ||
*/ | ||
interface ConfigurationInterface | ||
{ | ||
public function __construct(array $config = []); | ||
|
||
public function getTemplate(): ?string; | ||
|
||
public function setTemplate(string $template): void; | ||
|
||
public function getNoDataMessage(): ?string; | ||
|
||
public function setNoDataMessage(string $message): void; | ||
|
||
public function getPaginationLimit(): ?int; | ||
|
||
public function setPaginationLimit(int $limit): void; | ||
|
||
public function getPaginationEnabled(): ?bool; | ||
|
||
public function setPaginationEnabled(bool $value): void; | ||
|
||
public function getShowTitles(): ?bool; | ||
|
||
public function setShowTitles(bool $showTitles): void; | ||
|
||
public function getTranslationDomain(): ?string; | ||
|
||
public function setTranslationDomain(string $domain): void; | ||
|
||
public function getConfigsArray(): array; | ||
|
||
public function merge(ConfigurationInterface $configuration): self; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
|
||
namespace Pfilsx\DataGrid; | ||
|
||
|
||
use Symfony\Bridge\Doctrine\ManagerRegistry; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
|
||
/** | ||
* Class DataGridServiceContainer | ||
* @package Pfilsx\DataGrid | ||
* @internal | ||
*/ | ||
class DataGridServiceContainer | ||
{ | ||
|
||
private $container; | ||
|
||
public function __construct( | ||
ManagerRegistry $doctrine, | ||
RouterInterface $router, | ||
Environment $twig, | ||
RequestStack $requestStack, | ||
TranslatorInterface $translator = null | ||
) | ||
{ | ||
$this->container = [ | ||
'doctrine' => $doctrine, | ||
'router' => $router, | ||
'twig' => $twig, | ||
'request' => $requestStack, | ||
'translator' => $translator | ||
]; | ||
} | ||
|
||
public function get(string $service) | ||
{ | ||
return array_key_exists($service, $this->container) ? $this->container[$service] : null; | ||
} | ||
|
||
|
||
public function getDoctrine(): ManagerRegistry | ||
{ | ||
return $this->container['doctrine']; | ||
} | ||
|
||
public function getRouter(): RouterInterface | ||
{ | ||
return $this->container['router']; | ||
} | ||
|
||
public function getTwig(): Environment | ||
{ | ||
return $this->container['twig']; | ||
} | ||
|
||
public function getRequest(): RequestStack | ||
{ | ||
return $this->container['request']; | ||
} | ||
|
||
public function getTranslator(): ?TranslatorInterface | ||
{ | ||
return $this->container['translator']; | ||
} | ||
} |
Oops, something went wrong.