Repository.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap;
  3. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Interfaces\AbstractApiClient;
  4. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Interfaces\AbstractConnection;
  5. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\Accounts;
  6. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\Ressources;
  7. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
  8. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\Server;
  9. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\DistributionLists;
  10. use ModulesGarden\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\Domains;
  11. use ModulesGarden\Servers\KerioEmail\App\Traits\StorageTrait;
  12. /**
  13. *
  14. * Created by PhpStorm.
  15. * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
  16. * Date: 09.09.19
  17. * Time: 09:37
  18. * Class Repository
  19. * @property ClassOfServices $cos
  20. * @property Domains $domains
  21. * @property Accounts $accounts
  22. * @property DistributionLists $lists
  23. */
  24. class Repository extends AbstractApiClient
  25. {
  26. use StorageTrait;
  27. public function __get($name)
  28. {
  29. $name = strtolower($name);
  30. $exists = $this->getStorage()->exists($name);
  31. if(!$exists && method_exists($this, $name))
  32. {
  33. $action = $this->$name();
  34. $this->getStorage()->set($name, $action);
  35. }elseif(!$exists)
  36. {
  37. }elseif($exists){
  38. $action = $this->getStorage()->get($name);
  39. }else{
  40. throw new \Exception("Repository `{$name}` not found");
  41. }
  42. return $action;
  43. }
  44. /**
  45. * @return Server
  46. */
  47. public function server()
  48. {
  49. return new Server($this->getClient());
  50. }
  51. /**
  52. * @return ClassOfServices
  53. */
  54. public function cos()
  55. {
  56. return new ClassOfServices($this->getClient());
  57. }
  58. /**
  59. * @return Domains
  60. */
  61. public function domains()
  62. {
  63. return new Domains($this->getClient());
  64. }
  65. /**
  66. * @return Accounts
  67. */
  68. public function accounts()
  69. {
  70. return new Accounts($this->getClient());
  71. }
  72. /**
  73. * @return Ressources
  74. */
  75. public function ressources()
  76. {
  77. return new Ressources($this->getClient());
  78. }
  79. /**
  80. *
  81. */
  82. public function lists()
  83. {
  84. return new DistributionLists($this->getClient());
  85. }
  86. }