Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/ObjectReadCommand.php
- This file was added.
<?php | |||||
namespace App\Console\Commands; | |||||
use App\Console\Command; | |||||
abstract class ObjectReadCommand extends Command | |||||
{ | |||||
/** | |||||
* The name and signature of the console command. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $signature; | |||||
/** | |||||
* The console command description. | |||||
* | |||||
* @var string | |||||
*/ | |||||
protected $description; | |||||
protected $objectClass; | |||||
protected $objectName; | |||||
protected $objectTitle; | |||||
public function __construct() | |||||
{ | |||||
$this->description = "Read a {$this->objectName}"; | |||||
$this->signature = sprintf( | |||||
"%s:read {%s}", | |||||
$this->objectName, | |||||
$this->objectName | |||||
); | |||||
parent::__construct(); | |||||
} | |||||
/** | |||||
* Execute the console command. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function handle() | |||||
{ | |||||
$argument = $this->argument($this->objectName); | |||||
$object = $this->getObject($this->objectClass, $argument, $this->objectTitle); | |||||
if (!$object) { | |||||
return 1; | |||||
} | |||||
$this->info(var_export($object->toArray(), true)); | |||||
} | |||||
} |