Skip to content

Commit 0ffde4c

Browse files
committed
fix symfony script
1 parent fef9653 commit 0ffde4c

File tree

4 files changed

+82
-130
lines changed

4 files changed

+82
-130
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
]
5151
},
5252
"bin": [
53-
"/data/bin/symfony.php"
53+
"/data/bin/symfony"
5454
],
5555
"require-dev": {
5656
"rector/rector": "^0.11.60"

data/bin/symfony

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,90 @@ if (file_exists('config/config.php'))
1717

1818
if (!isset($sf_symfony_lib_dir))
1919
{
20-
throw new Exception('Unable to find symfony libraries due to missing config $sf_symfony_lib_dir');
20+
throw new \RuntimeException('Unable to find symfony libraries due to missing config $sf_symfony_lib_dir');
2121
}
2222

2323
if (!isset($sf_symfony_data_dir))
2424
{
25-
throw new Exception('Unable to find symfony libraries due to missing config $sf_symfony_data_dir');
25+
throw new \RuntimeException('Unable to find symfony libraries due to missing config $sf_symfony_data_dir');
2626
}
2727

28-
include($sf_symfony_data_dir.'/bin/symfony.php');
28+
if (isset($GLOBALS['_composer_autoload_path'])) {
29+
define('PHPUNIT_COMPOSER_INSTALL', $GLOBALS['_composer_autoload_path']);
30+
31+
unset($GLOBALS['_composer_autoload_path']);
32+
} else {
33+
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
34+
if (file_exists($file)) {
35+
define('PHPUNIT_COMPOSER_INSTALL', $file);
36+
37+
break;
38+
}
39+
}
40+
41+
unset($file);
42+
}
43+
44+
// set magic_quotes_runtime to off
45+
ini_set('magic_quotes_runtime', 'Off');
46+
47+
// force populating $argc and $argv in the case PHP does not automatically create them (fixes #2943)
48+
$argv = $_SERVER['argv'];
49+
$argc = $_SERVER['argc'];
50+
51+
// check if we are using an old project
52+
53+
// trap -V before pake
54+
if (in_array('-V', $argv) || in_array('--version', $argv))
55+
{
56+
printf("symfony version %s\n", pakeColor::colorize(trim(file_get_contents($sf_symfony_lib_dir.'/VERSION')), 'INFO'));
57+
exit(0);
58+
}
59+
60+
if (count($argv) <= 1)
61+
{
62+
$argv[] = '-T';
63+
}
64+
65+
require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php');
66+
67+
sfConfig::add(array(
68+
'sf_root_dir' => getcwd(),
69+
'sf_symfony_lib_dir' => $sf_symfony_lib_dir,
70+
'sf_symfony_data_dir' => $sf_symfony_data_dir,
71+
));
72+
73+
// directory layout
74+
include($sf_symfony_data_dir.'/config/constants.php');
75+
76+
// include path
77+
set_include_path(
78+
sfConfig::get('sf_lib_dir').PATH_SEPARATOR.
79+
sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR.
80+
sfConfig::get('sf_model_dir').PATH_SEPARATOR.
81+
sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'vendor'.PATH_SEPARATOR.
82+
get_include_path()
83+
);
84+
85+
// register tasks
86+
$dirs = array(
87+
sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'myPake*.php', // project tasks
88+
sfConfig::get('sf_symfony_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'sfPake*.php', // symfony tasks
89+
sfConfig::get('sf_root_dir').'/plugins/*/data/tasks' => '*.php', // plugin tasks
90+
);
91+
foreach ($dirs as $globDir => $name)
92+
{
93+
if ($dirs = glob($globDir))
94+
{
95+
$tasks = pakeFinder::type('file')->ignore_version_control()->name($name)->in($dirs);
96+
foreach ($tasks as $task)
97+
{
98+
include_once($task);
99+
}
100+
}
101+
}
102+
103+
// run task
104+
pakeApp::get_instance()->run(null, null, false);
105+
106+
exit(0);

data/bin/symfony.bat

Lines changed: 0 additions & 39 deletions
This file was deleted.

data/bin/symfony.php

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)