package.php 792 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 $package
  13. * @return void
  14. */
  15. public static function load($package)
  16. {
  17. if (is_array($package))
  18. {
  19. foreach ($package as $value)
  20. {
  21. static::load($value);
  22. }
  23. }
  24. // Packages may have a bootstrap file, which commonly is used to register auto-loaders
  25. // and perform other initialization needed to use the package. If the package has a
  26. // bootstrapper, we will require it here.
  27. if ( ! array_key_exists($package, static::$loaded) and file_exists($path = PACKAGE_PATH.$package.'/bootstrap'.EXT))
  28. {
  29. require $path;
  30. }
  31. static::$loaded[] = $package;
  32. }
  33. }