/** * {@inheritdoc} */ public function process() { $msg = 'Processing workflow'; if ($this->workflow instanceof Workflow and $name = $this->workflow->getName()) { $msg .= ': ' . $name; } $this->climate->write($msg . "\n"); $result = $this->workflow->process(); $this->climate->info('Time elapsed: ' . $result->getElapsed()->format('%i minute(s) %s second(s)')); $this->climate->info('Total processed: ' . $result->getTotalProcessedCount() . ' row(s)'); if ($errorCount = $result->getErrorCount() > 0) { $this->climate->error('Errors: ' . $errorCount); } return $result; }
/** * Creates sample ini file. */ protected function createSampleIniFile() { $data = "; NOTE: If non-alphanumeric characters are present, enclose in value in quotes.\n\n[staging]\n quickmode = ftp://example:password@production-example.com:21/path/to/installation\n\n[production]\n scheme = sftp\n user = example\n pass = password\n host = staging-example.com\n path = /path/to/installation\n port = 22"; if (file_put_contents(getcwd() . DIRECTORY_SEPARATOR . 'phploy.ini', $data)) { $this->cli->info("\nSample phploy.ini file created.\n"); } }
/** * Cli method * * @param CLImate $climate * * @throws \Rad\Core\Exception\MissingBundleException */ public function cliMethod(CLImate $climate) { $sqlDir = VAR_DIR . DS . 'cake_orm' . DS . 'sql'; if (!is_dir($sqlDir)) { mkdir($sqlDir, 0777, true); } $sql = []; foreach (Bundles::getLoaded() as $bundle) { $climate->backgroundLightGray()->info(sprintf('Bundle %s ...', $bundle)); $path = Bundles::getPath($bundle); $sqlFilename = Inflection::underscore($bundle) . '.sql'; $schemaPath = $path . DS . 'Resource' . DS . 'config' . DS . 'schema.xml'; if (!is_file($schemaPath)) { $climate->lightRed(sprintf('File "%s" does not exists.', $schemaPath)); $climate->br(2); continue; } $domDocument = new DOMDocument(); $domDocument->load($schemaPath); $xpath = new DOMXPath($domDocument); $tables = $xpath->query('/database/table'); /** @var DOMElement $table */ foreach ($tables as $table) { $schemaTable = new Table($table->getAttribute('name')); $this->prepareTableRegistry($table, $bundle); $this->prepareColumn($table, $xpath, $schemaTable); $this->prepareForeignConstraint($table, $xpath, $schemaTable); $this->prepareUniqueConstraint($table, $xpath, $schemaTable); $this->preparePrimaryConstraint($table, $xpath, $schemaTable); $this->prepareIndex($table, $xpath, $schemaTable); $sql[$sqlDir . DS . $sqlFilename][] = $schemaTable->createSql(ConnectionManager::get('default')); } foreach ($sql as $file => $tablesSql) { $tmpSql = ''; foreach ($tablesSql as $tableSql) { $tmpSql .= implode(";\n", $tableSql); $tmpSql .= "\n\n"; } file_put_contents($file, $tmpSql); $climate->lightGray(sprintf('Create SQL file "%s".', $file)); } $sql = []; $climate->info('Dump table registry config ...'); $this->dumpTableRegistry($climate, $bundle); $climate->info('Dump model classes ...'); $this->dumpModelClasses($climate, $bundle); $climate->br(2); } }
/** * Receives the messages and pass them to sender */ public function handle() { $this->channel->basic_consume($this->listenQueue, '', false, true, false, false, function ($msg) { $this->climate->br(); $this->climate->info('Received: ' . $msg->body); $input = json_decode($msg->body, true); try { $output = $this->interestCalculator->caculateInterest($input); $output['token'] = $this->token; $output = json_encode($output); $this->climate->out('Sending back: ' . $output); $this->channel->basic_publish($this->amqpFactory->buildMessage($output), '', $this->broadcastQueue); } catch (Exception $e) { $this->climate->error('Unable to handle the message: ' . $e->getMessage()); return false; } return true; }); while (count($this->channel->callbacks)) { $this->channel->wait(); } $this->channel->close(); $this->connection->close(); }