Skip to content

Instantly share code, notes, and snippets.

@bramstroker
Created March 15, 2016 10:17
Show Gist options
  • Save bramstroker/8a555759e01c5bd4770d to your computer and use it in GitHub Desktop.
Save bramstroker/8a555759e01c5bd4770d to your computer and use it in GitHub Desktop.
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