forked from 2bepublished/namespacify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnamespacify.php
58 lines (46 loc) · 1.66 KB
/
namespacify.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/local/php5/bin/php
<?php
/**
* Namespacify Command Line Tool
*
* Adds namespaces to all PHP classes of a given directory.
*
* PHP Version 5.3.10
*
* @category console
* @package namespacify
* @author Florian Eckerstorfer <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License
* @copyright 2012 2bePUBLISHED Internet Services Austria GmbH
*/
define('NAMESPACIFY_VERSION', '0.0.1-dev');
define('NAMESPACIFY_ROOT_DIR', __DIR__);
//
// AUTOLOAD
//
require_once NAMESPACIFY_ROOT_DIR.'/vendor/autoload.php';
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Pub\Namespacify\Application;
use Pub\Namespacify\Command\NamespacifyCommand;
use Pub\Namespacify\DependencyInjection\Compiler\CompilerPass;
$file = NAMESPACIFY_ROOT_DIR .'/cache/container.php';
if (file_exists($file)) {
require_once $file;
$container = new NamespacifyContainerCache();
} else {
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(NAMESPACIFY_ROOT_DIR));
$loader->load(NAMESPACIFY_ROOT_DIR.'/config/services.yml');
$container->compile();
$dumper = new PhpDumper($container);
file_put_contents($file, $dumper->dump(array('class' => 'NamespacifyContainerCache')));
}
$console = new Application("Namespacify", NAMESPACIFY_VERSION);
// Add namespacify command.
$namespacifyCommand = new NamespacifyCommand();
$namespacifyCommand->setContainer($container);
$console->add($namespacifyCommand);
$console->run();