Last active
August 25, 2020 07:05
-
-
Save thiagocordeiro/e754ea346431435936dbd480d5a4cd90 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class BaseController | |
{ | |
public function __contruct(Foo $foo) | |
{ | |
$this->foo = $foo; | |
} | |
} | |
class UserController extends BaseController | |
{ | |
public function __contruct(Foo $foo, Bar $bar) | |
{ | |
$this->bar = $bar; | |
$this->user = $this->loadFromSession(); | |
parent::__construct($foo); | |
} | |
protected function loadFromSession(): User { ... } | |
protected function hasPermissionTo(string $action): bool { ... } | |
} | |
class ScheduleAppointmentController extends UserController | |
{ | |
public function __contruct(AppointmentService $service, Foo $foo, Bar $bar) | |
{ | |
$this->service = $service; | |
parent::__construct($foo, $bar); | |
} | |
public function __invoke(): Response | |
{ | |
if (false === $this->hasPermissionTo(self::class)) { | |
throw new HttpException(Response::HTTP_FORBIDDEN); | |
} | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment