package.php 727 Bytes
Newer Older
Taylor Otwell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php namespace System;

class Package {

	/**
	 * All of the loaded packages.
	 *
	 * @var array
	 */
	public static $loaded = array();

	/**
	 * Load a package or set of packages.
	 *
15
	 * @param  string|array  $packages
Taylor Otwell committed
16 17
	 * @return void
	 */
18
	public static function load($packages)
Taylor Otwell committed
19
	{
20
		foreach ((array) $packages as $package)
Taylor Otwell committed
21
		{
22
			if ( ! static::loaded($package) and file_exists($bootstrap = PACKAGE_PATH.$package.'/bootstrap'.EXT))
23
			{
24
				require $bootstrap;
25
			}
26

27
			static::$loaded[] = $package;
Taylor Otwell committed
28 29 30
		}
	}

31 32 33 34 35 36 37 38 39 40 41
	/**
	 * Determine if a given package has been loaded.
	 *
	 * @param  string  $package
	 * @return bool
	 */
	public static function loaded($package)
	{
		return array_key_exists($package, static::$loaded);
	}

Taylor Otwell committed
42
}