public static function BirthdaysBirthday::fromArray in Birthdays 7
Creates a birthday from a database value.
Parameters
$value: An associative array with year, month and day set.
$allow_future: Allow values in the future. Defaults to FALSE.
Return value
A BirthdaysBirthday instance.
Throws
InvalidArgumentException when FALSE is given.
3 calls to BirthdaysBirthday::fromArray()
- BirthdaysBirthdayTestCase::testFromArray in ./
birthdays.test - Tests conversion from array.
- birthdays_field_formatter_view in ./
birthdays.module - Implements hook_field_formatter_view().
- birthdays_mail in ./
birthdays.module - Implements hook_mail().
File
- ./
birthdays_birthday.inc, line 123 - The BirthdaysBirthday class.
Class
- BirthdaysBirthday
- Converts between different data representations and do calculations on a birthday.
Code
public static function fromArray($value, $allow_future = FALSE) {
if (!is_array($value)) {
throw new InvalidArgumentException(t("Must be an array."));
}
if (!isset($value['year'])) {
$value['year'] = 0;
}
if (!isset($value['day']) || !isset($value['month'])) {
throw new InvalidArgumentException(t('Day and month must be set.'));
}
return self::fromDate($value['year'], $value['month'], $value['day'], $allow_future);
}