First commit
This commit is contained in:
commit
201edf2e4a
115 changed files with 29451 additions and 0 deletions
71
src/classes/Controllers/Console/DirectoryAdd.php
Normal file
71
src/classes/Controllers/Console/DirectoryAdd.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Directory\Controllers\Console;
|
||||
|
||||
/**
|
||||
* @author Hypolite Petovan <mrpetovan@gmail.com>
|
||||
*/
|
||||
class DirectoryAdd extends \Asika\SimpleConsole\Console
|
||||
{
|
||||
/**
|
||||
* @var \Atlas\Pdo\Connection
|
||||
*/
|
||||
protected $atlas;
|
||||
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
public function __construct(
|
||||
\Atlas\Pdo\Connection $atlas,
|
||||
?array $argv = null
|
||||
)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->atlas = $atlas;
|
||||
}
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
console directory-add - Adds provided directory to queue
|
||||
Usage
|
||||
bin/console directory-add <directory_url> [-h|--help|-?] [-v]
|
||||
|
||||
Description
|
||||
Adds provided directory to queue
|
||||
|
||||
Options
|
||||
-h|--help|-? Show help information
|
||||
-v Show more debug information.
|
||||
HELP;
|
||||
return $help;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if (count($this->args) == 0) {
|
||||
$this->out($this->getHelp());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (count($this->args) > 1) {
|
||||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
$directory_url = $this->getArgument(0);
|
||||
|
||||
$result = $this->atlas->perform('INSERT IGNORE INTO `directory_poll_queue` SET
|
||||
`directory_url` = :directory_url',
|
||||
['directory_url' => $directory_url]
|
||||
);
|
||||
|
||||
if (!$result) {
|
||||
throw new \RuntimeException('Unable to add repository with URL: ' . $directory_url);
|
||||
}
|
||||
|
||||
$this->out('Successfully added the repository to the queue.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue