Add Basic handling of plugins in admin

This commit is contained in:
Benoît Burnichon
2015-09-03 16:52:29 +02:00
parent c01f3f238f
commit 924f20d19d
8 changed files with 59 additions and 5 deletions

View File

@@ -30,6 +30,21 @@ class PluginsController
]);
}
/**
* @param string $pluginName
* @return Response
*/
public function showAction($pluginName)
{
if (!isset($this->app['plugins'][$pluginName])) {
throw new \InvalidArgumentException('Expects a valid plugin name.');
}
return $this->render('admin/plugins/show.html.twig', [
'plugin' => $this->app['plugins'][$pluginName],
]);
}
/**
* @param string $view
* @param array $parameters

View File

@@ -47,6 +47,10 @@ class Plugins implements ControllerProviderInterface, ServiceProviderInterface
->get('/', 'controller.admin_plugin:indexAction')
->bind('admin_plugins_list');
$controllers
->get('/{pluginName}', 'controller.admin_plugin:showAction')
->bind('admin_plugins_show');
return $controllers;
}
}

View File

@@ -43,6 +43,7 @@ class PluginServiceProvider implements ServiceProviderInterface
$app['plugins.manager'] = $app->share(function (Application $app) {
return new PluginManager($app['plugin.path'], $app['plugins.plugins-validator'], $app['conf']);
});
// All plugins, indexed by their name
$app['plugins'] = $app->share(function () {
return new Pimple();
});

View File

@@ -17,17 +17,21 @@ class BasePluginMetadata implements PluginMetadataInterface
private $version;
/** @var string */
private $iconUrl;
/** @var string */
private $localeTextDomain;
/**
* @param string $name
* @param string $version
* @param string $iconUrl
* @param string $localeTextDomain
*/
public function __construct($name, $version, $iconUrl)
public function __construct($name, $version, $iconUrl, $localeTextDomain)
{
$this->name = $name;
$this->version = $version;
$this->iconUrl = $iconUrl;
$this->localeTextDomain = $localeTextDomain;
}
/**
@@ -53,4 +57,12 @@ class BasePluginMetadata implements PluginMetadataInterface
{
return $this->iconUrl;
}
/**
* @return string
*/
public function getLocaleTextDomain()
{
return $this->localeTextDomain;
}
}

View File

@@ -7,9 +7,12 @@
</div>
<div id="plugin_list">
{% for pluginKey in plugins.keys() %}
{% set plugin = plugins[pluginKey] %}
<div>{{ plugin.name }}</div>
{% for pluginName in plugins.keys() %}
<li>
<a target="right" href="{{ path('admin_plugins_show', {pluginName: pluginName}) }}" class="ajax">
<span>{% trans pluginName plugins[pluginName].localeTextDomain %}</span>
</a>
</li>
{% endfor %}
</div>
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% extends app['request'].isXmlHttpRequest ? "admin/common/ajax_wrap.html.twig" : "admin/common/iframe_wrap.html.twig" %}
{% block content %}
<div class="page-header">
{% set pluginName = plugin.name %}
<h1>{% trans pluginName plugin.localeTextDomain %}</h1>
</div>
{{ block('plugin_about') }}
{% endblock %}
{% block about %}
<h1>{% trans 'admin::plugins: about' %}</h1>
{{ 'admin::plugins: name'|trans }} {{ plugin.name }}
{{ 'admin::plugins: version'|trans }} {{ plugin.version }}
{% endblock %}

View File

@@ -71,7 +71,7 @@
<li>
<a target="right" href="{{ path('admin_plugins_list') }}" class="ajax">
<img src="/skins/admin/plugin.png" />
<img src="/skins/admin/plugins-admin.png" />
<span>{% trans 'admin::plugins: plugins' %}</span>
</a>
</li>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB