package.php 727 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php namespace System;
  2. class Package {
  3. /**
  4. * All of the loaded packages.
  5. *
  6. * @var array
  7. */
  8. public static $loaded = array();
  9. /**
  10. * Load a package or set of packages.
  11. *
  12. * @param string|array $packages
  13. * @return void
  14. */
  15. public static function load($packages)
  16. {
  17. foreach ((array) $packages as $package)
  18. {
  19. if ( ! static::loaded($package) and file_exists($bootstrap = PACKAGE_PATH.$package.'/bootstrap'.EXT))
  20. {
  21. require $bootstrap;
  22. }
  23. static::$loaded[] = $package;
  24. }
  25. }
  26. /**
  27. * Determine if a given package has been loaded.
  28. *
  29. * @param string $package
  30. * @return bool
  31. */
  32. public static function loaded($package)
  33. {
  34. return array_key_exists($package, static::$loaded);
  35. }
  36. }