Renders a message using the passed configuration.

@param string $message The message to render
@param array  $config  Message configuration

@return string
193853
public function render($config = array())
    {
        $message = $config['message'];

        unset($config['message']);

        $message = '<p>'.$message.'</p>';
        $buttons = isset($config['buttons']) ? $config['buttons'] : array();

        unset($config['buttons']);

        if (! empty($buttons)) {
            foreach ($buttons as $label => $attrbs) {
                $buttons[$label] = $this->_renderButton($label, $attrbs);
            }

            $message .= '<p class="alert-actions">'.implode(' ', $buttons).'</p>';
        }

        return $this->_renderMessage($message, $config);
    }
125677
public function renderWidget( $config = [] ) {

		$containerHtml	= $this->container ? $this->renderContainer( $config ) : null;

		$draggerHtml	= $this->dragger ? $this->renderDragger( $config ) : null;

		$chooserHtml	= $this->chooser ? $this->renderChooser( $config ) : null;

		$preloaderHtml	= $this->preloader ? $this->renderPreloader( $config ) : null;

		$infoHtml		= $this->info ? $this->renderInfo( $config ) : null;

		$fieldsHtml		= $this->fields ? $this->renderFields( $config ) : null;

		$formHtml		= $this->form ? $this->renderForm( $config, [ 'infoHtml' => $infoHtml, 'fieldsHtml' => $fieldsHtml ] ) : null;

		$uploaderView	= CodeGenUtil::isAbsolutePath( $this->uploaderView ) ? $this->uploaderView : "$this->template/$this->uploaderView";

		$widgetHtml = $this->render( $uploaderView, [
			'widget' => $this,
			'containerHtml' => $containerHtml,
			'draggerHtml' => $draggerHtml,
			'chooserHtml' => $chooserHtml,
			'preloaderHtml' => $preloaderHtml,
			'infoHtml' => $infoHtml,
			'fieldsHtml' => $fieldsHtml,
			'formHtml' => $formHtml
		] );

		if( $this->wrap ) {

			return Html::tag( $this->wrapper, $widgetHtml, $this->options );
		}

		return $widgetHtml;
	}
1192454
public function renderer($config = null)
    {
        if ($config !== null) {
            $this->_renderer = new CakePdf($config);
        }

        return $this->_renderer;
    }
193632
public function dialog($config = array())
    {
        $html  = $this->createHelper('behavior')->modal();
        $html .= $this->command($config);

        return $html;
    }
1127474
public function transform(array $config): string
    {
        $cfg = '';
        foreach ($config as $nodeName => $nodeData) {
            $nodeName = \is_numeric($nodeName) ? 'num__'.$nodeName : $nodeName;

            if (\is_array($nodeData)) {
                $cfg .= \sprintf('%s[%s]%s', \chr($this->newline), $nodeName, \chr($this->newline));
                $cfg .= $this->addLine($nodeName, $nodeData, 0);
            } elseif (\is_bool($nodeData)) {
                $nodeData = $nodeData === true ? 'true' : 'false';
                $cfg .= \sprintf('%s = %s%s', $nodeName, $nodeData, \chr($this->newline));
            } else {
                $nodeData = $this->normalize((string)$nodeData);
                $cfg .= \sprintf('%s = %s%s', $nodeName, $nodeData, \chr($this->newline));
            }
        }
        return $cfg;
    }
588515
public static function getMessage($mailer, ConfigObject $config = null)
    {
        // Do it this way to avoid merging into the original mailer config
        $mailerConfig = Mailer::getConfig()->get($mailer)->toArray();
        $mailerConfig = new ConfigObject($mailerConfig);
        if ($config) {
            $mailerConfig->mergeWith($config);
        }
        $lib = self::getLibrary($mailer);

        /** @var MailerInterface $libInstance */
        $libInstance = self::factory($lib, MailerInterface::class);

        $instance = $libInstance::getMessage($mailerConfig);
        if (!self::isInstanceOf($instance, MessageInterface::class)) {
            throw new MailerException(MailerException::MESSAGE_INTERFACE);
        }

        return $instance;
    }
