<?php

final class SemiStructuredObjectTypePHIDSearchField
  extends PhabricatorSearchField {

  private $value;

  public function setValue(string $value) {
    $this->value = $value;
    return $this;
  }

  public function readValueFromRequest(AphrontRequest $request) {
    $id = $request->getURIData('typeid');
    if ($id === null) {
      return null;
    }

    $object_type = SemiStructuredObjectTypeQuery::loadOneById(
      $this->getViewer(),
      $id);
    return array($object_type->getPHID());
  }


  protected function getValueFromRequest(AphrontRequest $request, $key) {
    throw new Exception('Did not expect call');
  }


  protected function getValueForControl() {
    return $this->value;
  }

  protected function newControl() {
    return id(new AphrontFormMarkupControl())
      ->setValue($this->value);
  }


}
