1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-09 06:11:01 +01:00
phorge-phorge/src/applications/policy/rule/PhabricatorLunarPhasePolicyRule.php
Joshua Spence cf2eb0dd5f Move some files around
Summary: Move some `PhabricatorPolicyRule` implementations to a subdirectory of the parent application.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14478
2015-11-17 06:26:13 +11:00

54 lines
1.2 KiB
PHP

<?php
final class PhabricatorLunarPhasePolicyRule extends PhabricatorPolicyRule {
const PHASE_FULL = 'full';
const PHASE_NEW = 'new';
const PHASE_WAXING = 'waxing';
const PHASE_WANING = 'waning';
public function getRuleDescription() {
return pht('when the moon');
}
public function applyRule(
PhabricatorUser $viewer,
$value,
PhabricatorPolicyInterface $object) {
$moon = new PhutilLunarPhase(PhabricatorTime::getNow());
switch ($value) {
case 'full':
return $moon->isFull();
case 'new':
return $moon->isNew();
case 'waxing':
return $moon->isWaxing();
case 'waning':
return $moon->isWaning();
default:
return false;
}
}
public function getValueControlType() {
return self::CONTROL_TYPE_SELECT;
}
public function getValueControlTemplate() {
return array(
'options' => array(
self::PHASE_FULL => pht('is full'),
self::PHASE_NEW => pht('is new'),
self::PHASE_WAXING => pht('is waxing'),
self::PHASE_WANING => pht('is waning'),
),
);
}
public function getRuleOrder() {
return 1000;
}
}