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 */ 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; } }