Render the notifications as HTML/JavaScript

@param  array $notifications
@return string
351873
public function render(array $notifications)
    {
        $alerts = '';

        foreach ($notifications as $notification) {
            $message = $this->generateMessage($notification);

            $alerts .= "alert('{$message}');\n";
        }

        return $this->renderOutput($alerts);
    }
95737
private function createHtmlByType(array $notifications, $type)
    {
        $html = "<div class='alert-box {$type} radius' data-alert>";
        foreach ($notifications as $notification) {
            $html .= "{$notification}";
            // If it's not the last notification, add a line break for the next one
            if (end($notifications) !== $notification) {
                $html .= "<br />";
            }
        }
        $html .= "<a href='#' class='close'>&times;</a>";
        $html .= "</div>";

        return $html;
    }
627322
public function render(): string
    {
        $toastr = '<script type="text/javascript">'.$this->options().$this->notificationsAsString().'</script>';

        $this->session->forget(self::TOASTR_NOTIFICATIONS);

        return $toastr;
    }
513454
public static function renderMessages() : string {
		$result = '';
		// we need to see if we have postponed messages and render them first
		$postponed = Session::get(['numbers', 'messages']);
		if (!empty($postponed)) {
			Session::set(['numbers', 'messages'], []);
			foreach ($postponed as $k => $v) {
				$result.= \HTML::message(['options' => $v, 'type' => $k]);
			}
		}
		// regular messages
		$messages = Application::get(array('messages'));
		if (!empty($messages)) {
			foreach ($messages as $k => $v) {
				$result.= \HTML::message(['options' => $v, 'type' => $k]);
			}
		}
		return $result;
	}
618285
protected function render(array $versions)
	{
		$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
		<html>
			<head>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
				<title>Joomla Framework pull request log</title>
				</head>
			<body>';

		foreach ($versions as $version)
		{
			// Print the version number.
			$html .= PHP_EOL . '	<h1>' . $version . '</h1>';

			// Print out the labelled version of the changelog first.
			$labelled = $this->getBuffer("$version.labelled");

			if ($labelled)
			{
				foreach ($labelled as $label => $links)
				{
					$html .= PHP_EOL . "<h2>$label</h2>";
					$html .= PHP_EOL . '<ul>';

					foreach ($links as $link)
					{
						$html .= PHP_EOL . "<li>$link</li>";
					}

					$html .= PHP_EOL . '</ul>';
				}
			}

			// Print out the detailed version of the changelog.
			$log = $this->getBuffer("$version.log");
			$html .= PHP_EOL . '<h2>The following pull requests made by community contributors were merged:</h2>';
			$html .= PHP_EOL . '<ol>';

			foreach ($log as $issue)
			{
				$html .= PHP_EOL . "<li>$issue</li>";
			}
			$html .= PHP_EOL . '</ol>';

			// Print out the user-pull statistics.
			$userCount = $this->getBuffer("$version.userCount");
			arsort($userCount);
			$pullCount = $this->getBuffer("$version.pullCount");

			$html .= PHP_EOL . sprintf('<h4>%d pull requests.</h4>', $pullCount);
			$html .= PHP_EOL . '<ol>';

			foreach ($userCount as $user => $count)
			{
				$html .= PHP_EOL . sprintf('<li><a href="https://github.com/%1$s">%1$s</a>: %2$d</li>', $user, $count);
			}
			$html .= PHP_EOL . '	</ol>';

			// Print out the admin-merge statistics.
			$mergedBy = $this->getBuffer("$version.mergedBy");
			arsort($mergedBy);

			$html .= PHP_EOL . '<h4>Merged by:</h4>';
			$html .= PHP_EOL . '<ol>';

			foreach ($mergedBy as $user => $count)
			{
				$html .= PHP_EOL . sprintf('<li><a href="https://github.com/%1$s">%1$s</a>: %2$d</li>', $user, $count);
			}
			$html .= PHP_EOL . '</ol>';
		}

		$html .= PHP_EOL . '</body>';
		$html .= PHP_EOL . '</html>';

		return $html;
	}
768808
public function renderNotificationsPageAction(int $page): Response
    {
        $pagerfanta = new Pagerfanta(
            new NotificationAdapter($this->notificationService)
        );
        $pagerfanta->setMaxPerPage($this->notificationPaginationLimit);
        $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages()));

        $notifications = '';
        foreach ($pagerfanta->getCurrentPageResults() as $notification) {
            if ($this->registry->hasRenderer($notification->type)) {
                $renderer = $this->registry->getRenderer($notification->type);
                $notifications .= $renderer->render($notification);
            }
        }

        $routeGenerator = function ($page) {
            return $this->generateUrl('ezplatform.notifications.render.page', [
                'page' => $page,
            ]);
        };

        $pagination = (new EzPagerfantaView(new EzPagerfantaTemplate($this->translator)))->render($pagerfanta, $routeGenerator);

        return new Response($this->render('@ezdesign/notifications/notifications_modal_body.html.twig', [
            'page' => $page,
            'pagination' => $pagination,
            'notifications' => $notifications,
            'pager' => $pagerfanta,
        ])->getContent());
    }
935054
public function addNotifications(array $notifications)
    {
        foreach ($notifications as $notification) {
            if (in_array($notification, $this->notifications, true)) {
                continue;
            }

            $this->addNotification($notification);
        }
    }
340123
protected function prepareNotification(Notification $notification, $params = array())
    {
        $data = array_filter($notification->toArray());
        // Prevent from duplicating context items
        unset($data['context']);

        $params += array('origin' => php_sapi_name() == 'cli' ? 'cli' : 'http');
        $params += array('reported_at' => new \DateTime());
        $params += array('server' => $this->getServerName());

        $mergedData = array_merge($data, $params);

        $notification->hydrate($mergedData);

        return $notification;
    }
