-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoboFile.php
77 lines (70 loc) · 2.03 KB
/
RoboFile.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
69
70
71
72
73
74
75
76
77
<?php
use Robo\ResultData;
use Robo\Tasks;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
* Custom RoboFile commands for this project.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @class RoboFile
*/
class RoboFile extends Tasks
{
/**
* Placeholder for your own project's commands.
*
* @command drupal-project:custom-command
*
* @return void
*
* @throws \Exception
*/
public function customCommand(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
$io->comment('This is just a placeholder command, please add your own custom commands here. Please edit : ' . __FILE__);
}
/**
* Export default content.
*
* @command drupal-project:export-content
*
* @return \Robo\ResultData
*
* @throws \Exception
*/
public function exportContent(
InputInterface $input,
OutputInterface $output,
array $opts = [
'path' => 'modules/custom/default_content_config',
'entities' => [
'node',
'menu_link_content',
'media',
'redirect',
'user',
'config_pages',
],
]
): ResultData
{
$path = $opts['path'];
$entities = $opts['entities'];
$io = new SymfonyStyle($input, $output);
if (is_dir("web/$path/content")) {
$io->info('Removing existing default content exported.');
$this->_cleanDir("web/$path/content");
}
foreach ($entities as $entity) {
$io->info("Exporting $entity as default content");
$this->_exec("./drush.sh default-content:export-references $entity --folder=$path/content");
}
$io->info("Finished exporting default content to $path/content");
return new ResultData();
}
}