<?php

final class ProjectCustomField extends PhabricatorProjectCustomField
  implements PhabricatorStandardCustomFieldInterface {

  public function __construct() {
    $proxy = id(new PhabricatorStandardCustomFieldDate())
      ->setFieldKey($this->getFieldKey())
      ->setApplicationField($this)
      ->setFieldConfig(array(
        'name' => $this->getFieldName(),
        'description' => $this->getFieldDescription(),
      ));

    $this->setProxy($proxy);
  }

  public function getStandardCustomFieldNamespace() {
    return 'project';
  }

  // == General field identity stuff
  public function getFieldKey() {
    return 'sprint:startdate';
  }

  public function getFieldName() {
    return 'Sprint Start Date';
  }

  public function getFieldDescription() {
    return 'When a sprint starts';
  }

  public function renderPropertyViewValue(array $handles) {
    if ($this->getProxy()->getFieldValue())
    {
      return parent::renderPropertyViewValue($handles);
    }

    return null;
  }

  // == Search
  public function shouldAppearInApplicationSearch()
  {
    return true;
  }

}