915820
public function renderWidget( $config = [] ) {

		$gallery		= $this->gallery;
		$items 			= [];
		$galleryHtml	= '';

		// Paths
		$wrapperPath	= $this->template . '/wrapper';
		$itemPath		= $this->template . '/item';

		// Generate Items Html

		$gitems = $gallery->files;

	    foreach( $gitems as $item ) {

	        $items[] = $this->render( $itemPath, [ 'item' => $item ] );
	    }

		$itemsHtml		= implode( "\n", $items );

		$galleryHtml	= $this->render( $wrapperPath, [ 'gallery' => $gallery, 'itemsHtml' => $itemsHtml ] );

		return $galleryHtml;
	}
1189755
public function render(array $config = [])
    {
        $settings = AdminBar::$plugin->getSettings();
        $config['editEmbedded'] = $this->_editEmbedded;
        $entry = ($config['entry'] = $config['entry'] ?? null);
        $config['url'] = $config['url'] ?? '#';
        $config['id'] = $this->_editId;
        $config['enabled'] = AdminBar::$plugin->bar->canEmbed() ? true : false;

        // add config file settings to config
        $config['displayEditDate'] = $settings->displayEditDate;
        $config['displayEditAuthor'] = $settings->displayEditAuthor;
        $config['displayRevisionNote'] = $settings->displayRevisionNote;

        // figure out if $entry is a custom URL string, otherwise assume it's an Entry
        $config['type'] = $config['entry'] ? 'entry' : 'string';

        // get recent revision information
        $revision = $config['type'] == 'entry' ? Craft::$app->entryRevisions->getVersionsByEntryId($entry->id, $entry->siteId, 1, true) : null;
        if ($revision ?? false) {
            $revisionAuthor = Craft::$app->users->getUserById($revision[0]->creatorId);
            $config['revisionAuthor'] = $revisionAuthor;
            $config['revisionNote'] = $revision[0]->revisionNotes;
        } else {
            $config['revisionAuthor'] = null;
            $config['revisionNote'] = null;
        }

        // set title based on override, entry, or url provided
        if (!isset($config['title'])) {
            if ($config['type'] == 'entry') {
                $config['title'] = $config['entry']->title;
            } else {
                $config['title'] = $config['url'];
            }
        }

        $oldMode = Craft::$app->view->getTemplateMode();
        Craft::$app->view->setTemplateMode(View::TEMPLATE_MODE_CP);
        $html = Craft::$app->view->renderTemplate('admin-bar/editLinks', $config);
        Craft::$app->view->setTemplateMode($oldMode);

        print($html);

        $this->_editId += 1;
        $this->_editEmbedded = true;

        return '';
    }
49038
public function renderMail($config = array())
    {
        $config = new AnConfig($config);

        $config->append(array(
            'layout' => 'default',
        ));

        $layout = $config->layout;
        $data = $this->getState()->toArray();

        if ($this->getState()->getItem()) {
            $data[$this->_mixer->getIdentifier()->name] = $this->getState()->getItem();
        }

        if ($this->getState()->getList()) {
            $data[AnInflector::pluralize($this->_mixer->getIdentifier()->name)] = $this->getState()->getList();
        }

        $config->append(array(
            'data' => $data
        ));

        $template = $this->getEmailTemplateView()->getTemplate();
        $data = array_merge($config['data'], array('config' => $config));

        if ($layout && $template->findTemplate($layout)) {
            $output = $template->loadTemplate($layout, array('output' => $output))->render();
        } else {
            $output = $template->loadTemplate($config->template, $data)->render();
        }

        return $output;
    }
