Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/query/AlmanacInterfaceQuery.php
<?php | <?php | ||||
final class AlmanacInterfaceQuery | final class AlmanacInterfaceQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends AlmanacQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $networkPHIDs; | private $networkPHIDs; | ||||
private $devicePHIDs; | private $devicePHIDs; | ||||
private $addresses; | private $addresses; | ||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
Show All 32 Lines | final class AlmanacInterfaceQuery | ||||
protected function willFilterPage(array $interfaces) { | protected function willFilterPage(array $interfaces) { | ||||
$network_phids = mpull($interfaces, 'getNetworkPHID'); | $network_phids = mpull($interfaces, 'getNetworkPHID'); | ||||
$device_phids = mpull($interfaces, 'getDevicePHID'); | $device_phids = mpull($interfaces, 'getDevicePHID'); | ||||
$networks = id(new AlmanacNetworkQuery()) | $networks = id(new AlmanacNetworkQuery()) | ||||
->setParentQuery($this) | ->setParentQuery($this) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($network_phids) | ->withPHIDs($network_phids) | ||||
->needProperties($this->getNeedProperties()) | |||||
->execute(); | ->execute(); | ||||
$networks = mpull($networks, null, 'getPHID'); | $networks = mpull($networks, null, 'getPHID'); | ||||
$devices = id(new AlmanacDeviceQuery()) | $devices = id(new AlmanacDeviceQuery()) | ||||
->setParentQuery($this) | ->setParentQuery($this) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($device_phids) | ->withPHIDs($device_phids) | ||||
->needProperties($this->getNeedProperties()) | |||||
->execute(); | ->execute(); | ||||
$devices = mpull($devices, null, 'getPHID'); | $devices = mpull($devices, null, 'getPHID'); | ||||
foreach ($interfaces as $key => $interface) { | foreach ($interfaces as $key => $interface) { | ||||
$network = idx($networks, $interface->getNetworkPHID()); | $network = idx($networks, $interface->getNetworkPHID()); | ||||
$device = idx($devices, $interface->getDevicePHID()); | $device = idx($devices, $interface->getDevicePHID()); | ||||
if (!$network || !$device) { | if (!$network || !$device) { | ||||
$this->didRejectResult($interface); | $this->didRejectResult($interface); | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |