Created
February 8, 2020 17:40
-
-
Save dersonsena/c892be60179f37d780b1888375a7c2c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Infra\DomainActions; | |
use App\Infra\ActiveRecord\ActiveRecordAbstract; | |
abstract class ActionsAbstract | |
{ | |
/** | |
* @return string | |
*/ | |
abstract public static function getPath(): string; | |
/** | |
* @param ActiveRecordAbstract $model | |
* @param array $options | |
* @return array | |
*/ | |
public static function create(ActiveRecordAbstract $model, array $options = []): array | |
{ | |
return [ | |
'to' => [static::getPath() . '/create'], | |
'text' => 'Novo ' . $model::getEntityDescription(), | |
'htmlOptions' => ($options['htmlOptions'] ?? []) | |
]; | |
} | |
/** | |
* @param ActiveRecordAbstract $model | |
* @param array $options | |
* @return array | |
*/ | |
public static function update(ActiveRecordAbstract $model, array $options = []): array | |
{ | |
return [ | |
'to' => [static::getPath() . '/update/' . $model->id], | |
'text' => 'Editar ' . $model::getEntityDescription(), | |
'htmlOptions' => ($options['htmlOptions'] ?? []) | |
]; | |
} | |
/** | |
* @param ActiveRecordAbstract $model | |
* @param array $options | |
* @return array | |
*/ | |
public static function view(ActiveRecordAbstract $model, array $options = []): array | |
{ | |
return [ | |
'to' => [static::getPath() . '/view/' . $model->id], | |
'text' => 'Ver ' . $model::getEntityDescription(), | |
'htmlOptions' => ($options['htmlOptions'] ?? []) | |
]; | |
} | |
/** | |
* @param ActiveRecordAbstract $model | |
* @param array $options | |
* @return array | |
*/ | |
public static function delete(ActiveRecordAbstract $model, array $options = []): array | |
{ | |
return [ | |
'to' => [static::getPath() . '/delete/' . $model->id], | |
'text' => 'Deletar ' . $model::getEntityDescription(), | |
'htmlOptions' => ($options['htmlOptions'] ?? []) | |
]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Domains\Client; | |
use App\Infra\DomainActions\ActionsAbstract; | |
class ClientActions extends ActionsAbstract | |
{ | |
/** | |
* @inheritDoc | |
*/ | |
public static function getPath(): string | |
{ | |
return '/clients'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment