Skip to content
Open
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
18 changes: 10 additions & 8 deletions src/BeyondIT/OCOK/CliTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Symfony\Component\Console\Input\InputOption;

class CliTaskCommand extends OCOKCommand {

public function supportedVersions() {
return array('2','1.5');
}

protected function configure() {
$this->setName("run")
->setDescription("Run OpenCart controllers as tasks from commandline")
Expand All @@ -21,25 +21,27 @@ protected function configure() {
->addArgument("route", InputArgument::REQUIRED, "Set the route for the Task Controller")
->addArgument("args", InputArgument::IS_ARRAY, "Custom arguments, which are set as GET or POST (-p option) parameters for the controller script. Added as key/value pairs (e.g. key=value)");
}

protected function execute(InputInterface $input, OutputInterface $output) {
if (parent::execute($input, $output)) {

if (!$input->getOption("catalog")) {
chdir('admin');
chdir('admin');
}

foreach ($input->getArgument("args") as $arg) {
$pair = explode("=", $arg);
if (count($pair) === 2) {
if ($input->getOption("post")) {
$_POST[$pair[0]] = $pair[1];
} else {
$_GET[$pair[0]] = $pair[1];
}
}
}
}

$_SERVER['REQUEST_URI'] = '/';

ob_start();
require_once $this->getOCDirectory() . DIRECTORY_SEPARATOR . "index.php";
ob_end_clean();
Expand All @@ -52,5 +54,5 @@ protected function execute(InputInterface $input, OutputInterface $output) {


}
}
}
}