<commit_before><?php

namespace Plumillon\MenuManager;

use Pimple\Container;
use Plumillon\MenuManager\MenuManager\Item;
use Plumillon\MenuManager\MenuManager\Menu;

class MenuManager {
	protected $app;
	protected $config = [];
	protected $menuList = [];
	protected $activeItemList = [];

	public function __construct(Container $app, $config) {
		$this->app = $app;
		$this->config = $config;
		
		foreach($config as $menuConfig)
			$this->menuList[] = new Menu($app, $menuConfig);
	}

	public function load($name = 'main', Item $item = null, $paramList = [], $activeOnly = false) {
		if($item != null)
			$menu = $this->findMenu($item->getSubList(), $name);
		else {
			foreach($this->activeItemList as $item) {
				$menu = $this->findMenu($item->getSubList(), $name);
				
				if($menu != null)
					break;
			}
			
			if($menu == null && !$activeOnly)
				$menu = $this->findMenu($this->menuList, $name);
		}
		
		/*
		 * // Be paranoid, menus should already be there
		 * if($menu == null) {
		 * $config = $this->findConfig($this->config, $name);
		 *
		 * if($config == null)
		 * throw new MenuManagerException('No ' . $name . ' menu config found');
		 *
		 * $config['params'] = $paramList;
		 * $menu = new Menu($this->app, $config);
		 * $this->menuList[] = $menu;
		 * } else
		 *
		 */
		
		if($menu != null) {<commit_msg>Fix notice<commit_after><?php

namespace Plumillon\MenuManager;

use Pimple\Container;
use Plumillon\MenuManager\MenuManager\Item;
use Plumillon\MenuManager\MenuManager\Menu;

class MenuManager {
	protected $app;
	protected $config = [];
	protected $menuList = [];
	protected $activeItemList = [];

	public function __construct(Container $app, $config) {
		$this->app = $app;
		$this->config = $config;
		
		foreach($config as $menuConfig)
			$this->menuList[] = new Menu($app, $menuConfig);
	}

	public function load($name = 'main', Item $item = null, $paramList = [], $activeOnly = false) {
		$menu = null;

		if($item != null)
			$menu = $this->findMenu($item->getSubList(), $name);
		else {
			foreach($this->activeItemList as $item) {
				$menu = $this->findMenu($item->getSubList(), $name);
				
				if($menu != null)
					break;
			}
			
			if($menu == null && !$activeOnly)
				$menu = $this->findMenu($this->menuList, $name);
		}
		
		/*
		 * // Be paranoid, menus should already be there
		 * if($menu == null) {
		 * $config = $this->findConfig($this->config, $name);
		 *
		 * if($config == null)
		 * throw new MenuManagerException('No ' . $name . ' menu config found');
		 *
		 * $config['params'] = $paramList;
		 * $menu = new Menu($this->app, $config);
		 * $this->menuList[] = $menu;
		 * } else
		 *
		 */
		
		if($menu != null) {
{'fraction_non_alphanumeric': 0.18517138599105812, 'fraction_numerical': 0.0, 'mean_word_length': 3.4161184210526314, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '876240', 'n_tokens_mistral': 1033, 'n_tokens_neox': 874, 'n_words': 199}