917579
protected function run(Config $config): ResultInterface
    {
        $groups = (array) $config->get('groups');

        // TODO: Test me!
        $results = array_map(function (array $group): ResultInterface {
            $code = (int) $group['code'] ?? 200;

            $this->validator->setExpectedStatusCode($code);

            $urls = array_map(function (string $path): string {
                return home_url($path);
            }, $group['paths'] ?? []);

            return $this->validator->validate(...$urls);
        }, $groups);

        // TODO: Method to merge results? Or, allow returning multiple results?
        // Assume successful results don't have messages .
        $messages = array_map(function (ResultInterface $result): array {
            return $result->getMessages();
        }, $results);

        switch (count($messages)) {
            case 0:
                $messages = [];
                break;
            case 1:
                $messages = $messages[0];
                break;
            default:
                $messages = array_merge(...$messages);
        }

        $messages = array_filter($messages);

        if (! empty($messages)) {
            return ResultFactory::makeFailure(
                $this,
                array_merge(['***** Experimental *****', 'Something went wrong:'], $messages)
            );
        }

        return ResultFactory::makeSuccess($this);
    }
608175
public function formfield_text($config = array())
    {
        $config = new AnConfig($config);

        $config->append(array(
            'class' => 'input-block-level',
            'maxlength' => 200,
            'name' => '',
            'id' => '',
            'label' => '',
            'placeholder' => '',
            'description' => '',
            'disabled' => false,
            'type' => 'text',
            'pattern' => '',
            'required' => true,
        ));

        return $this->_render('formfield_text', $config);
    }
1156247
public function dialog($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'command' => NULL
        ));

        $html = $this->command($config);

        return $html;
    }
228576
public function getTemplate(array $config)
	{
		foreach ($this->templateGenerators as $type => $generator)
		{
			if (isset($config[$type]))
			{
				return $generator->getTemplate($config[$type]);
			}
		}

		return '';
	}
82166
public function message(array $config): string
    {
        return $this->notReachableServers->map(function (Server $server) {
            return trans('self-diagnosis::checks.servers_are_pingable.message', [
                'host' => $server->getHost(),
                'port' => $server->getPort() ?? 'n/a',
                'timeout' => $server->getTimeout(),
            ]);
        })->implode(PHP_EOL);
    }
598961
public function message(array $config): string
    {
        if ($this->message) {
            return $this->message;
        }

        return trans('self-diagnosis::checks.supervisor_programs_are_running.message.not_running_programs', [
            'programs' => $this->notRunningPrograms->implode(PHP_EOL),
        ]);
    }
780915
protected function _renderMails($config)
    {
        $mails = array();
        $config = new AnConfig($config);
        $settings = $config->settings;
        $people = $config->people;
        $notification = $config->notification;

        foreach ($people as  $person) {

            $setting = $settings->{$person->id};

            if (! $ret = $notification->shouldNotify($person, $setting)) {
                $notification->removeSubscribers($person);
                continue;
            }

            $person->addNotification($notification);

            if ($ret !== ComNotificationsDomainDelegateSettingInterface::NOTIFY_WITH_EMAIL) {
                continue;
            }

            //since each owner revieces the mail, they are in fact the viewer
            //so we need to set the as viewer while processing the notification
            AnService::set('com:people.viewer', $person);

            $notification->owner = $person;
            $data = new AnConfig($this->_parser->parse($notification));

            $data->append(array(
                'email_subject' => $data->title,
                'email_title' => pick($data->email_subject, $data->title),
                'email_body' => $data->body,
                'notification' => $notification
            ));

            if ($notification->target && !$notification->target->eql($person)) {
                $data->commands->insert('notification_setting', array('actor' => $notification->target));
            }

            $body = $this->renderMail(array(
                        'template' => 'notification',
                        'layout' => false,
                        'data' => array(
                            'person' => $person,
                            'commands' => $data->commands,
                            'subject' => $notification->subject,
                            'title' => $data->email_title,
                            'body' => $data->email_body
                        )
                    ));

            if ($person->email != '' && filter_var($person->email, FILTER_VALIDATE_EMAIL)) {
                $mails[] = array(
                      'subject' => $data->email_subject,
                      'body' => $body,
                      'to' => $person->email
                );
            }
        }

        return $mails;
    }
