Skip to content
module_test:
label: Test Module
breakpoints:
- theme.breakpoint_test_theme.mobile
- theme.breakpoint_test_theme.narrow
- theme.breakpoint_test_theme.wide
id: theme.breakpoint_test_theme.mobile
uuid: 3ae8bfe6-496b-478c-a811-17424038f49c
name: mobile
label: mobile
mediaQuery: '(min-width: 0px)'
source: breakpoint_test_theme
sourceType: theme
weight: 0
multipliers:
1x: 1x
status: true
langcode: en
id: theme.breakpoint_test_theme.narrow
uuid: 1d791b4a-7ccf-4c93-a800-c2bc2594cc62
name: narrow
label: narrow
mediaQuery: '(min-width: 560px)'
source: breakpoint_test_theme
sourceType: theme
weight: 1
multipliers:
1x: 1x
status: true
langcode: en
id: theme.breakpoint_test_theme.tv
uuid: e0ffa737-0570-4891-9809-9bce925673ca
name: tv
label: tv
mediaQuery: 'only screen and (min-width: 3456px)'
source: breakpoint_test_theme
sourceType: theme
weight: 3
multipliers:
1x: 1x
status: true
langcode: en
id: theme.breakpoint_test_theme.wide
uuid: 1561574d-99f8-48a6-b304-4e2b617673b2
name: wide
label: wide
mediaQuery: '(min-width: 851px)'
source: breakpoint_test_theme
sourceType: theme
weight: 2
multipliers:
1x: 1x
status: true
langcode: en
id: theme.breakpoint_test_theme.breakpoint_test_theme
uuid: 94b96e6e-a032-4b29-8100-efd5bf854fd1
name: breakpoint_test_theme
label: 'Breakpoint test theme'
breakpoint_ids:
- theme.breakpoint_test_theme.mobile
- theme.breakpoint_test_theme.narrow
- theme.breakpoint_test_theme.wide
- theme.breakpoint_test_theme.tv
source: breakpoint_test_theme
sourceType: theme
status: true
langcode: en
id: theme.breakpoint_test_theme.test
uuid: fcc25180-7e18-4149-8962-98d706faa59a
name: test
label: 'Test Theme'
breakpoint_ids:
- theme.breakpoint_test_theme.mobile
- theme.breakpoint_test_theme.narrow
- theme.breakpoint_test_theme.wide
source: breakpoint_test_theme
sourceType: theme
status: true
langcode: en
mobile: '(min-width: 0px)'
narrow: '(min-width: 560px)'
wide: '(min-width: 851px)'
tv: 'only screen and (min-width: 3456px)'
......@@ -320,9 +320,9 @@ public function getLangcodes() {
if (empty($langcodes)) {
$langcodes = array();
// Collect languages included with CKEditor based on file listing.
$ckeditor_languages = new \GlobIterator(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js');
foreach ($ckeditor_languages as $language_file) {
$langcode = $language_file->getBasename('.js');
$ckeditor_languages = glob(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js');
foreach ($ckeditor_languages as $language_filename) {
$langcode = basename($language_filename, '.js');
$langcodes[$langcode] = $langcode;
}
cache('ckeditor.languages')->set('langcodes', $langcodes);
......
......@@ -1731,3 +1731,20 @@ function comment_library_info() {
);
return $libraries;
}
/**
* #post_render_cache callback; replaces the placeholder with the comment form.
*
* @param array $context
* An array with the following keys:
* - entity_type: an entity type
* - entity_id: an entity ID
* - field_name: a comment field name
*
* @return array $element
* The updated $element.
*/
function comment_replace_form_placeholder(array $context) {
$entity = entity_load($context['entity_type'], $context['entity_id']);
return comment_add($entity, $context['field_name']);
}
......@@ -2,9 +2,7 @@
/**
* @file
* Provide views data and handlers for comment.module.
*
* @ingroup views_module_handlers
* Provide views data for comment.module.
*/
/**
......
......@@ -36,7 +36,6 @@
* fieldable = TRUE,
* translatable = TRUE,
* render_cache = FALSE,
* route_base_path = "admin/structure/comments/manage/{bundle}",
* entity_keys = {
* "id" = "cid",
* "bundle" = "field_id",
......@@ -48,7 +47,8 @@
* },
* links = {
* "canonical" = "comment.permalink",
* "edit-form" = "comment.edit_page"
* "edit-form" = "comment.edit_page",
* "admin-form" = "comment.bundle"
* }
* )
*/
......@@ -216,10 +216,10 @@ public function id() {
public function preSave(EntityStorageControllerInterface $storage_controller) {
parent::preSave($storage_controller);
global $user;
$user = \Drupal::currentUser();
if (!isset($this->status->value)) {
$this->status->value = user_access('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED;
$this->status->value = $user->hasPermission('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED;
}
if ($this->isNew()) {
// Add the comment to database. This next section builds the thread field.
......
......@@ -138,7 +138,24 @@ public function viewElements(FieldItemListInterface $items) {
if ($status == COMMENT_OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW) {
// Only show the add comment form if the user has permission.
if ($this->currentUser->hasPermission('post comments')) {
$output['comment_form'] = comment_add($entity, $field_name);
// All users in the "anonymous" role can use the same form: it is fine
// for this form to be stored in the render cache.
if ($this->currentUser->isAnonymous()) {
$output['comment_form'] = comment_add($entity, $field_name);
}
// All other users need a user-specific form, which would break the
// render cache: hence use a #post_render_cache callback.
else {
$output['comment_form'] = array(
'#type' => 'render_cache_placeholder',
'#callback' => 'comment_replace_form_placeholder',
'#context' => array(
'entity_type' => $entity->entityType(),
'entity_id' => $entity->id(),
'field_name' => $field_name
),
);
}
}
}
......
......@@ -229,11 +229,11 @@ function testCommentFunctionality() {
));
$this->drupalLogin($limited_user);
// Test that default field exists.
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields');
$this->drupalGet('entity_test/structure/entity_test/fields');
$this->assertText(t('Comment settings'));
$this->assertLinkByHref('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment');
$this->assertLinkByHref('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
// Test widget hidden option is not visible when there's no comments.
$this->drupalGet('admin/structure/entity-test/manage/entity_test/entity-test/fields/entity_test.entity_test.comment');
$this->drupalGet('entity_test/structure/entity_test/entity-test/fields/entity_test.entity_test.comment');
$this->assertNoField('edit-default-value-input-comment-und-0-status-0');
$this->drupalLogin($this->admin_user);
......@@ -343,20 +343,20 @@ function testCommentFunctionality() {
'administer entity_test content',
));
$this->drupalLogin($limited_user);
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment');
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-2');
// Test comment option change in field settings.
$edit = array('default_value_input[comment][0][status]' => COMMENT_CLOSED);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment');
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-2');
// Add a new comment field.
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields');
$this->drupalGet('entity_test/structure/entity_test/fields');
$edit = array(
'fields[_add_new_field][label]' => 'Foobar',
'fields[_add_new_field][field_name]' => 'foobar',
......
......@@ -23,13 +23,10 @@ class ConfigFieldInstanceMapper extends ConfigEntityMapper {
*/
public function getBaseRouteParameters() {
$parameters = parent::getBaseRouteParameters();
// @todo All core content entity path placeholders can be fully filled in
// with an additional {bundle} value in their paths, but a more
// predictable solution would be ideal. See
// https://drupal.org/node/2134871
$base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
// @todo Field instances have no method to return the bundle the instance is
// attached to. See https://drupal.org/node/2134861
$parameters['bundle'] = $this->entity->bundle;
$parameters[$base_entity_info['bundle_entity_type']] = $this->entity->bundle;
return $parameters;
}
......
contact.category_edit:
title: 'Edit'
route_name: contact.category_edit
tab_root_id: contact.category_edit
......@@ -67,10 +67,6 @@ function contact_menu() {
'title' => 'Edit contact category',
'route_name' => 'contact.category_edit',
);
$items['admin/structure/contact/manage/%contact_category/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['contact'] = array(
'title' => 'Contact',
......
......@@ -3,8 +3,6 @@
/**
* @file
* Provide views data for contact.module.
*
* @ingroup views_module_handlers
*/
/**
......
......@@ -26,10 +26,13 @@
* entity_keys = {
* "bundle" = "category"
* },
* route_base_path = "admin/structure/contact/manage/{bundle}",
* bundle_entity_type = "contact_category",
* fieldable = TRUE,
* bundle_keys = {
* "bundle" = "id"
* },
* links = {
* "admin-form" = "contact.category_edit"
* }
* )
*/
......