Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.