Created
March 15, 2016 10:17
-
-
Save bramstroker/8a555759e01c5bd4770d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OpeningPeriodStrategy implements StrategyInterface, TranslatorAwareInterface | |
{ | |
use TranslatorAwareTrait; | |
/** | |
* @param Campsite $campsite | |
* @return Information | |
*/ | |
public function getInformation(Campsite $campsite) | |
{ | |
$periods = $campsite->getPeriodsByType(CampsitePeriodType::OPENING); | |
if (count($periods) <= 0) { | |
return new NullInformation(); | |
} | |
return new Information( | |
$this->getTranslator()->translate('Opening period'), | |
$periods | |
); | |
} | |
public function defaultFormat($value) | |
{ | |
$periods = []; | |
foreach ($value as $period) { | |
$periods[] = $period->getFromDate()->toString('d/m') | |
. ' ' | |
. $this->getTranslator()->translate('until') | |
. ' ' | |
. $period->getToDate()->toString('d/m'); | |
} | |
return implode('<br/>', $periods) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment