本文整理汇总了PHP中Drupal\Core\Render\RendererInterface类的典型用法代码示例。如果您正苦于以下问题:PHP RendererInterface类的具体用法?PHP RendererInterface怎么用?PHP RendererInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RendererInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->viewStorage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')->disableOriginalConstructor()->getMock();
$this->renderer = $this->getMock('\\Drupal\\Core\\Render\\RendererInterface');
$this->renderer->expects($this->any())->method('render')->will($this->returnCallback(function (array &$elements) {
$elements['#attached'] = [];
return isset($elements['#markup']) ? $elements['#markup'] : '';
}));
$this->renderer->expects($this->any())->method('executeInRenderContext')->willReturnCallback(function (RenderContext $context, callable $callable) {
return $callable();
});
$this->currentPath = $this->getMockBuilder('Drupal\\Core\\Path\\CurrentPathStack')->disableOriginalConstructor()->getMock();
$this->redirectDestination = $this->getMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
$this->viewAjaxController = new ViewAjaxController($this->viewStorage, $this->executableFactory, $this->renderer, $this->currentPath, $this->redirectDestination);
$element_info_manager = $this->getMock('\\Drupal\\Core\\Render\\ElementInfoManagerInterface');
$element_info_manager->expects($this->any())->method('getInfo')->with('markup')->willReturn(['#pre_render' => [[Markup::class, 'ensureMarkupIsSafe']], '#defaults_loaded' => TRUE]);
$request_stack = new RequestStack();
$request_stack->push(new Request());
$args = [$this->getMock('\\Drupal\\Core\\Controller\\ControllerResolverInterface'), $this->getMock('\\Drupal\\Core\\Theme\\ThemeManagerInterface'), $element_info_manager, $this->getMock('\\Drupal\\Core\\Render\\RenderCacheInterface'), $request_stack, ['required_cache_contexts' => ['languages:language_interface', 'theme']]];
$this->renderer = $this->getMockBuilder('Drupal\\Core\\Render\\Renderer')->setConstructorArgs($args)->setMethods(NULL)->getMock();
$container = new ContainerBuilder();
$container->set('renderer', $this->renderer);
\Drupal::setContainer($container);
}
开发者ID:scratch,项目名称:gai,代码行数:28,代码来源:ViewAjaxControllerTest.php
示例2: setUp
protected function setUp()
{
$this->viewStorage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')->disableOriginalConstructor()->getMock();
$this->renderer = $this->getMock('\\Drupal\\Core\\Render\\RendererInterface');
$this->renderer->expects($this->any())->method('render')->will($this->returnCallback(function (array &$elements) {
$elements['#attached'] = [];
return isset($elements['#markup']) ? $elements['#markup'] : '';
}));
$this->currentPath = $this->getMockBuilder('Drupal\\Core\\Path\\CurrentPathStack')->disableOriginalConstructor()->getMock();
$this->redirectDestination = $this->getMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
$this->viewAjaxController = new ViewAjaxController($this->viewStorage, $this->executableFactory, $this->renderer, $this->currentPath, $this->redirectDestination);
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:13,代码来源:ViewAjaxControllerTest.php
示例3: getDescription
/**
* {@inheritdoc}
*/
public function getDescription()
{
$locked = $this->tempStore->getMetadata($this->entity->id());
$account = $this->entityTypeManager->getStorage('user')->load($locked->owner);
$username = array('#theme' => 'username', '#account' => $account);
return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', array('@user' => $this->renderer->render($username)));
}
开发者ID:curveagency,项目名称:intranet,代码行数:10,代码来源:IndexBreakLockForm.php
示例4: process
/**
* {@inheritdoc}
*/
public function process($text, $langcode)
{
$response = new FilterProcessResult($text);
// Use a look ahead to match the capture groups in any order.
if (preg_match_all('/<p>(?<json>{(?=.*preview_thumbnail\\b)(?=.*settings\\b)(?=.*video_url\\b)(?=.*settings_summary)(.*)})<\\/p>/', $text, $matches)) {
foreach ($matches['json'] as $delta => $match) {
// Ensure the JSON string is valid.
$embed_data = json_decode($match, TRUE);
if (!is_array($embed_data)) {
continue;
}
// If the URL can't matched to a provider or the settings are invalid,
// ignore it.
$provider = $this->providerManager->loadProviderFromInput($embed_data['video_url']);
if (!$provider || !$this->validSettings($embed_data['settings'])) {
continue;
}
$embed_code = $provider->renderEmbedCode($embed_data['settings']['width'], $embed_data['settings']['height'], $embed_data['settings']['autoplay']);
// Add the container to make the video responsive if it's been
//configured as such. This usually is attached to field output in the
// case of a formatter, but a custom container must be used where one is
// not present.
if ($embed_data['settings']['responsive']) {
$embed_code = ['#type' => 'container', '#attributes' => ['class' => ['video-embed-field-responsive-video']], 'children' => $embed_code];
}
// Replace the JSON settings with a video.
$text = str_replace($matches[0][$delta], $this->renderer->renderRoot($embed_code), $text);
}
}
// Add the required responsive video library and update the response text.
$response->setProcessedText($text);
$response->addAttachments(['library' => ['video_embed_field/responsive-video']]);
return $response;
}
开发者ID:badelas,项目名称:afroweb,代码行数:37,代码来源:VideoEmbedWysiwyg.php
示例5: displayErrorMessages
/**
* Loops through and displays all form errors.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
protected function displayErrorMessages(array $form, FormStateInterface $form_state)
{
$error_links = [];
$errors = $form_state->getErrors();
// Loop through all form errors and check if we need to display a link.
foreach ($errors as $name => $error) {
$form_element = FormElementHelper::getElementByName($name, $form);
$title = FormElementHelper::getElementTitle($form_element);
// Only show links to erroneous elements that are visible.
$is_visible_element = Element::isVisibleElement($form_element);
// Only show links for elements that have a title themselves or have
// children with a title.
$has_title = !empty($title);
// Only show links for elements with an ID.
$has_id = !empty($form_element['#id']);
// Do not show links to elements with suppressed messages. Most often
// their parent element is used for inline errors.
if (!empty($form_element['#error_no_message'])) {
unset($errors[$name]);
} elseif ($is_visible_element && $has_title && $has_id) {
$error_links[] = $this->l($title, Url::fromRoute('<none>', [], ['fragment' => $form_element['#id'], 'external' => TRUE]));
unset($errors[$name]);
}
}
// Set normal error messages for all remaining errors.
foreach ($errors as $error) {
$this->drupalSetMessage($error, 'error');
}
if (!empty($error_links)) {
$render_array = [['#markup' => $this->formatPlural(count($error_links), '1 error has been found: ', '@count errors have been found: ')], ['#theme' => 'item_list', '#items' => $error_links, '#context' => ['list_style' => 'comma-list']]];
$message = $this->renderer->renderPlain($render_array);
$this->drupalSetMessage($message, 'error');
}
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:42,代码来源:FormErrorHandler.php
示例6: getDescription
/**
* {@inheritdoc}
*/
public function getDescription()
{
$locked = $this->rulesUiHandler->getLockMetaData();
$account = $this->entityTypeManager->getStorage('user')->load($locked->owner);
$username = ['#theme' => 'username', '#account' => $account];
return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => $this->renderer->render($username)]);
}
开发者ID:Progressable,项目名称:openway8,代码行数:10,代码来源:BreakLockForm.php
示例7: addPage
/**
* Displays add links for the available bundles.
*
* Redirects to the add form if there's only one bundle available.
*
* @param string $entity_type_id
* The entity type ID.
* @param \Symfony\Component\HttpFoundation\Request $request
* The request.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|array
* If there's only one available bundle, a redirect response.
* Otherwise, a render array with the add links for each bundle.
*/
public function addPage($entity_type_id, Request $request)
{
$entity_type = $this->entityTypeManager()->getDefinition($entity_type_id);
$bundle_type = $entity_type->getBundleEntityType();
$bundle_key = $entity_type->getKey('bundle');
$form_route_name = 'entity.' . $entity_type_id . '.add_form';
$build = ['#theme' => 'entity_add_list', '#cache' => ['tags' => $entity_type->getListCacheTags()], '#bundle_type' => $bundle_type];
$bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
// Filter out the bundles the user doesn't have access to.
$access_control_handler = $this->entityTypeManager()->getAccessControlHandler($bundle_type);
foreach ($bundles as $bundle_name => $bundle_info) {
$access = $access_control_handler->createAccess($bundle_name, NULL, [], TRUE);
if (!$access->isAllowed()) {
unset($bundles[$bundle_name]);
}
$this->renderer->addCacheableDependency($build, $access);
}
// Redirect if there's only one bundle available.
if (count($bundles) == 1) {
$bundle_names = array_keys($bundles);
$bundle_name = reset($bundle_names);
return $this->redirect($form_route_name, [$bundle_key => $bundle_name]);
}
// Prepare the #bundles array for the template.
$bundles = $this->loadBundleDescriptions($bundles, $bundle_type);
foreach ($bundles as $bundle_name => $bundle_info) {
$build['#bundles'][$bundle_name] = ['label' => $bundle_info['label'], 'description' => $bundle_info['description'], 'add_link' => Link::createFromRoute($bundle_info['label'], $form_route_name, [$bundle_key => $bundle_name])];
}
return $build;
}
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:44,代码来源:EntityCreateController.php
示例8: generate
/**
* {@inheritdoc}
*
* For anonymous users, the "active" class will be calculated on the server,
* because most sites serve each anonymous user the same cached page anyway.
* For authenticated users, the "active" class will be calculated on the
* client (through JavaScript), only data- attributes are added to links to
* prevent breaking the render cache. The JavaScript is added in
* system_page_attachments().
*
* @see system_page_attachments()
*/
public function generate($text, Url $url, $collect_cacheability_metadata = FALSE)
{
// Performance: avoid Url::toString() needing to retrieve the URL generator
// service from the container.
$url->setUrlGenerator($this->urlGenerator);
// Start building a structured representation of our link to be altered later.
$variables = array('text' => is_array($text) ? $this->renderer->render($text) : $text, 'url' => $url, 'options' => $url->getOptions());
// Merge in default options.
$variables['options'] += array('attributes' => array(), 'query' => array(), 'language' => NULL, 'set_active_class' => FALSE, 'absolute' => FALSE);
// Add a hreflang attribute if we know the language of this link's url and
// hreflang has not already been set.
if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) {
$variables['options']['attributes']['hreflang'] = $variables['options']['language']->getId();
}
// Set the "active" class if the 'set_active_class' option is not empty.
if (!empty($variables['options']['set_active_class']) && !$url->isExternal()) {
// Add a "data-drupal-link-query" attribute to let the
// drupal.active-link library know the query in a standardized manner.
if (!empty($variables['options']['query'])) {
$query = $variables['options']['query'];
ksort($query);
$variables['options']['attributes']['data-drupal-link-query'] = Json::encode($query);
}
// Add a "data-drupal-link-system-path" attribute to let the
// drupal.active-link library know the path in a standardized manner.
if ($url->isRouted() && !isset($variables['options']['attributes']['data-drupal-link-system-path'])) {
// @todo System path is deprecated - use the route name and parameters.
$system_path = $url->getInternalPath();
// Special case for the front page.
$variables['options']['attributes']['data-drupal-link-system-path'] = $system_path == '' ? '<front>' : $system_path;
}
}
// Remove all HTML and PHP tags from a tooltip, calling expensive strip_tags()
// only when a quick strpos() gives suspicion tags are present.
if (isset($variables['options']['attributes']['title']) && strpos($variables['options']['attributes']['title'], '<') !== FALSE) {
$variables['options']['attributes']['title'] = strip_tags($variables['options']['attributes']['title']);
}
// Allow other modules to modify the structure of the link.
$this->moduleHandler->alter('link', $variables);
// Move attributes out of options since generateFromRoute() doesn't need
// them. Include a placeholder for the href.
$attributes = array('href' => '') + $variables['options']['attributes'];
unset($variables['options']['attributes']);
$url->setOptions($variables['options']);
if (!$collect_cacheability_metadata) {
$url_string = $url->toString($collect_cacheability_metadata);
} else {
$generated_url = $url->toString($collect_cacheability_metadata);
$url_string = $generated_url->getGeneratedUrl();
$generated_link = GeneratedLink::createFromObject($generated_url);
}
// The result of the URL generator is a plain-text URL to use as the href
// attribute, and it is escaped by \Drupal\Core\Template\Attribute.
$attributes['href'] = $url_string;
$result = SafeMarkup::format('<a@attributes>@text</a>', array('@attributes' => new Attribute($attributes), '@text' => $variables['text']));
return $collect_cacheability_metadata ? $generated_link->setGeneratedLink($result) : $result;
}
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:69,代码来源:LinkGenerator.php
示例9: viewElements
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode)
{
$element = [];
$thumbnails = $this->thumbnailFormatter->viewElements($items, $langcode);
$videos = $this->videoFormatter->viewElements($items, $langcode);
foreach ($items as $delta => $item) {
$element[$delta] = ['#type' => 'container', '#attributes' => ['data-video-embed-field-modal' => (string) $this->renderer->renderRoot($videos[$delta]), 'class' => ['video-embed-field-launch-modal']], '#attached' => ['library' => ['video_embed_field/colorbox']], 'children' => $thumbnails[$delta]];
}
return $element;
}
开发者ID:robertfoleyjr,项目名称:robertfoleyjr-d8,代码行数:13,代码来源:Colorbox.php
示例10: testUrlBubbleableMetadataBubbling
/**
* Tests bubbling of cacheable metadata for URLs.
*
* @param bool $collect_bubbleable_metadata
* Whether bubbleable metadata should be collected.
* @param int $invocations
* The expected amount of invocations for the ::bubble() method.
* @param array $options
* The URL options.
*
* @covers ::bubble
*
* @dataProvider providerUrlBubbleableMetadataBubbling
*/
public function testUrlBubbleableMetadataBubbling($collect_bubbleable_metadata, $invocations, array $options)
{
$self = $this;
$this->renderer->expects($this->exactly($invocations))->method('render')->willReturnCallback(function ($build) use($self) {
$self->assertTrue(!empty($build['#cache']));
});
$url = new Url('test_1', [], $options);
$url->setUrlGenerator($this->generator);
$url->toString($collect_bubbleable_metadata);
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:24,代码来源:MetadataBubblingUrlGeneratorTest.php
示例11: execute
/**
* {@inheritdoc}
*/
public function execute($entity = NULL)
{
if (empty($this->configuration['node'])) {
$this->configuration['node'] = $entity;
}
$message = $this->token->replace($this->configuration['message'], $this->configuration);
$build = ['#markup' => $message];
// @todo Fix in https://www.drupal.org/node/2577827
drupal_set_message($this->renderer->renderPlain($build));
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:MessageAction.php
示例12: toolbarAction
/**
* Generates the toolbar.
*
* @param Profile $profile
*
* @return array
*/
public function toolbarAction(Profile $profile)
{
$this->profiler->disable();
$templates = $this->templateManager->getTemplates($profile);
$rendered = '';
foreach ($templates as $name => $template) {
$rendered .= $template->renderBlock('toolbar', ['collector' => $profile->getcollector($name), 'token' => $profile->getToken(), 'name' => $name]);
}
$toolbar = ['#theme' => 'webprofiler_toolbar', '#toolbar' => $rendered, '#token' => $profile->getToken()];
return new Response($this->renderer->render($toolbar));
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:18,代码来源:ToolbarController.php
示例13: bubble
/**
* Bubbles the bubbleable metadata to the current render context.
*
* @param \Drupal\Core\GeneratedUrl $generated_url
* The generated URL whose bubbleable metadata to bubble.
* @param array $options
* (optional) The URL options. Defaults to none.
*/
protected function bubble(GeneratedUrl $generated_url, array $options = [])
{
// Bubbling metadata makes sense only if the code is executed inside a
// render context. All code running outside controllers has no render
// context by default, so URLs used there are not supposed to affect the
// response cacheability.
if ($this->renderer->hasRenderContext()) {
$build = [];
$generated_url->applyTo($build);
$this->renderer->render($build);
}
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:20,代码来源:MetadataBubblingUrlGenerator.php
示例14: execute
/**
* {@inheritdoc}
*/
public function execute($comment = NULL)
{
$build = $this->viewBuilder->view($comment);
$text = $this->renderer->renderPlain($build);
foreach ($this->configuration['keywords'] as $keyword) {
if (strpos($text, $keyword) !== FALSE) {
$comment->setPublished(FALSE);
$comment->save();
break;
}
}
}
开发者ID:sarahwillem,项目名称:OD8,代码行数:15,代码来源:UnpublishByKeywordComment.php
示例15: buildListingLevel
/**
* Helper function for self::listing() to build table rows.
*
* @param array[] $hierarchy
* Keys are plugin IDs, and values are arrays of the same structure as this
* parameter. The depth is unlimited.
* @param integer $depth
* The depth of $hierarchy's top-level items as seen from the original
* hierarchy's root (this function is recursive), starting with 0.
*
* @return array
* A render array.
*/
protected function buildListingLevel(array $hierarchy, $depth)
{
$rows = [];
foreach ($hierarchy as $plugin_id => $children) {
$definition = $this->paymentStatusManager->getDefinition($plugin_id);
$operations_provider = $this->paymentStatusManager->getOperationsProvider($plugin_id);
$indentation = ['#theme' => 'indentation', '#size' => $depth];
$rows[$plugin_id] = ['label' => ['#markup' => $this->renderer->render($indentation) . $definition['label']], 'description' => ['#markup' => $definition['description']], 'operations' => ['#type' => 'operations', '#links' => $operations_provider ? $operations_provider->getOperations($plugin_id) : []]];
$rows = array_merge($rows, $this->buildListingLevel($children, $depth + 1));
}
return $rows;
}
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:25,代码来源:ListPaymentStatuses.php
示例16: injectToolbar
/**
* @param \Symfony\Component\HttpFoundation\Response $response
*/
protected function injectToolbar(Response $response)
{
$content = $response->getContent();
$pos = mb_strripos($content, '</body>');
if (FALSE !== $pos) {
if ($token = $response->headers->get('X-Debug-Token')) {
$loader = ['#theme' => 'webprofiler_loader', '#token' => $token, '#profiler_url' => $this->urlGenerator->generate('webprofiler.toolbar', ['profile' => $token])];
$content = mb_substr($content, 0, $pos) . $this->renderer->renderRoot($loader) . mb_substr($content, $pos);
$response->setContent($content);
}
}
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:WebprofilerEventSubscriber.php
示例17: renderResponse
/**
* {@inheritdoc}
*/
public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)
{
$json = [];
$json['content'] = (string) $this->renderer->renderRoot($main_content);
if (!empty($main_content['#title'])) {
$json['title'] = (string) $main_content['#title'];
} else {
$json['title'] = (string) $this->titleResolver->getTitle($request, $route_match->getRouteObject());
}
$response = new CacheableJsonResponse($json, 200);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($main_content));
return $response;
}
开发者ID:sarahwillem,项目名称:OD8,代码行数:16,代码来源:JsonRenderer.php
示例18: generateResponse
/**
* Generates a response object after handing the un/flag request.
*
* Depending on the wrapper format of the request, it will either redirect
* or return an ajax response.
*
* @param \Drupal\flag\FlagInterface $flag
* The flag entity.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
* @param \Symfony\Component\HttpFoundation\Request $request
* The request.
*
* @return \Drupal\Core\Ajax\AjaxResponse|\Symfony\Component\HttpFoundation\RedirectResponse
* The response object.
*/
protected function generateResponse(FlagInterface $flag, EntityInterface $entity, Request $request) {
if ($request->get(MainContentViewSubscriber::WRAPPER_FORMAT) == 'drupal_ajax') {
// Create a new AJAX response.
$response = new AjaxResponse();
// Get the link type plugin.
$link_type = $flag->getLinkTypePlugin();
// Generate the link render array and get the link CSS ID.
$link = $link_type->getLink($flag, $entity);
$link_id = '#' . $link['link']['#attributes']['id'];
// Create a new JQuery Replace command to update the link display.
$replace = new ReplaceCommand($link_id, $this->renderer->renderPlain($link));
$response->addCommand($replace);
return $response;
}
else {
// Redirect back to the entity. A passed in destination query parameter
// will automatically override this.
$url_info = $entity->toUrl();
return $this->redirect($url_info->getRouteName(), $url_info->getRouteParameters());
}
}
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:42,代码来源:ActionLinkController.php
示例19: wrapControllerExecutionInRenderContext
/**
* Wraps a controller execution in a render context.
*
* @param callable $controller
* The controller to execute.
* @param array $arguments
* The arguments to pass to the controller.
*
* @return mixed
* The return value of the controller.
*
* @throws \LogicException
* When early rendering has occurred in a controller that returned a
* Response or domain object that cares about attachments or cacheability.
*
* @see \Symfony\Component\HttpKernel\HttpKernel::handleRaw()
*/
protected function wrapControllerExecutionInRenderContext($controller, array $arguments)
{
$context = new RenderContext();
$response = $this->renderer->executeInRenderContext($context, function () use($controller, $arguments) {
// Now call the actual controller, just like HttpKernel does.
return call_user_func_array($controller, $arguments);
});
// If early rendering happened, i.e. if code in the controller called
// drupal_render() outside of a render context, then the bubbleable metadata
// for that is stored in the current render context.
if (!$context->isEmpty()) {
/** @var \Drupal\Core\Render\BubbleableMetadata $early_rendering_bubbleable_metadata */
$early_rendering_bubbleable_metadata = $context->pop();
// If a render array or AjaxResponse is returned by the controller, merge
// the "lost" bubbleable metadata.
if (is_array($response)) {
BubbleableMetadata::createFromRenderArray($response)->merge($early_rendering_bubbleable_metadata)->applyTo($response);
} elseif ($response instanceof AjaxResponse) {
$response->addAttachments($early_rendering_bubbleable_metadata->getAttachments());
// @todo Make AjaxResponse cacheable in
// https://www.drupal.org/node/956186. Meanwhile, allow contrib
// subclasses to be.
if ($response instanceof CacheableResponseInterface) {
$response->addCacheableDependency($early_rendering_bubbleable_metadata);
}
} elseif ($response instanceof AttachmentsInterface || $response instanceof CacheableResponseInterface || $response instanceof CacheableDependencyInterface) {
throw new \LogicException(sprintf('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: %s.', get_class($response)));
} else {
// A Response or domain object is returned that does not care about
// attachments nor cacheability; for instance, a RedirectResponse. It is
// safe to discard any early rendering metadata.
}
}
return $response;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:52,代码来源:EarlyRenderingControllerWrapperSubscriber.php
示例20: view
/**
* {@inheritdoc}
*/
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
if ($entity->status()) {
$message = $this->contactMessageStorage->create([
'contact_form' => $entity->id(),
]);
$form = $this->entityFormBuilder->getForm($message);
$form['#title'] = $entity->label();
$form['#cache']['contexts'][] = 'user.permissions';
$this->renderer->addCacheableDependency($form, $this->config);
}
else {
// Form disabled, display a custom message using a template.
$form['disabled_form_error'] = array(
'#theme' => 'contact_storage_disabled_form',
'#contact_form' => $entity,
'#redirect_uri' => $entity->getThirdPartySetting('contact_storage', 'redirect_uri', ''),
'#disabled_form_message' => $entity->getThirdPartySetting('contact_storage', 'disabled_form_message', t('This contact form has been disabled.')),
);
}
// Add required cacheability metadata from the contact form entity, so that
// changing it invalidates the cache.
$this->renderer->addCacheableDependency($form, $entity);
return $form;
}
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:29,代码来源:ContactFormViewBuilder.php
注:本文中的Drupal\Core\Render\RendererInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论