<commit_before><?php

/**
 * @copyright   Copyright (c) 2016 ublaboo <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @package     Ublaboo
 */

namespace Ublaboo\ApiRouter\DI;

use Nette;

class ApiRoutesResolver extends Nette\Object
{

	public function prepandRoutes(Nette\Application\IRouter $router, array $routes)
	{
		$user_routes = [];

		foreach ($router as $key => $route) {
			$user_routes[] = $route;
			unset($router[$key]);
		}

		foreach ($routes as $route) {
			$router[] = $route;
		}

		foreach ($user_routes as $route) {
			$router[] = $route;
		}
	}

}<commit_msg>Walkaround for weird Nette arraylist behaviour<commit_after><?php

/**
 * @copyright   Copyright (c) 2016 ublaboo <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @package     Ublaboo
 */

namespace Ublaboo\ApiRouter\DI;

use Nette;

class ApiRoutesResolver extends Nette\Object
{

	public function prepandRoutes(Nette\Application\IRouter $router, array $routes)
	{
		$user_routes = [];
		$keys = [];

		foreach ($router as $key => $route) {
			$user_routes[] = $route;
			$keys[] = $key;
		}

		foreach (array_reverse($keys) as $key) {
			unset($router[$key]);
		}

		foreach ($routes as $route) {
			$router[] = $route;
		}

		foreach ($user_routes as $route) {
			$router[] = $route;
		}
	}

}
{'fraction_non_alphanumeric': 0.16430817610062892, 'fraction_numerical': 0.006289308176100629, 'mean_word_length': 3.5141843971631204, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4865153', 'n_tokens_mistral': 510, 'n_tokens_neox': 470, 'n_words': 106}