human friendly name for bundles (#1491)

This commit is contained in:
Kevin Papst
2020-02-22 22:56:37 +01:00
committed by GitHub
parent 6c7477f1a9
commit 0e507804b1
7 changed files with 52 additions and 41 deletions

View File

@@ -80,23 +80,23 @@ final class PermissionController extends AbstractController
// be careful, the order of the search keys is important!
$permissionOrder = [
new PermissionSection('User', '_user'),
new PermissionSection('User profile (own)', '_own_profile'),
new PermissionSection('User profile (other)', '_other_profile'),
new PermissionSection('Customer (Teamlead)', '_teamlead_customer'),
new PermissionSection('Customer (Team member)', '_team_customer'),
new PermissionSection('Customer (Admin)', '_customer'),
new PermissionSection('Project (Teamlead)', '_teamlead_project'),
new PermissionSection('Project (Team member)', '_team_project'),
new PermissionSection('Project (Admin)', '_project'),
new PermissionSection('Activity', '_activity'),
new PermissionSection('Timesheet (own)', '_own_timesheet'),
new PermissionSection('Timesheet (other)', '_other_timesheet'),
new PermissionSection('Timesheet', '_timesheet'),
new PermissionSection('Export', '_export'),
new PermissionSection('Invoice', '_invoice'),
new PermissionSection('Teams', '_team'),
new PermissionSection('Tags', '_tag'),
new PermissionSection('User profile (other)', '_other_profile'),
new PermissionSection('User profile (own)', '_own_profile'),
new PermissionSection('User', '_user'),
new PermissionSection('Customer (Admin)', '_customer'),
new PermissionSection('Customer (Team member)', '_team_customer'),
new PermissionSection('Customer (Teamlead)', '_teamlead_customer'),
new PermissionSection('Project (Admin)', '_project'),
new PermissionSection('Project (Team member)', '_team_project'),
new PermissionSection('Project (Teamlead)', '_teamlead_project'),
new PermissionSection('Activity', '_activity'),
new PermissionSection('Timesheet', '_timesheet'),
new PermissionSection('Timesheet (other)', '_other_timesheet'),
new PermissionSection('Timesheet (own)', '_own_timesheet'),
];
$event = new PermissionSectionsEvent();
@@ -115,7 +115,7 @@ final class PermissionController extends AbstractController
foreach ($this->manager->getPermissions() as $permission) {
$found = false;
foreach ($event->getSections() as $section) {
foreach (array_reverse($event->getSections()) as $section) {
if ($section->filter($permission)) {
$permissionSorted[$section->getTitle()][] = $permission;
$found = true;

View File

@@ -11,6 +11,10 @@ namespace App\Plugin;
class Plugin
{
/**
* @var string
*/
private $id;
/**
* @var string
*/
@@ -24,60 +28,51 @@ class Plugin
*/
private $metadata;
/**
* @return PluginMetadata
*/
public function getMetadata(): ?PluginMetadata
{
return $this->metadata;
}
/**
* @param PluginMetadata $metadata
* @return Plugin
*/
public function setMetadata(PluginMetadata $metadata)
public function setMetadata(PluginMetadata $metadata): Plugin
{
$this->metadata = $metadata;
return $this;
}
/**
* @return string
*/
public function getPath(): ?string
{
return $this->path;
}
/**
* @param string $path
* @return Plugin
*/
public function setPath(string $path)
public function setPath(string $path): Plugin
{
$this->path = $path;
return $this;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return Plugin
*/
public function setName(string $name)
public function setName(string $name): Plugin
{
$this->name = $name;
return $this;
}
public function getId(): ?string
{
return $this->id;
}
public function setId(string $id): Plugin
{
$this->id = $id;
return $this;
}
}

View File

@@ -71,6 +71,7 @@ class PluginManager
{
$plugin = new Plugin();
$plugin
->setId($bundle->getName())
->setName($bundle->getName())
->setPath($bundle->getPath())
->setMetadata(new PluginMetadata())
@@ -100,6 +101,10 @@ class PluginManager
$homepage = $json['homepage'] ?? Constants::HOMEPAGE . '/store/';
if (array_key_exists('name', $json['extra']['kimai'])) {
$plugin->setName($json['extra']['kimai']['name']);
}
$plugin
->getMetadata()
->setHomepage($homepage)