| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- /* * ********************************************************************
- * ProxmoxAddon product developed. (May 18, 2018)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace MGProvision\Proxmox\v2\repository;
- use \MGProvision\Proxmox\v2\ProxmoxApiException;
- Use \MGProvision\Proxmox\v2\models\Network;
- /**
- * Description of NetworkRepository
- *
- * @author Pawel Kopec <pawelk@modulesgardne.com>
- */
- class NetworkRepository extends AbstractRepository
- {
- protected $path;
- protected $filters = [];
- public function findByPath($path)
- {
- if (!preg_match('/network/', $path))
- {
- throw new ProxmoxApiException(sprintf(__CLASS__ . " path ('%s') is not valid", $path));
- }
- $this->path = $path;
- return $this;
- }
- public function findTypeBridge()
- {
- $this->filters['type'] = 'bridge';
- return $this;
- }
- /**
- *
- * @return Network[]
- * @throws ProxmoxApiException
- */
- public function fetch()
- {
- if ($this->fetch)
- {
- return $this->fetch;
- }
- if (empty($this->path))
- {
- throw new ProxmoxApiException(__CLASS__ . " path is empty");
- }
- $this->fetch = [];
- foreach ($this->api()->get($this->path, $this->filters) as $data)
- {
- $this->fetch[] = (new Network())->setAttributes($data)->setPath($this->path);
- }
- return $this->fetch;
- }
- }
|