3 final class PhortuneMonthYearExpiryControl
extends AphrontFormControl
{
7 public function setMonthInputValue($value) {
8 $this->monthValue
= $value;
11 private function getMonthInputValue() {
12 return $this->monthValue
;
14 private function getCurrentMonth() {
15 return phabricator_format_local_time(
21 public function setYearInputValue($value) {
22 $this->yearValue
= $value;
25 private function getYearInputValue() {
26 return $this->yearValue
;
28 private function getCurrentYear() {
29 return phabricator_format_local_time(
35 protected function getCustomControlClass() {
36 return 'aphront-form-control-text';
39 protected function renderInput() {
40 if (!$this->getUser()) {
41 throw new PhutilInvalidStateException('setUser');
44 // represent months like a credit card does
60 $current_year = $this->getCurrentYear();
61 $years = range($current_year, $current_year +
20);
62 $years = array_fuse($years);
64 if ($this->getMonthInputValue()) {
65 $selected_month = $this->getMonthInputValue();
67 $selected_month = $this->getCurrentMonth();
69 $months_sel = AphrontFormSelectControl
::renderSelectTag(
73 'sigil' => 'month-input',
76 $years_sel = AphrontFormSelectControl
::renderSelectTag(
77 $this->getYearInputValue(),
80 'sigil' => 'year-input',
83 return hsprintf('%s%s', $months_sel, $years_sel);