Skip to content
Snippets Groups Projects
Commit b1f52f8f authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Merge branch 'main' of https://git.unicaen.fr/lib/unicaen/parametre into HEAD

parents 41cf07ad 6809c5cd
No related branches found
No related tags found
No related merge requests found
Pipeline #29825 failed
image: registre.unicaen.fr:5000/unicaen-dev-php7.3-apache #update-satis:
# stage: publish
# script:
# - curl https://gest.unicaen.fr/packagist/update
---
variables:
PROXY_UNICAEN: $HTTPS_PROXY
stages: stages:
- publish - cleanup-runner
- tag_this_branch_if_success
cleanup-runner:
stage: cleanup-runner
script:
- docker system prune -af
cache: services:
key: ${CI_COMMIT_REF_SLUG} - docker:dind
paths:
- vendor/
update-satis: tag_this_branch_if_success:
stage: publish stage: tag_this_branch_if_success
image:
name: docker:dind
script: script:
- curl https://gest.unicaen.fr/packagist/update - echo "Configure PROXY Unicaen" && true
- export http_proxy=$PROXY_UNICAEN
- export https_proxy=$PROXY_UNICAEN
- echo "Installation of packages" && true
- apk update
- apk add git
- apk add php
- git config --global user.email "gitlab-runner@mail.com"
- git config --global user.name "Gitlab runner"
- git clone https://git.unicaen.fr/lib/unicaen/parametre.git
- cd parametre/
- git tag -n $(git describe --tags --abbrev=0)
...@@ -9,6 +9,8 @@ use UnicaenParametre\Form\Parametre\ParametreFormFactory; ...@@ -9,6 +9,8 @@ use UnicaenParametre\Form\Parametre\ParametreFormFactory;
use UnicaenParametre\Provider\Privilege\ParametrePrivileges; use UnicaenParametre\Provider\Privilege\ParametrePrivileges;
use UnicaenParametre\Service\Parametre\ParametreService; use UnicaenParametre\Service\Parametre\ParametreService;
use UnicaenParametre\Service\Parametre\ParametreServiceFactory; use UnicaenParametre\Service\Parametre\ParametreServiceFactory;
use UnicaenParametre\View\Helper\ParametreValueViewHelper;
use UnicaenParametre\View\Helper\ParametreValueViewHelperFactory;
use UnicaenPrivilege\Guard\PrivilegeController; use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal; use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment; use Laminas\Router\Http\Segment;
...@@ -122,6 +124,14 @@ return [ ...@@ -122,6 +124,14 @@ return [
'factories' => [ 'factories' => [
ParametreService::class => ParametreServiceFactory::class, ParametreService::class => ParametreServiceFactory::class,
], ],
] ],
'view_helpers' => [
'factories' => [
ParametreValueViewHelper::class => ParametreValueViewHelperFactory::class,
],
'aliases' => [
'parametreValue' => ParametreValueViewHelper::class,
],
],
]; ];
\ No newline at end of file
...@@ -67,6 +67,23 @@ class ParametreService ...@@ -67,6 +67,23 @@ class ParametreService
return $result; return $result;
} }
/** @return Parametre[] */
public function getParametresByCategorieCode(string $categorieCode, string $champ = 'ordre', string $ordre = 'ASC'): array
{
$qb = $this->createQueryBuilder()
->andWhere('categorie.code = :categorie')
->setParameter('categorie', $categorieCode)
->orderBy('parametre.' . $champ, $ordre);
$result = $qb->getQuery()->getResult();
$dictionnaire = [];
foreach ($result as $item) {
$dictionnaire[$item->getCode()] = $item;
}
return $dictionnaire;
}
public function getParametre(int $id): ?Parametre public function getParametre(int $id): ?Parametre
{ {
$qb = $this->createQueryBuilder() $qb = $this->createQueryBuilder()
......
<?php
namespace UnicaenParametre\View\Helper;
use Laminas\View\Helper\AbstractHelper;
use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait;
class ParametreValueViewHelper extends AbstractHelper
{
use ParametreServiceAwareTrait;
public function __invoke(string $categorieCode, string $parametreCode, array $options = []) : string
{
return "".$this->getParametreService()->getValeurForParametre($categorieCode, $parametreCode);
}
}
\ No newline at end of file
<?php
namespace UnicaenParametre\View\Helper;
use Laminas\View\Helper\AbstractHelper;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenParametre\Service\Parametre\ParametreService;
use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait;
class ParametreValueViewHelperFactory
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container): ParametreValueViewHelper
{
/** @var ParametreService $parametreService */
$parametreService = $container->get(ParametreService::class);
$helper = new ParametreValueViewHelper();
$helper->setParametreService($parametreService);
return $helper;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment