-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_data.php
68 lines (56 loc) · 2.16 KB
/
load_data.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
59
60
61
62
63
64
65
66
67
68
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$rootDir = __DIR__;
require_once __DIR__.'/app/bootstrap.php.cache';
// reset data
$fs = new \Symfony\Component\Filesystem\Filesystem;
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
// does the parent directory have a parameters.yml file
if (is_file(__DIR__.'/../parameters.demo.yml')) {
$fs->copy(__DIR__.'/../parameters.demo.yml', __DIR__.'/app/config/parameters.yml', true);
}
if (!is_file(__DIR__.'/app/config/parameters.yml')) {
$output->writeln('<error>no default app/config/parameters.yml file</error>');
exit(0);
}
/**
* @param $commands
* @param \Symfony\Component\Console\Output\ConsoleOutput $output
* @return void
*/
function execute_commands($commands, $output)
{
foreach($commands as $command) {
$output->writeln(sprintf('<info>Executing : </info> %s', $command));
$p = new \Symfony\Component\Process\Process($command);
$exit = $p->run(function($type, $data) use ($output) {
$output->write($data);
});
$output->writeln("");
}
}
$output->writeln("<info>Resetting demo</info>");
$fs->remove(sprintf('%s/web/uploads/media', $rootDir));
$fs->mkdir(sprintf('%s/web/uploads/media', $rootDir));
$fs->copy(__DIR__.'/src/Sonata/Bundle/DemoBundle/DataFixtures/data/robots.txt', __DIR__.'/web/robots.txt', true);
execute_commands(array(
'app/console cache:warmup --env=dev',
'app/console cache:create-cache-class --env=dev',
// 'app/console doctrine:database:drop --force',
// 'app/console doctrine:database:create',
'app/console doctrine:schema:update --force',
'app/console doctrine:fixtures:load --verbose',
'app/console sonata:page:update-core-routes --site=all',
'app/console sonata:page:create-snapshots --site=all',
'app/console assets:install --symlink web',
'app/console cache:warmup --env=prod',
'app/console cache:create-cache-class --env=prod',
), $output);
$output->writeln('<info>Done!</info>');