package.php 804 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. return;
  24. }
  25. // Packages may have a bootstrap file, which commonly is used to register auto-loaders
  26. // and perform other initialization needed to use the package. If the package has a
  27. // bootstrapper, we will require it here.
  28. if ( ! array_key_exists($package, static::$loaded) and file_exists($path = PACKAGE_PATH.$package.'/bootstrap'.EXT))
  29. {
  30. require $path;
  31. }
  32. static::$loaded[] = $package;
  33. }
  34. }