<?php

use MintyPHP\Router;
use MintyPHP\Service\Access\PermissionService;
use MintyPHP\Service\AddressBook\AddressBookServicesFactory;
use MintyPHP\Support\Guard;

Guard::requireLogin();
Guard::requirePermissionOrForbidden(PermissionService::ADDRESS_BOOK_VIEW);

$currentUserId = (int) ($_SESSION['user']['id'] ?? 0);
$addressBookService = (new AddressBookServicesFactory())->createAddressBookService();
Router::json($addressBookService->buildGridResult($currentUserId, $_GET));
