PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/package/app/app/symfony-data/bin/symfony.php

https://bitbucket.org/pandaos/kaltura
PHP | 173 lines | 128 code | 30 blank | 15 comment | 15 complexity | ddb7d8ab323e592ae188b407cdd8b50f MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-2.0, LGPL-3.0, JSON, MPL-2.0-no-copyleft-exception, Apache-2.0
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. if (!isset($sf_symfony_lib_dir))
  10. {
  11. die("You must launch symfony command line with the symfony script\n");
  12. }
  13. if (ini_get('zend.ze1_compatibility_mode'))
  14. {
  15. die("symfony cannot run with zend.ze1_compatibility_mode enabled.\nPlease turn zend.ze1_compatibility_mode to Off in your php.ini.\n");
  16. }
  17. // check if we are using an old project
  18. if (file_exists('config/config.php') && !isset($sf_symfony_lib_dir))
  19. {
  20. // allow only upgrading
  21. if (!in_array('upgrade', $argv))
  22. {
  23. echo "Please upgrade your project before launching any other symfony task\n";
  24. exit();
  25. }
  26. }
  27. require_once($sf_symfony_lib_dir.'/vendor/pake/pakeFunction.php');
  28. require_once($sf_symfony_lib_dir.'/vendor/pake/pakeGetopt.class.php');
  29. // autoloading for pake tasks
  30. class simpleAutoloader
  31. {
  32. static public
  33. $class_paths = array(),
  34. $autoload_callables = array();
  35. static public function initialize($sf_symfony_lib_dir)
  36. {
  37. self::$class_paths = array();
  38. self::register($sf_symfony_lib_dir, '.class.php');
  39. self::register($sf_symfony_lib_dir.'/vendor/propel', '.php');
  40. self::register($sf_symfony_lib_dir.'/vendor/creole', '.php');
  41. self::register('lib/model', '.php');
  42. self::register('plugins', '.php');
  43. }
  44. static public function __autoload($class)
  45. {
  46. if (!isset(self::$class_paths[$class]))
  47. {
  48. foreach ((array) self::$autoload_callables as $callable)
  49. {
  50. if (call_user_func($callable, $class))
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. require_once(self::$class_paths[$class]);
  58. return true;
  59. }
  60. static public function register($dir, $ext)
  61. {
  62. if (!is_dir($dir))
  63. {
  64. return;
  65. }
  66. foreach (pakeFinder::type('file')->name('*'.$ext)->ignore_version_control()->follow_link()->in($dir) as $file)
  67. {
  68. self::$class_paths[str_replace($ext, '', str_replace('.class', '', basename($file, $ext)))] = $file;
  69. }
  70. }
  71. static public function add($class, $file)
  72. {
  73. if (!is_file($file))
  74. {
  75. return;
  76. }
  77. self::$class_paths[$class] = $file;
  78. }
  79. static public function registerCallable($callable)
  80. {
  81. if (!is_callable($callable))
  82. {
  83. throw new Exception('Autoload callable does not exist');
  84. }
  85. self::$autoload_callables[] = $callable;
  86. }
  87. }
  88. function __autoload($class)
  89. {
  90. static $initialized = false;
  91. if (!$initialized)
  92. {
  93. simpleAutoloader::initialize(sfConfig::get('sf_symfony_lib_dir'));
  94. $initialized = true;
  95. }
  96. return simpleAutoloader::__autoload($class);
  97. }
  98. // trap -V before pake
  99. if (in_array('-V', $argv) || in_array('--version', $argv))
  100. {
  101. printf("symfony version %s\n", pakeColor::colorize(trim(file_get_contents($sf_symfony_lib_dir.'/VERSION')), 'INFO'));
  102. exit(0);
  103. }
  104. if (count($argv) <= 1)
  105. {
  106. $argv[] = '-T';
  107. }
  108. require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php');
  109. sfConfig::add(array(
  110. 'sf_root_dir' => getcwd(),
  111. 'sf_symfony_lib_dir' => $sf_symfony_lib_dir,
  112. 'sf_symfony_data_dir' => $sf_symfony_data_dir,
  113. ));
  114. // directory layout
  115. include($sf_symfony_data_dir.'/config/constants.php');
  116. // include path
  117. set_include_path(
  118. sfConfig::get('sf_lib_dir').PATH_SEPARATOR.
  119. sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR.
  120. sfConfig::get('sf_model_dir').PATH_SEPARATOR.
  121. sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'vendor'.PATH_SEPARATOR.
  122. get_include_path()
  123. );
  124. // register tasks
  125. $dirs = array(
  126. sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'myPake*.php', // project tasks
  127. sfConfig::get('sf_symfony_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'sfPake*.php', // symfony tasks
  128. sfConfig::get('sf_root_dir').'/plugins/*/data/tasks' => '*.php', // plugin tasks
  129. );
  130. foreach ($dirs as $globDir => $name)
  131. {
  132. if ($dirs = glob($globDir))
  133. {
  134. $tasks = pakeFinder::type('file')->name($name)->in($dirs);
  135. foreach ($tasks as $task)
  136. {
  137. include_once($task);
  138. }
  139. }
  140. }
  141. // run task
  142. pakeApp::get_instance()->run(null, null, false);
  143. exit(0);