Files
Chamilo/vendor/knplabs/knp-menu/src/Knp/Menu/Provider/ArrayAccessProvider.php
T
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

47 lines
1.3 KiB
PHP

<?php
namespace Knp\Menu\Provider;
/**
* A menu provider getting the menus from a class implementing ArrayAccess.
*
* In case the value stored in the registry is a callable rather than an ItemInterface,
* it will be called with the options as first argument and the registry as second argument
* and is expected to return a menu item.
*/
class ArrayAccessProvider implements MenuProviderInterface
{
private $registry;
private $menuIds;
/**
* @param \ArrayAccess $registry
* @param array $menuIds The map between menu identifiers and registry keys
*/
public function __construct(\ArrayAccess $registry, array $menuIds = [])
{
$this->registry = $registry;
$this->menuIds = $menuIds;
}
public function get($name, array $options = [])
{
if (!isset($this->menuIds[$name])) {
throw new \InvalidArgumentException(\sprintf('The menu "%s" is not defined.', $name));
}
$menu = $this->registry[$this->menuIds[$name]];
if (\is_callable($menu)) {
$menu = \call_user_func($menu, $options, $this->registry);
}
return $menu;
}
public function has($name, array $options = [])
{
return isset($this->menuIds[$name]);
}
}