Repository.php 2.3 KB

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