getElement();
if (! $form instanceof Form) {
return $content;
}
$view = $form->getView();
if ($view === null) {
return $content;
}
$notifications = $this->recurseForm($form);
if (empty($notifications)) {
return $content;
}
$html = '
' . $content;
}
}
/**
* Recurse the given form and return the notifications for it and all of its subforms
*
* @param Form $form The form to recurse
*
* @return array
*/
protected function recurseForm(Form $form)
{
$notifications = $form->getNotifications();
foreach ($form->getSubForms() as $subForm) {
foreach ($this->recurseForm($subForm) as $type => $messages) {
foreach ($messages as $message) {
$notifications[$type][] = $message;
}
}
}
return $notifications;
}
/**
* Return the name for the given notification type
*
* @param int $type
*
* @return string
*
* @throws ProgrammingError In case the given type is invalid
*/
protected function getNotificationTypeName($type)
{
switch ($type) {
case Form::NOTIFICATION_ERROR:
return 'error';
case Form::NOTIFICATION_WARNING:
return 'warning';
case Form::NOTIFICATION_INFO:
return 'info';
default:
throw new ProgrammingError('Invalid notification type "%s" provided', $type);
}
}
}