53279
public static function get_notification_html( $notification_details ) {
		$default              = [
			'id'      => '',
			'heading' => '',
			'message' => '',
			'ctas'    => [
				'confirm' => [
					'link' => '#',
					'text' => '',
				],
				'cancel'  => [
					'link' => '#',
					'text' => '',
				],
			],
		];
		$notification_details = wp_parse_args( $notification_details, $default );

		$notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">';

		if ( ! empty( $notification_details['heading'] ) ) {
			$notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) );
		}
		if ( ! empty( $notification_details['message'] ) ) {
			$notification_html .= wp_kses_post( $notification_details['message'] );
		}
		$notification_html .= '<div class="actions">';

		if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) {
			$notification_html .= sprintf(
				'<a href="%s" target="_blank" class=" button button-primary %s" data-confirm="yes" >%s</a>',
				esc_url( $notification_details['ctas']['confirm']['link'] ),
				esc_attr( $notification_details['id'] . '_confirm' ),
				wp_kses_post( $notification_details['ctas']['confirm']['text'] )
			);
		}

		if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) {
			$notification_html .= sprintf(
				'<a href="%s" class=" button %s" data-confirm="no">%s</a>',
				esc_url( $notification_details['ctas']['cancel']['link'] ),
				esc_attr( $notification_details['id'] ) . '_cancel',
				wp_kses_post( $notification_details['ctas']['cancel']['text'] )
			);
		}

		$notification_html .= '</div>';
		$notification_html .= '	</div>';
		$notification_html .= '	</div>';

		return $notification_html;
	}
1100729
public function withNotification($notification)
    {
        $notification = $notification instanceof Notification
            ? $notification
            : Notification::fromArray((array) $notification);

        $message = clone $this;
        $message->notification = $notification;

        return $message;
    }
1318957
public function render(array $notifications)
    {
        $sweetAlerts = '';

        foreach ($notifications as $notification) {
            $message = $this->escapeMessage($notification['message']);
            $type    = $notification['type'];
            $title   = is_null($notification['title']) ? ucfirst($type) : $this->escapeTitle($notification['title']);

            $sweetAlerts = <<<TAG
    swal({
        title: '{$title}',
        text: '{$message}',
        type: '{$type}'
    });\n
TAG;
        }

        return $this->renderOutput($sweetAlerts);
    }
1191940
public function render($messages = null)
	{
		if ($messages)
		{
			$this->setMessages($messages);
		}

		$messages = $this->getMessages();

		$output = array();
		$output[] = '<script type="text/javascript">';
		$output[] = 'if (!window.console) console = {};';
		$output[] = 'console.log   = console.log   || function(){};';
		$output[] = 'console.warn  = console.warn  || function(){};';
		$output[] = 'console.error = console.error || function(){};';
		$output[] = 'console.info  = console.info  || function(){};';
		$output[] = 'console.debug = console.debug || function(){};';
		foreach ($messages as $item)
		{
			$output[] = 'console.' . $item['label'] . '("' . addslashes($this->_deflate($item['message'])) . '");';
		}
		$output[] = '</script>';
		return implode("\n", $output);
	}
973439
public function generateFromTokens($tokens)
    {
        if (!$tokens) {
            return '';
        }

        // Basic algorithm
        $html = '';
        for ($i = 0, $size = count($tokens); $i < $size; $i++) {
            if ($this->_scriptFix && $tokens[$i]->name === 'script'
                && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) {
                // script special case
                // the contents of the script block must be ONE token
                // for this to work.
                $html .= $this->generateFromToken($tokens[$i++]);
                $html .= $this->generateScriptFromToken($tokens[$i++]);
            }
            $html .= $this->generateFromToken($tokens[$i]);
        }

        // Tidy cleanup
        if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) {
            $tidy = new Tidy;
            $tidy->parseString(
                $html,
                array(
                   'indent'=> true,
                   'output-xhtml' => $this->_xhtml,
                   'show-body-only' => true,
                   'indent-spaces' => 2,
                   'wrap' => 68,
                ),
                'utf8'
            );
            $tidy->cleanRepair();
            $html = (string) $tidy; // explicit cast necessary
        }

        // Normalize newlines to system defined value
        if ($this->config->get('Core.NormalizeNewlines')) {
            $nl = $this->config->get('Output.Newline');
            if ($nl === null) {
                $nl = PHP_EOL;
            }
            if ($nl !== "\n") {
                $html = str_replace("\n", $nl, $html);
            }
        }
        return $html;
    }
524619
public function viewedNotifications($notifications)
    {
        $notifications = (array) $notifications;

        $ids = clone $this->newNotificationIds;

        foreach ($notifications as $notification) {
            $ids->offsetUnset($notification->id);
        }

        $this->set('newNotificationIds', $ids);

        $this->save();
    }
807678
public function formatNotifiables($notifiables)
    {
        if (is_array($notifiables) || $notifiables instanceof Collection) {
            return $notifiables;
        }

        if ($notifiables instanceof Record) {
            return new Collection([$notifiables]);
        }

        return [$notifiables];
    }
979815
private function _renderArgs($args = [])
    {
        return '('.
            implode(',', array_map(function ($arg) {
                if ($arg instanceof jsExpressionable) {
                    return $arg->jsRender();
                }

                return $this->_json_encode($arg);
            }, $args)).
            ')';
    }
539070
public function render($options = array())
    {
        $alert = $this->alertManager->getAlert();
        $options['alerts'] = $alert ? $alert->all() : array();

        return $this->alertHelper->render($options, $this->getTemplate($options));
    }