partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

DefaultController.php (2017B)


      1 <?php
      2 
      3 namespace PartKeepr\CoreBundle\Controller;
      4 
      5 use FOS\RestBundle\Controller\Annotations\View;
      6 use FOS\RestBundle\Controller\FOSRestController;
      7 use Sensio\Bundle\FrameworkExtraBundle\Configuration as Routing;
      8 use Symfony\Component\Intl\Intl;
      9 
     10 class DefaultController extends FOSRestController
     11 {
     12     /**
     13      * Returns system status.
     14      *
     15      * @Routing\Route("/api/system_status", defaults={"method" = "get","_format" = "json"})
     16      * @View()
     17      *
     18      * @return array
     19      */
     20     public function getSystemStatusAction()
     21     {
     22         return $this->get('partkeepr_systemservice')->getSystemStatus();
     23     }
     24 
     25     /**
     26      * Returns system information.
     27      *
     28      * @Routing\Route("/api/system_information", defaults={"method" = "get","_format" = "json"})
     29      * @View()
     30      *
     31      * @return array
     32      */
     33     public function getSystemInformationAction()
     34     {
     35         return $this->get('partkeepr_systemservice')->getSystemInformation();
     36     }
     37 
     38     /**
     39      * Returns available disk space.
     40      *
     41      * @Routing\Route("/api/disk_space", defaults={"method" = "get","_format" = "json"})
     42      * @View()
     43      *
     44      * @return array
     45      */
     46     public function getDiskFreeSpaceAction()
     47     {
     48         return [
     49             'disk_total' => $this->get('partkeepr_systemservice')->getTotalDiskSpace(),
     50             'disk_used'  => $this->get('partkeepr_systemservice')->getUsedDiskSpace(),
     51         ];
     52     }
     53 
     54     /**
     55      * Returns the available currencies.
     56      *
     57      * @Routing\Route("/api/currencies", defaults={"method" = "get","_format" = "json"})
     58      * @View()
     59      */
     60     public function getCurrenciesAction()
     61     {
     62         $currencyData = Intl::getCurrencyBundle()->getCurrencyNames();
     63 
     64         $currencies = [];
     65         foreach ($currencyData as $code => $name) {
     66             $currencies[] = [
     67                 "code"   => $code,
     68                 "name"   => $name,
     69                 "symbol" => Intl::getCurrencyBundle()->getCurrencySymbol($code),
     70             ];
     71         }
     72 
     73         return $currencies;
     74     }
     75 }