Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
},
"require": {
"statamic/cms": "dev-master"
"statamic/cms": "^5.41"
},
"require-dev": {
"orchestra/testbench": "^9.6.1 || ^10.0",
Expand Down
23 changes: 19 additions & 4 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Generator
protected $config;
protected $request;
protected $after;
protected $skipAfter;
protected $extraUrls;
protected $workers = 1;
protected $earlyTaskErrors = [];
Expand All @@ -50,6 +51,8 @@ public function __construct(Application $app, Filesystem $files, Router $router,
$this->tasks = $tasks;
$this->extraUrls = collect();
$this->config = $this->initializeConfig();
$this->after = array();
$this->skipAfter = array();
}

private function initializeConfig()
Expand All @@ -70,12 +73,17 @@ public function workers(int $workers)
return $this;
}

public function after($after)
public function after($after, $id = 'unidentified')
{
$this->after = $after;
$this->after[$id] = $after;

return $this;
}

public function skipAfter( string $id )
{
$this->skipAfter[] = $id;
}

public function addUrls($closure)
{
Expand Down Expand Up @@ -107,8 +115,15 @@ public function generate($urls = '*')
->copyFiles()
->outputSummary();

if ($this->after) {
call_user_func($this->after);
if ( count($this->after) > 0 ) {
foreach ($this->after as $id => $after) {
if (in_array($id, $this->skipAfter)) {
Partyline::line("<comment>Skipping $id after function...</comment>");
continue;
}
Partyline::line("<info>Calling $id after function...</info>");
call_user_func($after);
}
}
}

Expand Down
Loading