diff --git a/DependencyInjection/CompilerPass/MenuCompilerPass.php b/DependencyInjection/CompilerPass/MenuCompilerPass.php index b6b66a755..a8d87d950 100644 --- a/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -36,13 +36,28 @@ class MenuCompilerPass implements CompilerPassInterface . "container.", MenuComposer::class)); } - $menuComposerDefinition = $container->getDefinition('chill.main.menu_composer'); - + $menuComposerDefinition = $container->getDefinition('chill.main.menu_composer'); + + $services = []; foreach ($container->findTaggedServiceIds('chill.menu_builder') as $id => $tags) { - $class = $container->getDefinition($id)->getClass(); + $services[] = [ + 'id' => $id, + 'priority' => $tags[0]['priority'] ?? 100, + ]; + } + + usort($services, function ($a, $b) { + if ($a['priority'] == $b['priority']) { + return 0; + } + return ($a['priority'] < $b['priority']) ? -1 : 1; + }); + + foreach ($services as $service) { + $class = $container->getDefinition($service['id'])->getClass(); foreach ($class::getMenuIds() as $menuId) { $menuComposerDefinition - ->addMethodCall('addLocalMenuBuilder', [new Reference($id), $menuId]); + ->addMethodCall('addLocalMenuBuilder', [new Reference($service['id']), $menuId]); } } } diff --git a/Entity/User.php b/Entity/User.php index d77883200..1a46b30a5 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -100,7 +100,14 @@ class User implements AdvancedUserInterface { * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ private $groupCenters; - + + /** + * Array where SAML attributes's data are stored + * @var array + * + * @ORM\Column(type="json_array", nullable=true) + */ + private $attributes; /** * User constructor. @@ -346,4 +353,31 @@ class User implements AdvancedUserInterface { } } + /** + * Set attributes + * + * @param array $attributes + * + * @return Report + */ + public function setAttributes($attributes) + { + $this->attributes = $attributes; + + return $this; + } + + /** + * Get attributes + * + * @return array + */ + public function getAttributes() + { + if ($this->attributes === null) { + $this->attributes = []; + } + + return $this->attributes; + } } diff --git a/migrations/Version20210304085819.php b/migrations/Version20210304085819.php new file mode 100644 index 000000000..48b54919e --- /dev/null +++ b/migrations/Version20210304085819.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE users ADD attributes JSONB DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN users.attributes IS \'(DC2Type:json_array)\''); + } + + public function down(Schema $schema) : void + { + $this->addSql('ALTER TABLE users DROP attributes'); + } +}