445690
public function renderWidget( $config = [] ) {

		// Limit
		$limit = Yii::$app->request->getQueryParam( $this->limitParam );

		if( isset( $limit ) && in_array( $limit, $this->limits ) ) {

			$this->limit = $limit;
		}

		if( isset( $this->dataProvider ) ) {

			$this->dataProvider->pagination->pageSize = $this->limit;
		}

		// Layout
		$user		= Yii::$app->user->getIdentity();
		$uLayout	= $user->getDataConfigMeta( CoreGlobal::DATA_GRID_LAYOUT );
		$layout		= Yii::$app->request->getQueryParam( 'layout' );

		$gridLayout	= isset( $user ) && isset( $uLayout ) ? $uLayout : $this->layout;
		$gridLayout	= isset( $layout ) && in_array( $layout, [ 'data', 'table', 'list', 'card' ] ) ? $layout : $gridLayout;

		$gridLayout = $this->grid && $gridLayout == 'data' ? 'data' : $gridLayout;
		$gridLayout = $this->table && $gridLayout == 'table' ? 'table' : $gridLayout;
		$gridLayout = $this->list && $gridLayout == 'list' ? 'list' : $gridLayout;
		$gridLayout = $this->card && $gridLayout == 'card' ? 'card' : $gridLayout;

		$this->layout = $gridLayout;

		// Views
		$this->actionView = CodeGenUtil::isAbsolutePath( $this->actionView ) ? $this->actionView : "$this->template/$this->actionView";

		$sortHtml		= $this->sort ? $this->renderSort( $config ) : null;

		$searchHtml		= $this->search ? $this->renderSearch( $config ) : null;

		$filtersHtml	= $this->filter ? $this->renderFilters( $config ) : null;

		$bulkHtml		= $this->bulk ? $this->renderBulk( $config ) : null;

		$reportHtml		= $this->report ? $this->renderReport( $config ) : null;

		$headHtml		= $this->head ? $this->renderHead( $config, [ 'sortHtml' => $sortHtml, 'searchHtml' => $searchHtml, 'filtersHtml' => $filtersHtml, 'bulkHtml' => $bulkHtml ] ) : null;

		$optionsHtml	= $this->option ? $this->renderOptions( $config, [ 'sortHtml' => $sortHtml, 'searchHtml' => $searchHtml, 'filtersHtml' => $filtersHtml, 'bulkHtml' => $bulkHtml ] ) : null;

		$headerHtml		= $this->header ? $this->renderHeader( $config ) : null;

		$dataHtml		= $this->grid && $this->layout == 'data' ? $this->renderData( $config ) : null;
		$dataHtml		= $this->table && $this->layout == 'table' ? $this->renderData( $config ) : $dataHtml;

		$listHtml		= $this->list && $this->layout == 'list' ? $this->renderList( $config ) : null;

		$cardHtml		= $this->card && $this->layout == 'card' ? $this->renderCards( $config ) : null;

		$footerHtml		= $this->footer ? $this->renderFooter( $config ) : null;

		$gridView		= CodeGenUtil::isAbsolutePath( $this->gridView ) ? $this->gridView : "$this->template/$this->gridView";

		$widgetHtml = $this->render( $gridView, [
			'widget' => $this,
			'sortHtml' => $sortHtml, 'searchHtml' => $searchHtml, 'filtersHtml' => $filtersHtml,
			'bulkHtml' => $bulkHtml, 'reportHtml' => $reportHtml, 'headHtml' => $headHtml, 'optionsHtml' => $optionsHtml,
			'headerHtml' => $headerHtml, 'footerHtml' => $footerHtml,
			'dataHtml' => $dataHtml, 'listHtml' => $listHtml, 'cardHtml' => $cardHtml
		]);

		if( $this->wrap ) {

			return Html::tag( $this->wrapper, $widgetHtml, $this->options );
		}

        return $widgetHtml;
	}