Skip to content

Commit

Permalink
Centralize deprecated check
Browse files Browse the repository at this point in the history
  • Loading branch information
nupplaphil committed Jan 5, 2025
1 parent 77c9f54 commit b9dde78
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/Console/AbstractConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ abstract class AbstractConsole extends Console
* @var string
*/
public const LOG_CHANNEL = LogChannel::CONSOLE;

/**
* Checks, if the Console command was executed outside of`bin/console.php` and prints the correct execution
*
* @param string $command the current command
*/
protected function checkDeprecated(string $command): void
{
if (substr($this->executable, -strlen('bin/console.php')) !== 'bin/console.php') {
$this->out(sprintf("'%s' is deprecated and will removed. Please use 'bin/console.php %s' instead", $this->executable, $command));
}
}
}
4 changes: 1 addition & 3 deletions src/Console/Daemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ protected function getHelp(): string

protected function doExecute()
{
if (substr($this->executable, -strlen('bin/console.php')) !== 'bin/console.php') {
$this->out(sprintf("'%s' is deprecated and will removed. Please use 'bin/console.php daemon' instead", $this->executable));
}
$this->checkDeprecated('daemon');

if ($this->mode->isInstall()) {
throw new RuntimeException("Friendica isn't properly installed yet");
Expand Down
4 changes: 1 addition & 3 deletions src/Console/JetstreamDaemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ protected function getHelp(): string

protected function doExecute()
{
if ($this->executable !== 'bin/console.php') {
$this->out(sprintf("'%s' is deprecated and will removed. Please use 'bin/console.php jetstream' instead", $this->executable));
}
$this->checkDeprecated('jetstream');

if ($this->mode->isInstall()) {
throw new RuntimeException("Friendica isn't properly installed yet");
Expand Down
4 changes: 1 addition & 3 deletions src/Console/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ protected function getHelp(): string

protected function doExecute()
{
if ($this->executable !== 'bin/console.php') {
$this->out(sprintf("'%s' is deprecated and will removed. Please use 'bin/console.php worker' instead", $this->executable));
}
$this->checkDeprecated('worker');

$this->mode->setExecutor(Mode::WORKER);

Expand Down

0 comments on commit b9dde78

Please sign in to comment.