Skip to content

Commit

Permalink
7.4 (apiato#380)
Browse files Browse the repository at this point in the history
update
  • Loading branch information
johannesschobel authored Mar 4, 2018
1 parent b9bfa8d commit e931134
Show file tree
Hide file tree
Showing 51 changed files with 709 additions and 546 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ API_RATE_LIMIT_ENABLED=true
API_RATE_LIMIT_ATTEMPTS=30
API_RATE_LIMIT_EXPIRES=1

API_REQUEST_APPLY_REQUEST_CRITERIA=true

PAGINATION_LIMIT_DEFAULT=10
PAGINATION_SKIP=false

Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
## [Unreleased]

### Added
- Laravel 5.6
- Added the `TinkerServiceProvider` to `core` in order to allow for using `php artisan tinker` from the console.
- Added a `PaymentTransaction` in order to log all `Payments`.
- There is a new configuration flag (`apiato.requests.automatically-apply-request-criteria`) to disable automatically
adding the `RequestCriteria` to all `Repository` instances. This is known to cause issues.
- In addition to this config flag, there is a new `addRequestCriteria` and `removeRequestCriteria` function
for `Tasks` and `Actions` (automatically applied via the `HasRequestCriteriaTrait`) that allows adding/removing
the `RequestCriteria` for specific `Repositories`. This can easily be achieved via the `MagicCall` approach! (see the `GetAllUsersAction` for an example!)

### Changed
- Adapted the existing `ChargerTasks` for `Stripe` and `Wepay` in order to follow the `PaymentTransaction` approach.

- Rename `Socialauth` container to `SocialAuth`

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function showLoginPage()
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function logoutAdmin(LogoutRequest $equest)
public function logoutAdmin(LogoutRequest $request)
{
Apiato::call('Authentication@WebLogoutAction');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FindPermissionAction extends Action
* @param \App\Ship\Transporters\DataTransporter $data
*
* @return \App\Containers\Authorization\Models\Permission
* @throws PermissionNotFoundException
*/
public function run(DataTransporter $data): Permission
{
Expand Down
1 change: 1 addition & 0 deletions app/Containers/Authorization/Actions/FindRoleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FindRoleAction extends Action
* @param \App\Ship\Transporters\DataTransporter $data
*
* @return \App\Containers\Authorization\Models\Role
* @throws RoleNotFoundException
*/
public function run(DataTransporter $data): Role
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GetAllPermissionsAction extends Action
*/
public function run()
{
$permissions = Apiato::call('Authorization@GetAllPermissionsTask');
$permissions = Apiato::call('Authorization@GetAllPermissionsTask', [], ['addRequestCriteria']);

return $permissions;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Authorization/Actions/GetAllRolesAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GetAllRolesAction extends Action
*/
public function run()
{
$roles = Apiato::call('Authorization@GetAllRolesTask');
$roles = Apiato::call('Authorization@GetAllRolesTask', [], ['addRequestCriteria']);

return $roles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CreatePermissionTask extends Task
/**
* @var \App\Containers\Authorization\Data\Repositories\PermissionRepository
*/
private $repository;
protected $repository;

/**
* CreatePermissionTask constructor.
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Authorization/Tasks/CreateRoleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CreateRoleTask extends Task
/**
* @var \App\Containers\Authorization\Data\Repositories\RoleRepository
*/
private $repository;
protected $repository;

/**
* CreateRoleTask constructor.
Expand Down
13 changes: 10 additions & 3 deletions app/Containers/Authorization/Tasks/DeleteRoleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\Ship\Exceptions\DeleteResourceFailedException;
use App\Ship\Parents\Tasks\Task;
use Exception;
use Illuminate\Support\Facades\App;

/**
* Class DeleteRoleTask.
Expand All @@ -16,6 +15,14 @@
*/
class DeleteRoleTask extends Task
{

protected $repository;

public function __construct(RoleRepository $repository)
{
$this->repository = $repository;
}

/**
* @param Integer|Role $role
*
Expand All @@ -30,9 +37,9 @@ public function run($role): bool

// delete the record from the roles table.
try {
return App::make(RoleRepository::class)->delete($role);
return $this->repository->delete($role);
}
catch(Exception $exception) {
catch (Exception $exception) {
throw new DeleteResourceFailedException();
}
}
Expand Down
10 changes: 8 additions & 2 deletions app/Containers/Authorization/Tasks/FindPermissionTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Containers\Authorization\Data\Repositories\PermissionRepository;
use App\Containers\Authorization\Models\Permission;
use App\Ship\Parents\Tasks\Task;
use Illuminate\Support\Facades\App;

/**
* Class FindPermissionTask.
Expand All @@ -15,6 +14,13 @@
class FindPermissionTask extends Task
{

protected $repository;

public function __construct(PermissionRepository $repository)
{
$this->repository = $repository;
}

/**
* @param $permissionNameOrId
*
Expand All @@ -24,7 +30,7 @@ public function run($permissionNameOrId): Permission
{
$query = is_numeric($permissionNameOrId) ? ['id' => $permissionNameOrId] : ['name' => $permissionNameOrId];

$permission = App::make(PermissionRepository::class)->findWhere($query)->first();
$permission = $this->repository->findWhere($query)->first();

return $permission;
}
Expand Down
10 changes: 8 additions & 2 deletions app/Containers/Authorization/Tasks/FindRoleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Containers\Authorization\Data\Repositories\RoleRepository;
use App\Containers\Authorization\Models\Role;
use App\Ship\Parents\Tasks\Task;
use Illuminate\Support\Facades\App;

/**
* Class FindRoleTask.
Expand All @@ -15,6 +14,13 @@
class FindRoleTask extends Task
{

protected $repository;

public function __construct(RoleRepository $repository)
{
$this->repository = $repository;
}

/**
* @param $roleNameOrId
*
Expand All @@ -24,7 +30,7 @@ public function run($roleNameOrId): Role
{
$query = is_numeric($roleNameOrId) ? ['id' => $roleNameOrId] : ['name' => $roleNameOrId];

$role = App::make(RoleRepository::class)->findWhere($query)->first();
$role = $this->repository->findWhere($query)->first();

return $role;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GetAllPermissionsTask extends Task
/**
* @var PermissionRepository
*/
private $repository;
protected $repository;

/**
* GetAllPermissionsTask constructor.
Expand Down
4 changes: 2 additions & 2 deletions app/Containers/Authorization/Tasks/GetAllRolesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use App\Ship\Parents\Tasks\Task;

/**
* Class GetAllPermissionsTask.
* Class GetAllRolesTask.
*
* @author Mahmoud Zalt <mahmoud@zalt.me>
*/
class GetAllRolesTask extends Task
{

private $repository;
protected $repository;

public function __construct(RoleRepository $repository)
{
Expand Down
10 changes: 8 additions & 2 deletions app/Containers/Payment/Actions/GetAllPaymentAccountsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ public function run()
{
$user = Apiato::call('Authentication@GetAuthenticatedUserTask');

$paymentAccounts = Apiato::call('Payment@GetAllPaymentAccountsTask', [],
['ordered', ['filterByUser' => [$user]]]);
$paymentAccounts = Apiato::call('Payment@GetAllPaymentAccountsTask',
[],
[
'addRequestCriteria',
'ordered',
['filterByUser' => [$user]]
]
);

return $paymentAccounts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AssignPaymentAccountToUserTask extends Task
* @param string|null $paymentNickName
*
* @return \Illuminate\Database\Eloquent\Model
* @throws CreateResourceFailedException
*/
public function run(AbstractPaymentAccount $account, User $user, string $paymentNickName = null)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Payment/Tasks/DeletePaymentAccountTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class DeletePaymentAccountTask extends Task
{

private $repository;
protected $repository;

public function __construct(PaymentAccountRepository $repository)
{
Expand Down
13 changes: 9 additions & 4 deletions app/Containers/Payment/Tasks/FindPaymentAccountByIdTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\Ship\Exceptions\NotFoundException;
use App\Ship\Parents\Tasks\Task;
use Exception;
use Illuminate\Support\Facades\App;

/**
* Class FindPaymentAccountByIdTask
Expand All @@ -18,17 +17,23 @@
class FindPaymentAccountByIdTask extends Task
{

protected $repository;

public function __construct(PaymentAccountRepository $repository)
{
$this->repository = $repository;
}

/**
* @param $id
*
* @return mixed
* @throws NotFoundException
*/
public function run($id): PaymentAccount
{
$repository = App::make(PaymentAccountRepository::class);

try {
$paymentAccount = $repository->find($id);
$paymentAccount = $this->repository->find($id);
} catch (Exception $exception) {
throw new NotFoundException();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Payment/Tasks/GetAllPaymentAccountsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class GetAllPaymentAccountsTask extends Task
{

private $repository;
protected $repository;

/**
* GetAllPaymentAccountsTask constructor.
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Payment/Tasks/UpdatePaymentAccountTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class UpdatePaymentAccountTask extends Task
{
private $repository;
protected $repository;

public function __construct(PaymentAccountRepository $repository)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Settings/Actions/GetAllSettingsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GetAllSettingsAction extends Action
*/
public function run()
{
$settings = Apiato::call('Settings@GetAllSettingsTask', [], ['ordered']);
$settings = Apiato::call('Settings@GetAllSettingsTask', [], ['addRequestCriteria', 'ordered']);

return $settings;
}
Expand Down
10 changes: 8 additions & 2 deletions app/Containers/Settings/Tasks/CreateSettingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
use App\Ship\Exceptions\CreateResourceFailedException;
use App\Ship\Parents\Tasks\Task;
use Exception;
use Illuminate\Support\Facades\App;

class CreateSettingTask extends Task
{

protected $repository;

public function __construct(SettingRepository $repository)
{
$this->repository = $repository;
}

/**
* @param array $data
*
Expand All @@ -21,7 +27,7 @@ class CreateSettingTask extends Task
public function run(array $data): Setting
{
try {
return App::make(SettingRepository::class)->create($data);
return $this->repository->create($data);
}
catch (Exception $exception) {
throw new CreateResourceFailedException();
Expand Down
10 changes: 8 additions & 2 deletions app/Containers/Settings/Tasks/DeleteSettingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
use App\Ship\Exceptions\DeleteResourceFailedException;
use App\Ship\Parents\Tasks\Task;
use Exception;
use Illuminate\Support\Facades\App;

class DeleteSettingTask extends Task
{

protected $repository;

public function __construct(SettingRepository $repository)
{
$this->repository = $repository;
}

/**
* @param Setting $setting
*
Expand All @@ -21,7 +27,7 @@ class DeleteSettingTask extends Task
public function run(Setting $setting)
{
try {
return App::make(SettingRepository::class)->delete($setting->id);
return $this->repository->delete($setting->id);
}
catch (Exception $exception) {
throw new DeleteResourceFailedException();
Expand Down
2 changes: 1 addition & 1 deletion app/Containers/Settings/Tasks/FindSettingByIdTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class FindSettingByIdTask extends Task
{

private $repository;
protected $repository;

public function __construct(SettingRepository $repository)
{
Expand Down
Loading

0 comments on commit e931134

Please sign in to comment.