<?php

namespace Plummer\Calendar;

class CalendarFactory
{
	public static function fromRegistry(CalendarAbstract $calendar, RegistryInterface $eventsRegistry, RegistryInterface $recurrencesRegistry)
	{
		$calendar->addEvents($eventsRegistry->getAll());
		$calendar->addRecurrenceTypes($recurrencesRegistry->getAll());

		return $calendar;
	}
}
<?php

namespace Plummer\Calendar;

class CalendarFactory
{
	public static function fromRegistry(CalendarAbstract $calendar, RegistryInterface $eventsRegistry, RegistryInterface $recurrencesRegistry)
	{
		$events = $eventsRegistry->hasFilters() ?
			$eventsRegistry->getFiltered() :
			$eventsRegistry->getAll();

		$recurrences = $recurrencesRegistry->hasFilters() ?
			$recurrencesRegistry->getFiltered() :
			$recurrencesRegistry->getAll();

		$calendar->addEvents($events);
		$calendar->addRecurrenceTypes($recurrences);

		return $calendar;
	}
}
Check whether to retrieve all items or filter them based on params.
Check whether to retrieve all items or filter them based on params.
