From 253b6221f7aa81ce3bd585effd34edc8bcb2f53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ku=C4=8Dera?= Date: Tue, 4 Jul 2017 11:36:56 +0200 Subject: [PATCH] use translate macro in template --- src/Datagrid.blocks.latte | 18 +++++++++--------- src/Datagrid.php | 6 ++++++ src/exceptions.php | 5 +++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Datagrid.blocks.latte b/src/Datagrid.blocks.latte index da51d4e..f38ba09 100644 --- a/src/Datagrid.blocks.latte +++ b/src/Datagrid.blocks.latte @@ -88,7 +88,7 @@ {/define} {define row-actions-edit-link} - {$control->translate(nextras.datagrid.edit.label)} + {_}nextras.datagrid.edit.label{/_} {/define} {define row} @@ -160,11 +160,11 @@ {define pagination}
{if $paginator->isFirst()} - « {$control->translate(nextras.datagrid.pagination.first)} - « {$control->translate(nextras.datagrid.pagination.previous)} + « {_}nextras.datagrid.pagination.first{/_} + « {_}nextras.datagrid.pagination.previous{/_} {else} - « {$control->translate(nextras.datagrid.pagination.first)} - « {$control->translate(nextras.datagrid.pagination.previous)} + « {_}nextras.datagrid.pagination.first{/_} + « {_}nextras.datagrid.pagination.previous{/_} {/if} @@ -172,11 +172,11 @@ {if $paginator->isLast()} - {$control->translate(nextras.datagrid.pagination.next)} » - {$control->translate(nextras.datagrid.pagination.last)} » + {_}nextras.datagrid.pagination.next{/_} » + {_}nextras.datagrid.pagination.last{/_} » {else} - {$control->translate(nextras.datagrid.pagination.next)} » - {$control->translate(nextras.datagrid.pagination.last)} » + {_}nextras.datagrid.pagination.next{/_} » + {_}nextras.datagrid.pagination.last{/_} » {/if}
{/define} diff --git a/src/Datagrid.php b/src/Datagrid.php index 3fd3586..9b35a7c 100644 --- a/src/Datagrid.php +++ b/src/Datagrid.php @@ -273,6 +273,10 @@ public function translate($s, $count = null) public function render() { + if (!$this->template instanceof Template) { + throw new LogicException('Template must be instance of ' . Template::class); + } + if ($this->filterFormFactory) { $this['form']['filter']->setDefaults($this->filter); } @@ -288,6 +292,8 @@ public function render() $this->template->showFilterCancel = $this->filterDataSource != $this->filterDefaults; // @ intentionaly $this->template->setFile(__DIR__ . '/Datagrid.latte'); + $this->template->setTranslator($this->translator); + $this->onRender($this); $this->template->render(); } diff --git a/src/exceptions.php b/src/exceptions.php index d33178c..33a9616 100644 --- a/src/exceptions.php +++ b/src/exceptions.php @@ -13,3 +13,8 @@ class InvalidArgumentException extends \InvalidArgumentException { } + + +class LogicException extends \LogicException +{ +}