package.php 689 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 (file_exists($bootstrap = PACKAGE_PATH.$package.'/bootstrap'.EXT)) require_once $bootstrap;
  20. static::$loaded[] = $package;
  21. }
  22. }
  23. /**
  24. * Determine if a given package has been loaded.
  25. *
  26. * @param string $package
  27. * @return bool
  28. */
  29. public static function loaded($package)
  30. {
  31. return array_key_exists($package, static::$loaded);
  32. }
  33. }