Differential D21628 Diff 51485 src/applications/almanac/engineextension/AlmanacBindingsSearchEngineAttachment.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/engineextension/AlmanacBindingsSearchEngineAttachment.php
<?php | <?php | ||||
final class AlmanacBindingsSearchEngineAttachment | final class AlmanacBindingsSearchEngineAttachment | ||||
extends AlmanacSearchEngineAttachment { | extends AlmanacSearchEngineAttachment { | ||||
private $isActive; | |||||
public function setIsActive($is_active) { | |||||
$this->isActive = $is_active; | |||||
return $this; | |||||
} | |||||
public function getIsActive() { | |||||
return $this->isActive; | |||||
} | |||||
public function getAttachmentName() { | public function getAttachmentName() { | ||||
return pht('Almanac Bindings'); | return pht('Almanac Bindings'); | ||||
} | } | ||||
public function getAttachmentDescription() { | public function getAttachmentDescription() { | ||||
return pht('Get Almanac bindings for the service.'); | return pht('Get Almanac bindings for the service.'); | ||||
} | } | ||||
public function willLoadAttachmentData($query, $spec) { | public function willLoadAttachmentData($query, $spec) { | ||||
$query->needProperties(true); | $query->needProperties(true); | ||||
if ($this->getIsActive()) { | |||||
$query->needBindings(true); | $query->needBindings(true); | ||||
} else { | |||||
$query->needActiveBindings(true); | |||||
} | |||||
} | } | ||||
public function getAttachmentForObject($object, $data, $spec) { | public function getAttachmentForObject($object, $data, $spec) { | ||||
$bindings = array(); | $bindings = array(); | ||||
foreach ($object->getBindings() as $binding) { | |||||
if ($this->getIsActive()) { | |||||
$service_bindings = $object->getActiveBindings(); | |||||
} else { | |||||
$service_bindings = $object->getBindings(); | |||||
} | |||||
foreach ($service_bindings as $binding) { | |||||
$bindings[] = $this->getAlmanacBindingDictionary($binding); | $bindings[] = $this->getAlmanacBindingDictionary($binding); | ||||
} | } | ||||
return array( | return array( | ||||
'bindings' => $bindings, | 'bindings' => $bindings, | ||||
); | ); | ||||
} | } | ||||
} | } |