Commit 5ce64901 by Julien Jorry

Add Wordpress API KEY to view Global Parameter in ADMIN

parent 65d1d324
...@@ -302,6 +302,8 @@ services: ...@@ -302,6 +302,8 @@ services:
admin.globalparameter.gerer: admin.globalparameter.gerer:
class: App\Admin\GlobalParameterAdmin class: App\Admin\GlobalParameterAdmin
arguments: [~, App\Entity\GlobalParameter, ~] arguments: [~, App\Entity\GlobalParameter, ~]
calls:
- [setTemplate, ['list', 'admin/globalparameter_list.html.twig']]
tags: tags:
- name: sonata.admin - name: sonata.admin
manager_type: orm manager_type: orm
......
...@@ -58,6 +58,7 @@ class AppExtension extends AbstractExtension ...@@ -58,6 +58,7 @@ class AppExtension extends AbstractExtension
new \Twig_SimpleFunction('getAllGroupes', array($this, 'getAllGroupes')), new \Twig_SimpleFunction('getAllGroupes', array($this, 'getAllGroupes')),
new \Twig_SimpleFunction('getAllFlux', array($this, 'getAllFlux')), new \Twig_SimpleFunction('getAllFlux', array($this, 'getAllFlux')),
new \Twig_SimpleFunction('mediaurl', array($this, 'mediaurl')), new \Twig_SimpleFunction('mediaurl', array($this, 'mediaurl')),
new \Twig_SimpleFunction('getWordpressApiKey', array($this, 'getWordpressApiKey')),
new \Twig_SimpleFunction('parameter', function ($name) { new \Twig_SimpleFunction('parameter', function ($name) {
return $this->container->getParameter($name); return $this->container->getParameter($name);
}) })
...@@ -77,6 +78,16 @@ class AppExtension extends AbstractExtension ...@@ -77,6 +78,16 @@ class AppExtension extends AbstractExtension
return json_decode($string, true); return json_decode($string, true);
} }
public function getWordpressApiKey()
{
$users = $this->em->getRepository(User::class)->findByRole('ROLE_API');
if (count($users) <= 0) {
// @TODO :erreur => crée un nouvel utilisateur API si non existant ?
return '';
}
return $users[0]->getApiKey();
}
public function showModalGroupChoice() public function showModalGroupChoice()
{ {
if ($this->security->getUser() != null) { if ($this->security->getUser() != null) {
......
{% extends '@SonataAdmin/CRUD/base_list.html.twig' %}
{% block list_table %}
<div class="col-xs-12 col-md-12" style="margin-bottom: 20px;">
{% if KOH_USE_WORDPRESS != 'false' %}
<strong>WORDPRESS API KEY : </strong> : {{ getWordpressApiKey() }}
{% endif %}
</div>
{{parent()}}
{% endblock list_table %}
\ No newline at end of file
Markdown is supported
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