Skip to content

Commit

Permalink
Implement GetInfoCommand::getSpecification to make this command usable
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Oct 9, 2020
1 parent 23dba20 commit 2f50c18
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/commands/GetInfoCommand.php
Expand Up @@ -10,10 +10,15 @@

namespace hiapi\commands;

use hiqdev\DataMapper\Query\Specification;
use hiapi\validators\RefValidator;

abstract class GetInfoCommand extends EntityCommand
{
public $id;

public $with;

public function getId()
{
return $this->id;
Expand All @@ -24,6 +29,17 @@ public function rules()
return [
['id', 'integer', 'min' => 1],
['id', 'required'],

['with', 'each', 'rule' => [RefValidator::class]],
];
}

public function getSpecification(): Specification
{
$spec = new Specification();
$spec->where = ['id' => $this->getId()];
$spec->with = $this->with;

return $spec;
}
}

0 comments on commit 2f50c18

Please sign in to comment.