Skip to content
Snippets Groups Projects
Commit 647bae75 authored by Sebastian Kehr's avatar Sebastian Kehr 🚣🏼 Committed by Dorian Merz
Browse files

refs #16284 [finc] introduce I18nResourcesInjector and FormLabel

merged via diff and patch by "Dorian Merz <merz@ub.uni-leipzig.de>"
parent d717f321
No related merge requests found
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
"require": { "require": {
"finc/rules-evaluator": "0.0.3", "finc/rules-evaluator": "0.0.3",
"sabre/vobject": "3.5.3", "sabre/vobject": "3.5.3",
"symfony/filesystem": "^3.4" "symfony/filesystem": "^3.4",
"zendframework/zend-i18n-resources": "^2.6"
}, },
"scripts": { "scripts": {
"post-install-cmd": ["@copy-themes-force", "@dump-modules"], "post-install-cmd": ["@copy-themes-force", "@dump-modules"],
......
...@@ -16,10 +16,16 @@ $config = [ ...@@ -16,10 +16,16 @@ $config = [
'finc\Cover\Loader' => 'VuFind\Cover\LoaderFactory', 'finc\Cover\Loader' => 'VuFind\Cover\LoaderFactory',
'finc\Cover\Router' => 'finc\Cover\RouterFactory', 'finc\Cover\Router' => 'finc\Cover\RouterFactory',
], ],
'aliases' => [
'MvcTranslator' => 'Zend\Mvc\I18n\Translator',
],
'delegators' => [ 'delegators' => [
'VuFindSearch\Service' => [ 'VuFindSearch\Service' => [
'finc\Service\MungerInjectionDelegatorFactory', 'finc\Service\MungerInjectionDelegatorFactory',
], ],
'Zend\Mvc\I18n\Translator' => [
'finc\I18n\Translator\ZendI18nResourcesInjector',
],
], ],
'aliases' => [ 'aliases' => [
'VuFind\Cache\Manager' => 'finc\Cache\Manager', 'VuFind\Cache\Manager' => 'finc\Cache\Manager',
...@@ -46,6 +52,7 @@ $config = [ ...@@ -46,6 +52,7 @@ $config = [
'VuFind\Controller\MyResearchController' => 'finc\Controller\MyResearchController', 'VuFind\Controller\MyResearchController' => 'finc\Controller\MyResearchController',
'VuFind\Controller\RecordController' => 'finc\Controller\RecordController', 'VuFind\Controller\RecordController' => 'finc\Controller\RecordController',
'VuFind\Controller\RecordsController' => 'finc\Controller\RecordsController', 'VuFind\Controller\RecordsController' => 'finc\Controller\RecordsController',
'VuFind\Controller\AjaxController' => 'finc\Controller\AjaxController',
], ],
], ],
'controller_plugins' => [ 'controller_plugins' => [
...@@ -58,6 +65,14 @@ $config = [ ...@@ -58,6 +65,14 @@ $config = [
'newItems' => 'finc\Controller\Plugin\NewItems' 'newItems' => 'finc\Controller\Plugin\NewItems'
] ]
], ],
'view_helpers' => [
'aliases' => [
'formLabel' => 'finc\Form\View\Helper\FormLabel',
],
'factories' => [
'finc\Form\View\Helper\FormLabel' => 'Zend\ServiceManager\Factory\InvokableFactory',
],
],
'vufind' => [ 'vufind' => [
'plugin_managers' => [ 'plugin_managers' => [
'ajaxhandler' => [ 'ajaxhandler' => [
......
<?php
/**
* Copyright (C) 2020 Leipzig University Library
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
namespace finc\Form\View\Helper;
use Zend\Form\Element;
use Zend\Form\View\Helper\FormLabel as Base;
class FormLabel extends Base
{
public function openTag($element = null)
{
if ($element instanceof Element) {
$element->setLabelAttributes(
[
'data-type' => $element->getAttribute('type'),
'data-name' => $element->getAttribute('name'),
'data-required' => $element->getAttribute('required')
? 'true' : 'false'
] + $element->getLabelAttributes()
);
}
return parent::openTag($element);
}
}
\ No newline at end of file
<?php
/**
* Copyright (C) 2020 Leipzig University Library
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
namespace finc\I18n\Translator;
use Psr\Container\ContainerInterface;
use Zend\I18n\Translator\Resources;
class ZendI18nResourcesInjector
{
public function __invoke(
ContainerInterface $container,
$name,
callable $callback
) {
$translator = call_user_func($callback);
$translator->addTranslationFilePattern(
'phpArray',
Resources::getBasePath(),
Resources::getPatternForValidator()
);
$translator->addTranslationFilePattern(
'phpArray',
Resources::getBasePath(),
Resources::getPatternForCaptcha()
);
return $translator;
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment