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\IpConfig; /** * Description of IpConfigRepository * * @author Pawel Kopec */ class IpConfigRepository extends AbstractRepository { protected $path; protected $filters=[]; public function findByPath($path) { if (!preg_match('/config/', $path)) { throw new ProxmoxApiException(sprintf("Ipconfigt path ('%s') is not valid", $path)); } $this->path = $path; return $this; } /** * * @return IpConfig[] * @throws ProxmoxApiException */ public function fetch() { if ($this->fetch) { return $this->fetch; } if (empty($this->path)) { throw new ProxmoxApiException("IpConfig path is empty"); } $this->fetch = []; $get = $this->api()->get($this->path); krsort($get); foreach ($get as $id => $config) { if (!preg_match('/ipconfig/', $id)) { continue; } $key = preg_replace("/ipconfig/","", $id); if(isset($this->filters['networkId']) && $key != $this->filters['networkId']){ continue; } $this->fetch[] = new IpConfig($id, $config); } return $this->fetch; } public function findByNetworkId($networkId){ $this->filters['networkId'] = preg_replace("/net/","", $networkId); return $this; } }