API improvements (#5494)
* hide logo in docs UI * always return a user in api base controller * added example for duration fields
This commit is contained in:
@@ -20,15 +20,22 @@ use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormTypeInterface;
|
||||
|
||||
/**
|
||||
* @method null|User getUser()
|
||||
*/
|
||||
abstract class BaseApiController extends AbstractController
|
||||
{
|
||||
public const DATE_ONLY_FORMAT = 'yyyy-MM-dd';
|
||||
public const DATE_FORMAT = DateTimeType::HTML5_FORMAT;
|
||||
public const DATE_FORMAT_PHP = 'Y-m-d\TH:i:s';
|
||||
|
||||
protected function getUser(): User
|
||||
{
|
||||
$user = parent::getUser();
|
||||
if (!$user instanceof User) {
|
||||
throw $this->createAccessDeniedException('Need a user for API access');
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TFormType of FormTypeInterface<TData>
|
||||
* @template TData of BaseQuery
|
||||
|
||||
Reference in New Issue
Block a user