<commit_before><?php namespace SolarPhase\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

use SolarPhase\Website\Link;

abstract class Controller extends BaseController {

	use DispatchesCommands, ValidatesRequests;

	/**
	 * Creates a new controller instance.
	 */
	public function __construct()
	{
		view()->share('title', '');
		view()->share('active_links', []);
		view()->share(
			'navigation_links',
			Link::onlyParents()
				->orderBy('order', 'desc')
				->with('children')
				->get()
		);
	}

	/**
	 * Sets the title for the request.
	 *
	 * @param string $title
	 */
	public function setTitle($title)
	{
		view()->share('title', $title);
	}

	/**
	 * Traverses the specified link and populates the active link stack with the
	 * appropriate link ids.
	 *
	 * @param Link $link
	 * @param array $active_links
	 */
	public function setActiveLink(Link $link, $active_links = [])
	{
		array_push($active_links, $link->id);
		if ($link->parent) {
			return $this->setActiveLink($link->parent, $active_links);
		}

		view()->share('active_links', $active_links);
	}

}
<commit_msg>Added flash message functionality to the base controller.<commit_after><?php namespace SolarPhase\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

use SolarPhase\Website\Link;

abstract class Controller extends BaseController {

	use DispatchesCommands, ValidatesRequests;

	/**
	 * Creates a new controller instance.
	 */
	public function __construct()
	{
		view()->share('title', '');
		view()->share('active_links', []);
		view()->share(
			'navigation_links',
			Link::onlyParents()
				->orderBy('order', 'desc')
				->with('children')
				->get()
		);
	}

	/**
	 * Sets the title for the request.
	 *
	 * @param string $title
	 */
	public function setTitle($title)
	{
		view()->share('title', $title);
	}

	/**
	 * Traverses the specified link and populates the active link stack with the
	 * appropriate link ids.
	 *
	 * @param Link $link
	 * @param array $active_links
	 */
	public function setActiveLink(Link $link, $active_links = [])
	{
		array_push($active_links, $link->id);
		if ($link->parent) {
			return $this->setActiveLink($link->parent, $active_links);
		}

		view()->share('active_links', $active_links);
	}

	/**
	 * Puts a message in the flash session to be displayed on the next request.
	 *
	 * @param string $type
	 * @param string $text
	 */
	public function flashMessage($type, $text)
	{
		session()->flash('message', [
			'type' => $type,
			'text' => $text,
		]);
	}

}

{'fraction_non_alphanumeric': 0.14981818181818182, 'fraction_numerical': 0.0, 'mean_word_length': 4.0109289617486334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '4804925', 'n_tokens_mistral': 923, 'n_tokens_neox': 852, 'n_words': 210}