Info.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Shaarli\Api\Controllers;
  3. use Slim\Http\Request;
  4. use Slim\Http\Response;
  5. /**
  6. * Class Info
  7. *
  8. * REST API Controller: /info
  9. *
  10. * @package Api\Controllers
  11. * @see http://shaarli.github.io/api-documentation/#links-instance-information-get
  12. */
  13. class Info extends ApiController
  14. {
  15. /**
  16. * Service providing various information about Shaarli instance.
  17. *
  18. * @param Request $request Slim request.
  19. * @param Response $response Slim response.
  20. *
  21. * @return Response response.
  22. */
  23. public function getInfo($request, $response)
  24. {
  25. $info = [
  26. 'global_counter' => count($this->linkDb),
  27. 'private_counter' => count_private($this->linkDb),
  28. 'settings' => array(
  29. 'title' => $this->conf->get('general.title', 'Shaarli'),
  30. 'header_link' => $this->conf->get('general.header_link', '?'),
  31. 'timezone' => $this->conf->get('general.timezone', 'UTC'),
  32. 'enabled_plugins' => $this->conf->get('general.enabled_plugins', []),
  33. 'default_private_links' => $this->conf->get('privacy.default_private_links', false),
  34. ),
  35. ];
  36. return $response->withJson($info, 200, $this->jsonStyle);
  37. }
  38. }