Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes
This commit is contained in:
parent
1a0e9d9fac
commit
a6b049dd05
538 changed files with 5247 additions and 1594 deletions
39
core/modules/action/migration_templates/d6_action.yml
Normal file
39
core/modules/action/migration_templates/d6_action.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
id: d6_action
|
||||
label: Actions
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: action
|
||||
process:
|
||||
id:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: aid
|
||||
label: description
|
||||
type: type
|
||||
plugin:
|
||||
-
|
||||
plugin: static_map
|
||||
source: callback
|
||||
map:
|
||||
system_goto_action: action_goto_action
|
||||
system_send_email_action: action_send_email_action
|
||||
system_message_action: action_message_action
|
||||
user_block_ip_action: 0
|
||||
imagecache_flush_action: 0
|
||||
imagecache_generate_all_action: 0
|
||||
imagecache_generate_action: 0
|
||||
bypass: true
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
configuration:
|
||||
-
|
||||
plugin: default_value
|
||||
source: parameters
|
||||
default_value: "a:0:{}"
|
||||
-
|
||||
plugin: callback
|
||||
callable: unserialize
|
||||
destination:
|
||||
plugin: entity:action
|
36
core/modules/action/migration_templates/d7_action.yml
Normal file
36
core/modules/action/migration_templates/d7_action.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
id: d7_action
|
||||
label: Actions
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: action
|
||||
process:
|
||||
id:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: aid
|
||||
label: label
|
||||
type: type
|
||||
plugin:
|
||||
-
|
||||
plugin: static_map
|
||||
source: callback
|
||||
map:
|
||||
system_goto_action: action_goto_action
|
||||
system_send_email_action: action_send_email_action
|
||||
system_message_action: action_message_action
|
||||
system_block_ip_action: 0
|
||||
bypass: true
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
configuration:
|
||||
-
|
||||
plugin: default_value
|
||||
source: parameters
|
||||
default_value: "a:0:{}"
|
||||
-
|
||||
plugin: callback
|
||||
callable: unserialize
|
||||
destination:
|
||||
plugin: entity:action
|
74
core/modules/action/src/Plugin/migrate/source/Action.php
Normal file
74
core/modules/action/src/Plugin/migrate/source/Action.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Plugin\migrate\source\Action.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal action source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "action",
|
||||
* source_provider = "system"
|
||||
* )
|
||||
*/
|
||||
class Action extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('actions', 'a')
|
||||
->fields('a');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'aid' => $this->t('Action ID'),
|
||||
'type' => $this->t('Module'),
|
||||
'callback' => $this->t('Callback function'),
|
||||
'parameters' => $this->t('Action configuration'),
|
||||
);
|
||||
if ($this->getModuleSchemaVersion('system') >= 7000) {
|
||||
$fields['label'] = $this->t('Label of the action');
|
||||
}
|
||||
else {
|
||||
$fields['description'] = $this->t('Action description');
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['aid']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$aid = $row->getSourceProperty('aid');
|
||||
if (is_numeric($aid)) {
|
||||
if ($this->getModuleSchemaVersion('system') >= 7000) {
|
||||
$label = $row->getSourceProperty('label');
|
||||
}
|
||||
else {
|
||||
$label = $row->getSourceProperty('description');
|
||||
}
|
||||
$row->setSourceProperty('aid', $label);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Plugin\migrate\source\d6\Action.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 action source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_action"
|
||||
* )
|
||||
*/
|
||||
class Action extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('actions', 'a')
|
||||
->fields('a', array(
|
||||
'aid',
|
||||
'type',
|
||||
'callback',
|
||||
'parameters',
|
||||
'description',
|
||||
)
|
||||
);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'aid' => $this->t('Action ID'),
|
||||
'type' => $this->t('Module'),
|
||||
'callback' => $this->t('Callback function'),
|
||||
'parameters' => $this->t('Action configuration'),
|
||||
'description' => $this->t('Action description'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['aid']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Tests\Migrate\d6\MigrateActionsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\system\Entity\Action;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of action items.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateActionsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
public static $modules = ['action', 'comment', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_action');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Drupal 6 action migration to Drupal 8.
|
||||
*/
|
||||
public function testActions() {
|
||||
// Test default actions.
|
||||
$this->assertEntity('node_publish_action', 'Publish post', 'node', []);
|
||||
$this->assertEntity('node_make_sticky_action', 'Make post sticky', 'node', []);
|
||||
$this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
|
||||
$this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
|
||||
|
||||
// Test advanced actions.
|
||||
$this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('change_the_author_of_a_post', 'Change the author of a post', 'node', ["owner_uid" => "2"]);
|
||||
$this->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
|
||||
$this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
|
||||
"recipient" => "test@example.com",
|
||||
"subject" => "Drupal migration test",
|
||||
"message" => "Drupal migration test"
|
||||
]);
|
||||
$this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of an Action entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The expected Action ID.
|
||||
* @param string $label
|
||||
* The expected Action label.
|
||||
* @param string $type
|
||||
* The expected Action type.
|
||||
* @param array $configuration
|
||||
* The expected Action configuration.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $type, $configuration) {
|
||||
$action = Action::load($id);
|
||||
|
||||
$this->assertTrue($action instanceof Action);
|
||||
/** @var \Drupal\system\Entity\Action $action */
|
||||
$this->assertIdentical($id, $action->id());
|
||||
$this->assertIdentical($label, $action->label());
|
||||
$this->assertIdentical($type, $action->getType());
|
||||
$this->assertIdentical($configuration, $action->get('configuration'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Tests\Migrate\d7\MigrateActionsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\system\Entity\Action;
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of action items.
|
||||
*
|
||||
* @group action
|
||||
*/
|
||||
class MigrateActionsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['action', 'comment', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_action');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Drupal 7 action migration to Drupal 8.
|
||||
*/
|
||||
public function testActions() {
|
||||
// Test default actions.
|
||||
$this->assertEntity('node_publish_action', 'Publish content', 'node', []);
|
||||
$this->assertEntity('node_make_sticky_action', 'Make content sticky', 'node', []);
|
||||
$this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
|
||||
$this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
|
||||
|
||||
// Test advanced actions.
|
||||
$this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('change_the_author_of_content', 'Change the author of content', 'node', ["owner_uid" => "2"]);
|
||||
$this->assertEntity('unpublish_content_containing_keyword_s_', 'Unpublish content containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
|
||||
$this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
|
||||
"recipient" => "test@example.com",
|
||||
"subject" => "Drupal migration test",
|
||||
"message" => "Drupal migration test"
|
||||
]);
|
||||
$this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of an Action entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The expected Action ID.
|
||||
* @param string $label
|
||||
* The expected Action label.
|
||||
* @param string $type
|
||||
* The expected Action type.
|
||||
* @param array $configuration
|
||||
* The expected Action configuration.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $type, $configuration) {
|
||||
$action = Action::load($id);
|
||||
|
||||
$this->assertTrue($action instanceof Action);
|
||||
/** @var \Drupal\system\Entity\Action $action */
|
||||
$this->assertIdentical($id, $action->id());
|
||||
$this->assertIdentical($label, $action->label());
|
||||
$this->assertIdentical($type, $action->getType());
|
||||
$this->assertIdentical($configuration, $action->get('configuration'));
|
||||
}
|
||||
|
||||
}
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\action\Unit\Plugin\migrate\source\d6\ActionTest.
|
||||
* Contains \Drupal\Tests\action\Unit\Plugin\migrate\source\ActionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\action\Unit\Plugin\migrate\source\d6;
|
||||
namespace Drupal\Tests\action\Unit\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 actions source plugin.
|
||||
* Tests actions source plugin.
|
||||
*
|
||||
* @group action
|
||||
*/
|
||||
|
@ -18,14 +18,14 @@ class ActionTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\d6\Action';
|
||||
const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\Action';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_action',
|
||||
'plugin' => 'action',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -33,14 +33,14 @@ class ActionTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'aid' => '1',
|
||||
'aid' => 'Redirect to node list page',
|
||||
'type' => 'system',
|
||||
'callback' => 'system_goto_action',
|
||||
'parameters' => 'a:1:{s:3:"url";s:4:"node";}',
|
||||
'description' => 'Redirect to node list page',
|
||||
),
|
||||
array(
|
||||
'aid' => '2',
|
||||
'aid' => 'Test notice email',
|
||||
'type' => 'system',
|
||||
'callback' => 'system_send_email_action',
|
||||
'parameters' => 'a:3:{s:9:"recipient";s:7:"%author";s:7:"subject";s:4:"Test";s:7:"message";s:4:"Test',
|
||||
|
@ -50,15 +50,15 @@ class ActionTest extends MigrateSqlSourceTestCase {
|
|||
'aid' => 'comment_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'comment_publish_action',
|
||||
'parameters' => null,
|
||||
'description' => null,
|
||||
'parameters' => NULL,
|
||||
'description' => NULL,
|
||||
),
|
||||
array(
|
||||
'aid' => 'node_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'node_publish_action',
|
||||
'parameters' => null,
|
||||
'description' => null,
|
||||
'parameters' => NULL,
|
||||
'description' => NULL,
|
||||
),
|
||||
);
|
||||
|
|
@ -4,3 +4,4 @@ description: 'Provides an automated way to run cron jobs, by executing them at t
|
|||
package: Core
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
configure: system.cron_settings
|
||||
|
|
|
@ -190,7 +190,8 @@ function hook_block_build_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\
|
|||
* @param \Drupal\block\Entity\Block $block
|
||||
* The block instance.
|
||||
* @param string $operation
|
||||
* The operation to be performed, e.g., 'view', 'create', 'delete', 'update'.
|
||||
* The operation to be performed; for instance, 'view', 'create', 'delete', or
|
||||
* 'update'.
|
||||
* @param \Drupal\Core\Session\AccountInterface $account
|
||||
* The user object to perform the access check operation on.
|
||||
*
|
||||
|
|
|
@ -127,7 +127,22 @@ class BlockAccessControlHandler extends EntityAccessControlHandler implements En
|
|||
}
|
||||
elseif ($this->resolveConditions($conditions, 'and') !== FALSE) {
|
||||
// Delegate to the plugin.
|
||||
$access = $entity->getPlugin()->access($account, TRUE);
|
||||
$block_plugin = $entity->getPlugin();
|
||||
try {
|
||||
if ($block_plugin instanceof ContextAwarePluginInterface) {
|
||||
$contexts = $this->contextRepository->getRuntimeContexts(array_values($block_plugin->getContextMapping()));
|
||||
$this->contextHandler->applyContextMapping($block_plugin, $contexts);
|
||||
}
|
||||
$access = $block_plugin->access($account, TRUE);
|
||||
}
|
||||
catch (ContextException $e) {
|
||||
// Setting access to forbidden if any context is missing for the same
|
||||
// reasons as with conditions (described in the comment above).
|
||||
// @todo Avoid setting max-age 0 for some or all cases, for example by
|
||||
// treating available contexts without value differently in
|
||||
// https://www.drupal.org/node/2521956.
|
||||
$access = AccessResult::forbidden()->setCacheMaxAge(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$access = AccessResult::forbidden();
|
||||
|
|
|
@ -211,14 +211,15 @@ class BlockViewBuilder extends EntityViewBuilder {
|
|||
if ($content !== NULL && !Element::isEmpty($content)) {
|
||||
// Place the $content returned by the block plugin into a 'content' child
|
||||
// element, as a way to allow the plugin to have complete control of its
|
||||
// properties and rendering (e.g., its own #theme) without conflicting
|
||||
// with the properties used above, or alternate ones used by alternate
|
||||
// block rendering approaches in contrib (e.g., Panels). However, the use
|
||||
// of a child element is an implementation detail of this particular block
|
||||
// rendering approach. Semantically, the content returned by the plugin
|
||||
// "is the" block, and in particular, #attributes and #contextual_links is
|
||||
// information about the *entire* block. Therefore, we must move these
|
||||
// properties from $content and merge them into the top-level element.
|
||||
// properties and rendering (for instance, its own #theme) without
|
||||
// conflicting with the properties used above, or alternate ones used by
|
||||
// alternate block rendering approaches in contrib (for instance, Panels).
|
||||
// However, the use of a child element is an implementation detail of this
|
||||
// particular block rendering approach. Semantically, the content returned
|
||||
// by the plugin "is the" block, and in particular, #attributes and
|
||||
// #contextual_links is information about the *entire* block. Therefore,
|
||||
// we must move these properties from $content and merge them into the
|
||||
// top-level element.
|
||||
foreach (array('#attributes', '#contextual_links') as $property) {
|
||||
if (isset($content[$property])) {
|
||||
$build[$property] += $content[$property];
|
||||
|
@ -232,8 +233,8 @@ class BlockViewBuilder extends EntityViewBuilder {
|
|||
else {
|
||||
// Abort rendering: render as the empty string and ensure this block is
|
||||
// render cached, so we can avoid the work of having to repeatedly
|
||||
// determine whether the block is empty. E.g. modifying or adding entities
|
||||
// could cause the block to no longer be empty.
|
||||
// determine whether the block is empty. For instance, modifying or adding
|
||||
// entities could cause the block to no longer be empty.
|
||||
$build = array(
|
||||
'#markup' => '',
|
||||
'#cache' => $build['#cache'],
|
||||
|
|
|
@ -241,6 +241,7 @@ class BlockUiTest extends WebTestBase {
|
|||
|
||||
$this->drupalGet('');
|
||||
$this->assertText('Test context-aware block');
|
||||
$this->assertText('User context found.');
|
||||
$this->assertRaw($expected_text);
|
||||
|
||||
// Test context mapping allows empty selection for optional contexts.
|
||||
|
@ -251,6 +252,7 @@ class BlockUiTest extends WebTestBase {
|
|||
$this->drupalPostForm(NULL, $edit, 'Save block');
|
||||
$this->drupalGet('');
|
||||
$this->assertText('No context mapping selected.');
|
||||
$this->assertNoText('User context found.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -265,7 +265,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
|
||||
$this->assertTrue(empty($result), 'The title is not visible.');
|
||||
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:system.site', 'config:views.view.test_view_block' ,'rendered']));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:system.site', 'config:views.view.test_view_block' , 'rendered']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -291,7 +291,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
$this->assertEqual(0, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
|
||||
// Ensure that the view cachability metadata is propagated even, for an
|
||||
// empty block.
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
|
||||
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
|
||||
|
||||
// Add a header displayed on empty result.
|
||||
|
@ -309,7 +309,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
|
||||
$this->drupalGet($url);
|
||||
$this->assertEqual(1, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
|
||||
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
|
||||
|
||||
// Hide the header on empty results.
|
||||
|
@ -327,7 +327,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
|
||||
$this->drupalGet($url);
|
||||
$this->assertEqual(0, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
|
||||
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
|
||||
|
||||
// Add an empty text.
|
||||
|
@ -344,7 +344,7 @@ class DisplayBlockTest extends ViewTestBase {
|
|||
|
||||
$this->drupalGet($url);
|
||||
$this->assertEqual(1, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
|
||||
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
|
||||
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
namespace Drupal\block_test\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\user\UserInterface;
|
||||
|
||||
/**
|
||||
* Provides a context-aware block.
|
||||
|
@ -35,4 +37,15 @@ class TestContextAwareBlock extends BlockBase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function blockAccess(AccountInterface $account) {
|
||||
if ($this->getContextValue('user') instanceof UserInterface) {
|
||||
drupal_set_message('User context found.');
|
||||
}
|
||||
|
||||
return parent::blockAccess($account);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class RevisionRelationshipsTest extends ViewTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('block_content' ,'block_content_test_views');
|
||||
public static $modules = array('block_content' , 'block_content_test_views');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
|
|
|
@ -58,9 +58,9 @@ class BookExport {
|
|||
* The given node is embedded to its absolute depth in a top level section. For
|
||||
* example, a child node with depth 2 in the hierarchy is contained in
|
||||
* (otherwise empty) <div> elements corresponding to depth 0 and depth 1.
|
||||
* This is intended to support WYSIWYG output - e.g., level 3 sections always
|
||||
* look like level 3 sections, no matter their depth relative to the node
|
||||
* selected to be exported as printer-friendly HTML.
|
||||
* This is intended to support WYSIWYG output; for instance, level 3 sections
|
||||
* always look like level 3 sections, no matter their depth relative to the
|
||||
* node selected to be exported as printer-friendly HTML.
|
||||
*
|
||||
* @param \Drupal\node\NodeInterface $node
|
||||
* The node to export.
|
||||
|
|
|
@ -53,15 +53,15 @@ class Book extends DrupalSqlBase {
|
|||
'mlid' => $this->t('Menu link ID'),
|
||||
'plid' => $this->t('Parent link ID'),
|
||||
'weight' => $this->t('Weight'),
|
||||
'p1' => $this->t('The first mlid in the materialized path.'),
|
||||
'p2' => $this->t('The second mlid in the materialized path.'),
|
||||
'p3' => $this->t('The third mlid in the materialized path.'),
|
||||
'p4' => $this->t('The fourth mlid in the materialized path.'),
|
||||
'p5' => $this->t('The fifth mlid in the materialized path.'),
|
||||
'p6' => $this->t('The sixth mlid in the materialized path.'),
|
||||
'p7' => $this->t('The seventh mlid in the materialized path.'),
|
||||
'p8' => $this->t('The eight mlid in the materialized path.'),
|
||||
'p9' => $this->t('The nine mlid in the materialized path.'),
|
||||
'p1' => $this->t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
|
||||
'p2' => $this->t('The second mlid in the materialized path. See p1.'),
|
||||
'p3' => $this->t('The third mlid in the materialized path. See p1.'),
|
||||
'p4' => $this->t('The fourth mlid in the materialized path. See p1.'),
|
||||
'p5' => $this->t('The fifth mlid in the materialized path. See p1.'),
|
||||
'p6' => $this->t('The sixth mlid in the materialized path. See p1.'),
|
||||
'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
|
||||
'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
|
||||
'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -338,6 +338,9 @@ class BookTest extends WebTestBase {
|
|||
* A book node ID or set to 'new' to create a new book.
|
||||
* @param int|null $parent
|
||||
* (optional) Parent book reference ID. Defaults to NULL.
|
||||
*
|
||||
* @return \Drupal\node\NodeInterface
|
||||
* The created node.
|
||||
*/
|
||||
function createBookNode($book_nid, $parent = NULL) {
|
||||
// $number does not use drupal_static as it should not be reset
|
||||
|
|
|
@ -101,6 +101,32 @@
|
|||
return element;
|
||||
};
|
||||
|
||||
// Overrides default implementation. Used to populate the "classes"
|
||||
// property of the widget's "data" property, which is used for the
|
||||
// "widget styles" functionality
|
||||
// (http://docs.ckeditor.com/#!/guide/dev_styles-section-widget-styles).
|
||||
// Is applied to whatever the main element of the widget is (<figure> or
|
||||
// <img>). The classes in image2_captionedClass are always added due to
|
||||
// a bug in CKEditor. In the case of drupalimage, we don't ever want to
|
||||
// add that class, because the widget template already contains it.
|
||||
// @see http://dev.ckeditor.com/ticket/13888
|
||||
// @see https://www.drupal.org/node/2268941
|
||||
var originalGetClasses = widgetDefinition.getClasses;
|
||||
widgetDefinition.getClasses = function () {
|
||||
var classes = originalGetClasses.call(this);
|
||||
var captionedClasses = (this.editor.config.image2_captionedClass || '').split(/\s+/);
|
||||
|
||||
if (captionedClasses.length && classes) {
|
||||
for (var i = 0; i < captionedClasses.length; i++) {
|
||||
if (captionedClasses[i] in classes) {
|
||||
delete classes[captionedClasses[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return classes;
|
||||
};
|
||||
|
||||
// Protected; keys of the widget data to be sent to the Drupal dialog.
|
||||
// Keys in the hash are the keys for image2's data, values are the keys
|
||||
// that the Drupal dialog uses.
|
||||
|
|
|
@ -244,6 +244,27 @@
|
|||
};
|
||||
// Low priority to ensure drupalimage's event handler runs first.
|
||||
}, null, null, 20);
|
||||
},
|
||||
|
||||
afterInit: function (editor) {
|
||||
var disableButtonIfOnWidget = function (evt) {
|
||||
var widget = editor.widgets.focused;
|
||||
if (widget && widget.name === 'image') {
|
||||
this.setState(CKEDITOR.TRISTATE_DISABLED);
|
||||
evt.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
// Disable alignment buttons if the align filter is not enabled.
|
||||
if (editor.plugins.justify && !editor.config.drupalImageCaption_alignFilterEnabled) {
|
||||
var cmd;
|
||||
var commands = ['justifyleft', 'justifycenter', 'justifyright', 'justifyblock'];
|
||||
for (var n = 0; n < commands.length; n++) {
|
||||
cmd = editor.getCommand(commands[n]);
|
||||
cmd.contextSensitive = 1;
|
||||
cmd.on('refresh', disableButtonIfOnWidget, null, null, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ use Drupal\editor\Entity\Editor;
|
|||
* or enable themselves based on the configuration of another setting, such as
|
||||
* enabling based on a particular button being present in the toolbar.
|
||||
*
|
||||
* If a contextually enabled CKEditor plugin must also be configurable (e.g. in
|
||||
* the case where it must be enabled based on an explicit setting), then one
|
||||
* must also implement the CKEditorPluginConfigurableInterface interface.
|
||||
* If a contextually enabled CKEditor plugin must also be configurable (for
|
||||
* instance, in the case where it must be enabled based on an explicit setting),
|
||||
* then one must also implement the CKEditorPluginConfigurableInterface
|
||||
* interface.
|
||||
*
|
||||
* @see \Drupal\ckeditor\CKEditorPluginInterface
|
||||
* @see \Drupal\ckeditor\CKEditorPluginButtonsInterface
|
||||
|
|
|
@ -477,11 +477,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
|
|||
// Once validated, an element or its property cannot be
|
||||
// invalidated by another rule.
|
||||
// That means that the most permissive setting wins. Which means that
|
||||
// it will still be allowed by CKEditor to e.g. define any style, no
|
||||
// matter what the "*" tag's restrictions may be. If there's a setting
|
||||
// for either the "style" or "class" attribute, it cannot possibly be
|
||||
// more permissive than what was set above. Hence: inherit from the
|
||||
// "*" tag where possible.
|
||||
// it will still be allowed by CKEditor, for instance, to define any
|
||||
// style, no matter what the "*" tag's restrictions may be. If there
|
||||
// is a setting for either the "style" or "class" attribute, it cannot
|
||||
// possibly be more permissive than what was set above. Hence, inherit
|
||||
// from the "*" tag where possible.
|
||||
if (isset($html_restrictions['allowed']['*'])) {
|
||||
$wildcard = $html_restrictions['allowed']['*'];
|
||||
if (isset($wildcard['style'])) {
|
||||
|
|
|
@ -187,8 +187,8 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// Hidden CKEditor instance. We need a hidden CKEditor instance with all
|
||||
// plugins enabled, so we can retrieve CKEditor's per-feature metadata (on
|
||||
// which tags, attributes, styles and classes are enabled). This metadata is
|
||||
// necessary for certain filters' (e.g. the html_filter filter) settings to
|
||||
// be updated accordingly.
|
||||
// necessary for certain filters' (for instance, the html_filter filter)
|
||||
// settings to be updated accordingly.
|
||||
// Get a list of all external plugins and their corresponding files.
|
||||
$plugins = array_keys($this->ckeditorPluginManager->getDefinitions());
|
||||
$all_external_plugins = array();
|
||||
|
@ -348,9 +348,10 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
// If this language code is available in a Drupal mapping, use that to
|
||||
// compute a possibility for matching from the Drupal langcode to the
|
||||
// CKEditor langcode.
|
||||
// e.g. CKEditor uses the langcode 'no' for Norwegian, Drupal uses 'nb'.
|
||||
// This would then remove the 'no' => 'no' mapping and replace it with
|
||||
// 'nb' => 'no'. Now Drupal knows which CKEditor translation to load.
|
||||
// For instance, CKEditor uses the langcode 'no' for Norwegian, Drupal
|
||||
// uses 'nb'. This would then remove the 'no' => 'no' mapping and replace
|
||||
// it with 'nb' => 'no'. Now Drupal knows which CKEditor translation to
|
||||
// load.
|
||||
if (isset($language_mappings[$langcode]) && !isset($langcodes[$language_mappings[$langcode]])) {
|
||||
$langcodes[$language_mappings[$langcode]] = $langcode;
|
||||
unset($langcodes[$langcode]);
|
||||
|
|
|
@ -247,7 +247,7 @@
|
|||
var i = inputs.length;
|
||||
if (inputs.length) {
|
||||
var toggleClick = true;
|
||||
var lock = $('<button class="color-palette__lock link">' + Drupal.t('Unlock') + '</button>').on('click', function (e) {
|
||||
var lock = $('<button class="color-palette__lock">' + Drupal.t('Unlock') + '</button>').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
if (toggleClick) {
|
||||
$(this).addClass('is-unlocked').html(Drupal.t('Lock'));
|
||||
|
|
|
@ -9,7 +9,7 @@ use Drupal\Core\Asset\CssOptimizer;
|
|||
use Drupal\Component\Utility\Bytes;
|
||||
use Drupal\Component\Utility\Environment;
|
||||
use Drupal\Core\Block\BlockPluginInterface;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Render\Element\Textfield;
|
||||
|
@ -118,9 +118,13 @@ function color_block_view_system_branding_block_alter(array &$build, BlockPlugin
|
|||
*/
|
||||
function color_block_view_pre_render(array $build) {
|
||||
$theme_key = \Drupal::theme()->getActiveTheme()->getName();
|
||||
$config = \Drupal::config('color.theme.' . $theme_key);
|
||||
CacheableMetadata::createFromRenderArray($build)
|
||||
->addCacheableDependency($config)
|
||||
->applyTo($build);
|
||||
|
||||
// Override logo.
|
||||
$logo = \Drupal::config('color.theme.' . $theme_key)->get('logo');
|
||||
$logo = $config->get('logo');
|
||||
if ($logo && $build['content']['site_logo'] && preg_match('!' . $theme_key . '/logo.svg$!', $build['content']['site_logo']['#uri'])) {
|
||||
$build['content']['site_logo']['#uri'] = file_create_url($logo);
|
||||
}
|
||||
|
@ -193,7 +197,6 @@ function color_get_palette($theme, $default = FALSE) {
|
|||
* @see color_scheme_form_submit()
|
||||
*/
|
||||
function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) {
|
||||
$base = drupal_get_path('module', 'color');
|
||||
$info = color_get_info($theme);
|
||||
|
||||
$info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
|
||||
|
@ -500,9 +503,6 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
|
|||
->set('stylesheets', $css)
|
||||
->set('files', $paths['files'])
|
||||
->save();
|
||||
|
||||
// Clear the library cache.
|
||||
Cache::invalidateTags(['library_info']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
6
core/modules/color/color.services.yml
Normal file
6
core/modules/color/color.services.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
services:
|
||||
color.config_cache_invalidator:
|
||||
class: Drupal\color\EventSubscriber\ColorConfigCacheInvalidator
|
||||
arguments: ['@cache_tags.invalidator']
|
||||
tags:
|
||||
- { name: event_subscriber }
|
|
@ -74,6 +74,8 @@ button.color-palette__lock,
|
|||
left: -10px;
|
||||
direction: ltr;
|
||||
text-indent: -9999px;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
}
|
||||
[dir="rtl"] button.color-palette__lock,
|
||||
[dir="rtl"] .color-palette__lock {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\color\EventSubscriber\ColorConfigCacheInvalidator.
|
||||
*/
|
||||
|
||||
namespace Drupal\color\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
|
||||
use Drupal\Core\Config\ConfigCrudEvent;
|
||||
use Drupal\Core\Config\ConfigEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* A subscriber invalidating cache tags when color config objects are saved.
|
||||
*/
|
||||
class ColorConfigCacheInvalidator implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* The cache tags invalidator.
|
||||
*
|
||||
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
|
||||
*/
|
||||
protected $cacheTagsInvalidator;
|
||||
|
||||
/**
|
||||
* Constructs a ColorConfigCacheInvalidator object.
|
||||
*
|
||||
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
|
||||
* The cache tags invalidator.
|
||||
*/
|
||||
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
|
||||
$this->cacheTagsInvalidator = $cache_tags_invalidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate cache tags when a color theme config object changes.
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigCrudEvent $event
|
||||
* The Event to process.
|
||||
*/
|
||||
public function onChange(ConfigCrudEvent $event) {
|
||||
// Changing a theme's color settings causes the theme's asset library
|
||||
// containing the color CSS file to be altered to use a different file.
|
||||
if (strpos($event->getConfig()->getName(), 'color.theme.') === 0) {
|
||||
$this->cacheTagsInvalidator->invalidateTags(['library_info']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
$events[ConfigEvents::SAVE][] = ['onChange'];
|
||||
$events[ConfigEvents::DELETE][] = ['onChange'];
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,7 +22,7 @@ class ColorTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('color', 'color_test');
|
||||
public static $modules = array('color', 'color_test', 'block', 'file');
|
||||
|
||||
/**
|
||||
* A user with administrative permissions.
|
||||
|
@ -194,4 +194,43 @@ class ColorTest extends WebTestBase {
|
|||
$this->assertIdentical($GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png', $this->getDrupalSettings()['color']['logo']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the scheme can be set, viewed anonymously and reset.
|
||||
*/
|
||||
function testOverrideAndResetScheme() {
|
||||
$settings_path = 'admin/appearance/settings/bartik';
|
||||
$this->config('system.theme')
|
||||
->set('default', 'bartik')
|
||||
->save();
|
||||
|
||||
// Place branding block with site name and slogan into header region.
|
||||
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
|
||||
|
||||
$this->drupalGet('');
|
||||
$this->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
|
||||
$this->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
|
||||
|
||||
// Log in and set the color scheme to 'slate'.
|
||||
$this->drupalLogin($this->bigUser);
|
||||
$edit['scheme'] = 'slate';
|
||||
$this->drupalPostForm($settings_path, $edit, t('Save configuration'));
|
||||
|
||||
// Visit the homepage and ensure color changes.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet('');
|
||||
$this->assertRaw('files/color/bartik-', 'Make sure the color logo is being used.');
|
||||
$this->assertNoRaw('bartik/logo.svg', 'Make sure the original bartik logo does not exist.');
|
||||
|
||||
// Log in and set the color scheme back to default (delete config).
|
||||
$this->drupalLogin($this->bigUser);
|
||||
$edit['scheme'] = 'default';
|
||||
$this->drupalPostForm($settings_path, $edit, t('Save configuration'));
|
||||
|
||||
// Log out and ensure there is no color and we have the original logo.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet('');
|
||||
$this->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
|
||||
$this->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -245,7 +245,8 @@ function comment_node_view_alter(array &$build, EntityInterface $node, EntityVie
|
|||
* @param \Drupal\comment\CommentInterface $comment
|
||||
* The comment object.
|
||||
* @param $view_mode
|
||||
* (optional) View mode; e.g., 'full', 'teaser', etc. Defaults to 'full'.
|
||||
* (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to
|
||||
* 'full'.
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
|
@ -266,7 +267,8 @@ function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode
|
|||
* @param $comments
|
||||
* An array of comments as returned by entity_load_multiple().
|
||||
* @param $view_mode
|
||||
* View mode; e.g., 'full', 'teaser', etc.
|
||||
* (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to
|
||||
* 'full'.
|
||||
* @param $langcode
|
||||
* (optional) A string indicating the language field values are to be shown
|
||||
* in. If no language is provided the current content language is used.
|
||||
|
@ -641,8 +643,8 @@ function template_preprocess_comment(&$variables) {
|
|||
}
|
||||
|
||||
if (theme_get_setting('features.comment_user_picture')) {
|
||||
// To change user picture settings (e.g., image style), edit the 'compact'
|
||||
// view mode on the User entity.
|
||||
// To change user picture settings (for instance, image style), edit the
|
||||
// 'compact' view mode on the User entity.
|
||||
$variables['user_picture'] = user_view($account, 'compact');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -25,6 +25,7 @@ class NodeComment extends InOperator {
|
|||
CommentItemInterface::CLOSED => $this->t('Closed'),
|
||||
CommentItemInterface::OPEN => $this->t('Open'),
|
||||
);
|
||||
return $this->valueOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class CommentInterfaceTest extends CommentTestBase {
|
|||
/**
|
||||
* Set up comments to have subject and preview disabled.
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->drupalLogin($this->adminUser);
|
||||
// Make sure that comment field title is not displayed when there's no
|
||||
|
|
|
@ -240,7 +240,7 @@ class CommentNonNodeTest extends WebTestBase {
|
|||
* @param string $subject
|
||||
* Comment subject to find.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
* Comment ID.
|
||||
*/
|
||||
function getUnapprovedComment($subject) {
|
||||
|
|
|
@ -129,7 +129,7 @@ class CommentPreviewTest extends CommentTestBase {
|
|||
* Tests comment edit, preview, and save.
|
||||
*/
|
||||
function testCommentEditPreviewSave() {
|
||||
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments'));
|
||||
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments'));
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
|
|
|
@ -288,7 +288,7 @@ abstract class CommentTestBase extends WebTestBase {
|
|||
/**
|
||||
* Sets the value governing restrictions on anonymous comments.
|
||||
*
|
||||
* @param integer $level
|
||||
* @param int $level
|
||||
* The level of the contact information allowed for anonymous comments:
|
||||
* - 0: No contact information allowed.
|
||||
* - 1: Contact information allowed but not required.
|
||||
|
@ -373,7 +373,7 @@ abstract class CommentTestBase extends WebTestBase {
|
|||
* @param string $subject
|
||||
* Comment subject to find.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
* Comment id.
|
||||
*/
|
||||
function getUnapprovedComment($subject) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class CommentLinksTest extends CommentViewKernelTestBase {
|
|||
$view = Views::getView('test_comment');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'approve_comment' => [
|
||||
'table' => 'comment',
|
||||
'field' => 'approve_comment',
|
||||
|
@ -134,7 +134,7 @@ class CommentLinksTest extends CommentViewKernelTestBase {
|
|||
$view = Views::getView('test_comment');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'replyto_comment' => [
|
||||
'table' => 'comment',
|
||||
'field' => 'replyto_comment',
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* - title: Comment title, linked to the comment.
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
* The attributes.class may contain one or more of the following classes:
|
||||
* - comment: The current template type; e.g., 'theming hook'.
|
||||
* - comment: The current template type; for instance, 'theming hook'.
|
||||
* - by-anonymous: Comment by an unregistered user.
|
||||
* - by-{entity-type}-author: Comment by the author of the parent entity,
|
||||
* eg. by-node-author.
|
||||
|
|
|
@ -142,6 +142,9 @@ class ConfigController implements ContainerInjectionInterface {
|
|||
|
||||
$build['diff'] = array(
|
||||
'#type' => 'table',
|
||||
'#attributes' => array(
|
||||
'class' => array('diff'),
|
||||
),
|
||||
'#header' => array(
|
||||
array('data' => t('Active'), 'colspan' => '2'),
|
||||
array('data' => t('Staged'), 'colspan' => '2'),
|
||||
|
|
|
@ -27,7 +27,7 @@ class CacheabilityMetadataConfigOverrideIntegrationTest extends WebTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// @todo If our block does not contain any content then the cache context
|
||||
|
|
|
@ -32,7 +32,7 @@ class CacheabilityMetadataConfigOverrideTest extends KernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('block_content');
|
||||
$this->installConfig(['config_override_test']);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\config\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Config\ConfigNameException;
|
||||
use Drupal\Core\Config\ConfigValueException;
|
||||
|
@ -263,6 +264,7 @@ class ConfigCRUDTest extends KernelTestBase {
|
|||
'string' => 'string',
|
||||
'string_int' => '1',
|
||||
);
|
||||
$data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($data));
|
||||
$this->assertIdentical($config->get(), $data);
|
||||
|
||||
// Re-set each key using Config::set().
|
||||
|
|
|
@ -35,13 +35,10 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
$add_key = 'biff';
|
||||
$add_data = 'bangpow';
|
||||
$change_data = 'foobar';
|
||||
$original_data = array(
|
||||
'foo' => 'bar',
|
||||
'404' => 'herp',
|
||||
);
|
||||
|
||||
// Install the default config.
|
||||
$this->installConfig(array('config_test'));
|
||||
$original_data = \Drupal::config($config_name)->get();
|
||||
|
||||
// Change a configuration value in sync.
|
||||
$sync_data = $original_data;
|
||||
|
@ -95,7 +92,7 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, $config_name);
|
||||
// Prove the fields match.
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual(count($edits), 1, 'There is one item in the diff');
|
||||
|
||||
// Rename the entity.
|
||||
|
@ -105,11 +102,11 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, 'config_test.dynamic.' . $new_test_entity_id, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[1]->type, 'change', 'The second item in the diff is a change.');
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[1]->type, 'change', 'The second item in the diff is a change.');
|
||||
$this->assertEqual($edits[1]->orig, array('id: ' . $new_test_entity_id));
|
||||
$this->assertEqual($edits[1]->closing, array('id: ' . $test_entity_id));
|
||||
$this->assertEqual($edits[2]->type, 'copy', 'The third item in the diff is a copy.');
|
||||
$this->assertEqual($edits[2]->type, 'copy', 'The third item in the diff is a copy.');
|
||||
$this->assertEqual(count($edits), 3, 'There are three items in the diff.');
|
||||
}
|
||||
|
||||
|
@ -135,16 +132,16 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
// Test the fields match in the default collection diff.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual(count($edits), 1, 'There is one item in the diff');
|
||||
|
||||
// Test that the differences are detected when diffing the collection.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, NULL, 'test');
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'change', 'The second item in the diff is a copy.');
|
||||
$this->assertEqual($edits[0]->type, 'change', 'The second item in the diff is a copy.');
|
||||
$this->assertEqual($edits[0]->orig, array('foo: bar'));
|
||||
$this->assertEqual($edits[0]->closing, array('foo: baz'));
|
||||
$this->assertEqual($edits[1]->type, 'copy', 'The second item in the diff is a copy.');
|
||||
$this->assertEqual($edits[1]->type, 'copy', 'The second item in the diff is a copy.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class ConfigEntityStaticCacheTest extends KernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->entityTypeId = 'config_test';
|
||||
$this->entityId = 'test_1';
|
||||
|
|
|
@ -311,6 +311,10 @@ class ConfigImportUITest extends WebTestBase {
|
|||
// Deleted value is escaped.
|
||||
$this->assertText(Html::escape("404: '<em>herp</em>'"));
|
||||
|
||||
// Verify diff colors are displayed.
|
||||
$result = $this->xpath('//table[contains(@class, :class)]', array(':class' => 'diff'));
|
||||
$this->assertEqual(count($result), 1, "Diff UI is displaying colors.");
|
||||
|
||||
// Reset data back to original, and remove a key
|
||||
$sync_data = $original_data;
|
||||
unset($sync_data[$remove_key]);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\config\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Core\Config\FileStorage;
|
||||
|
@ -48,6 +49,7 @@ class ConfigInstallProfileOverrideTest extends WebTestBase {
|
|||
'requirements_error' => 1209600,
|
||||
),
|
||||
);
|
||||
$expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data));
|
||||
|
||||
// Verify that the original data matches. We have to read the module config
|
||||
// file directly, because the install profile default system.cron.yml
|
||||
|
@ -85,7 +87,7 @@ class ConfigInstallProfileOverrideTest extends WebTestBase {
|
|||
// type does not exist.
|
||||
$optional_dir = drupal_get_path('module', 'testing_config_overrides') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
|
||||
$optional_storage = new FileStorage($optional_dir);
|
||||
foreach (['config_test.dynamic.dotted.default', 'config_test.dynamic.override','config_test.dynamic.override_unmet'] as $id) {
|
||||
foreach (['config_test.dynamic.dotted.default', 'config_test.dynamic.override', 'config_test.dynamic.override_unmet'] as $id) {
|
||||
$this->assertTrue(\Drupal::config($id)->isNew(), "The config_test entity $id contained in the profile's optional directory does not exist.");
|
||||
// Make that we don't get false positives from the assertion above.
|
||||
$this->assertTrue($optional_storage->exists($id), "The config_test entity $id does exist in the profile's optional directory.");
|
||||
|
|
|
@ -22,7 +22,7 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'language', 'config_test', 'system', 'field');
|
||||
public static $modules = array('user', 'language', 'config_test', 'system', 'field');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -63,6 +63,7 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
$expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
|
||||
$expected['mapping']['langcode']['type'] = 'string';
|
||||
$expected['mapping']['langcode']['label'] = 'Language code';
|
||||
$expected['mapping']['_core']['type'] = '_core_config_info';
|
||||
$expected['mapping']['testitem'] = array('label' => 'Test item');
|
||||
$expected['mapping']['testlist'] = array('label' => 'Test list');
|
||||
$expected['type'] = 'config_schema_test.someschema';
|
||||
|
@ -106,6 +107,7 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
'label' => 'Language code',
|
||||
'type' => 'string',
|
||||
);
|
||||
$expected['mapping']['_core']['type'] = '_core_config_info';
|
||||
$expected['type'] = 'system.maintenance';
|
||||
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
|
||||
$this->assertEqual($definition, $expected, 'Retrieved the right metadata for system.maintenance');
|
||||
|
@ -120,6 +122,7 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
'type' => 'string',
|
||||
'label' => 'Language code',
|
||||
);
|
||||
$expected['mapping']['_core']['type'] = '_core_config_info';
|
||||
$expected['mapping']['label'] = array(
|
||||
'label' => 'Label',
|
||||
'type' => 'label',
|
||||
|
@ -179,6 +182,7 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
$expected['mapping']['third_party_settings']['type'] = 'sequence';
|
||||
$expected['mapping']['third_party_settings']['label'] = 'Third party settings';
|
||||
$expected['mapping']['third_party_settings']['sequence']['type'] = '[%parent.%parent.%type].third_party.[%key]';
|
||||
$expected['mapping']['_core']['type'] = '_core_config_info';
|
||||
$expected['type'] = 'image.style.*';
|
||||
|
||||
$this->assertEqual($definition, $expected);
|
||||
|
@ -231,6 +235,7 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
$expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
|
||||
$expected['mapping']['langcode']['type'] = 'string';
|
||||
$expected['mapping']['langcode']['label'] = 'Language code';
|
||||
$expected['mapping']['_core']['type'] = '_core_config_info';
|
||||
$expected['mapping']['testid']['type'] = 'string';
|
||||
$expected['mapping']['testid']['label'] = 'ID';
|
||||
$expected['mapping']['testdescription']['type'] = 'text';
|
||||
|
@ -386,7 +391,9 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
$extension_path = drupal_get_path('module', 'config_schema_test');
|
||||
$install_storage = new FileStorage($extension_path . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY);
|
||||
$original_data = $install_storage->read('config_schema_test.ignore');
|
||||
$this->assertIdentical($this->config('config_schema_test.ignore')->get(), $original_data);
|
||||
$installed_data = $this->config('config_schema_test.ignore')->get();
|
||||
unset($installed_data['_core']);
|
||||
$this->assertIdentical($installed_data, $original_data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -401,6 +408,7 @@ class ConfigSchemaTest extends KernelTestBase {
|
|||
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
|
||||
$expected['mapping']['langcode']['type'] = 'string';
|
||||
$expected['mapping']['langcode']['label'] = 'Language code';
|
||||
$expected['mapping']['_core']['type'] = '_core_config_info';
|
||||
$expected['mapping']['testid']['type'] = 'string';
|
||||
$expected['mapping']['testid']['label'] = 'ID';
|
||||
$expected['mapping']['testdescription']['type'] = 'text';
|
||||
|
|
|
@ -202,7 +202,7 @@ EOD;
|
|||
$this->assertIdentical($expected_options, array_intersect($expected_options, $options), 'The expected configuration files are listed.');
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/system.simple/system.image');
|
||||
$this->assertFieldByXPath('//textarea[@name="export"]', "toolkit: gd\n", 'The expected system configuration is displayed.');
|
||||
$this->assertFieldByXPath('//textarea[@name="export"]', "toolkit: gd\n_core:\n default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\n", 'The expected system configuration is displayed.');
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/date_format');
|
||||
$this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Date format'), 'The date format entity type is selected when specified in the URL.');
|
||||
|
|
|
@ -87,13 +87,14 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
if (!isset($this->discovery)) {
|
||||
// Look at all themes and modules.
|
||||
// @todo If the list of installed modules and themes is changed, new
|
||||
// definitions are not picked up immediately and obsolete definitions are
|
||||
// not removed, because the list of search directories is only compiled
|
||||
// once in this constructor. The current code only works due to
|
||||
// coincidence: The request that installs e.g. a new theme does not
|
||||
// instantiate this plugin manager at the beginning of the request; when
|
||||
// routes are being rebuilt at the end of the request, this service only
|
||||
// happens to get instantiated with the updated list of installed themes.
|
||||
// definitions are not picked up immediately and obsolete definitions
|
||||
// are not removed, because the list of search directories is only
|
||||
// compiled once in this constructor. The current code only works due to
|
||||
// coincidence: The request that installs (for instance, a new theme)
|
||||
// does not instantiate this plugin manager at the beginning of the
|
||||
// request; when routes are being rebuilt at the end of the request,
|
||||
// this service only happens to get instantiated with the updated list
|
||||
// of installed themes.
|
||||
$directories = array();
|
||||
foreach ($this->moduleHandler->getModuleList() as $name => $module) {
|
||||
$directories[$name] = $module->getPath();
|
||||
|
|
|
@ -116,8 +116,8 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
|
|||
* An associative array containing the structure of the form.
|
||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* The current state of the form.
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* (optional) Page request object.
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* (optional) The route match.
|
||||
* @param string $plugin_id
|
||||
* (optional) The plugin ID of the mapper.
|
||||
* @param string $langcode
|
||||
|
|
|
@ -37,15 +37,15 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
|
|||
* Performs various assertions on a single contact form entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The contact form ID.
|
||||
* The contact form ID.
|
||||
* @param string $expected_label
|
||||
* The expected label.
|
||||
* The expected label.
|
||||
* @param string[] $expected_recipients
|
||||
* The recipient e-mail addresses the form should have.
|
||||
* The recipient e-mail addresses the form should have.
|
||||
* @param string $expected_reply
|
||||
* The expected reply message.
|
||||
* @param integer $expected_weight
|
||||
* The contact form's expected weight.
|
||||
* The expected reply message.
|
||||
* @param int $expected_weight
|
||||
* The contact form's expected weight.
|
||||
*/
|
||||
protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
|
||||
/** @var \Drupal\contact\ContactFormInterface $entity */
|
||||
|
|
|
@ -30,7 +30,7 @@ class ContactCategoryTest extends MigrateSqlSourceTestCase {
|
|||
array(
|
||||
'cid' => 1,
|
||||
'category' => 'contact category value 1',
|
||||
'recipients' => array('admin@example.com','user@example.com'),
|
||||
'recipients' => array('admin@example.com', 'user@example.com'),
|
||||
'reply' => 'auto reply value 1',
|
||||
'weight' => 0,
|
||||
'selected' => 0,
|
||||
|
@ -38,7 +38,7 @@ class ContactCategoryTest extends MigrateSqlSourceTestCase {
|
|||
array(
|
||||
'cid' => 2,
|
||||
'category' => 'contact category value 2',
|
||||
'recipients' => array('admin@example.com','user@example.com'),
|
||||
'recipients' => array('admin@example.com', 'user@example.com'),
|
||||
'reply' => 'auto reply value 2',
|
||||
'weight' => 0,
|
||||
'selected' => 0,
|
||||
|
|
|
@ -96,9 +96,9 @@ function content_translation_language_types_info_alter(array &$language_types) {
|
|||
* canonical link template cannot be enabled for translation. Setting this key
|
||||
* to TRUE overrides that. When that key is set, the Content Translation
|
||||
* module will not provide any UI for translating the entity type, and the
|
||||
* entity type should implement its own UI. This is useful for (e.g.) entity
|
||||
* types that are embedded into others for editing (which would not need a
|
||||
* canonical link, but could still support translation).
|
||||
* entity type should implement its own UI. For instance, this is useful for
|
||||
* entity types that are embedded into others for editing (which would not
|
||||
* need a canonical link, but could still support translation).
|
||||
* - content_translation_metadata: To implement its business logic the content
|
||||
* translation UI relies on various metadata items describing the translation
|
||||
* state. The default implementation is provided by
|
||||
|
|
|
@ -177,8 +177,8 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
|
|||
protected function hasAuthor() {
|
||||
// Check for field named uid, but only in case the entity implements the
|
||||
// EntityOwnerInterface. This helps to exclude cases, where the uid is
|
||||
// defined as field name, but is not meant to be an owner field e.g. the
|
||||
// User entity.
|
||||
// defined as field name, but is not meant to be an owner field; for
|
||||
// instance, the User entity.
|
||||
return $this->entityType->isSubclassOf('\Drupal\user\EntityOwnerInterface') && $this->checkFieldStorageDefinitionTranslatability('uid');
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
|
|||
// Update #title attribute for all elements that are allowed to have a
|
||||
// #title attribute according to the Form API Reference. The reason for this
|
||||
// check is because some elements have a #title attribute even though it is
|
||||
// not rendered, e.g. field containers.
|
||||
// not rendered; for instance, field containers.
|
||||
if (isset($element['#type']) && isset($fapi_title_elements[$element['#type']]) && isset($element['#title'])) {
|
||||
$element['#title'] .= $suffix;
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
|
|||
*
|
||||
* @param array $items
|
||||
* An array of field items.
|
||||
* @param integer $delta
|
||||
* @param int $delta
|
||||
* The delta identifying the item to be processed.
|
||||
* @param array $columns
|
||||
* An array of column names to be synchronized.
|
||||
|
|
|
@ -48,7 +48,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
|
|||
/**
|
||||
* The field cardinality.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $cardinality;
|
||||
|
||||
|
|
|
@ -27,22 +27,6 @@ class Date extends NumericDate {
|
|||
return "$this->tableAlias.$this->realField";
|
||||
}
|
||||
|
||||
/**
|
||||
* Override query to provide 'second' granularity.
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensureMyTable();
|
||||
switch ($this->options['granularity']) {
|
||||
case 'second':
|
||||
$formula = $this->getDateFormat('YmdHis');
|
||||
$this->query->addOrderBy(NULL, $formula, $this->options['order'], $this->tableAlias . '_' . $this->field . '_' . $this->options['granularity']);
|
||||
return;
|
||||
}
|
||||
|
||||
// All other granularities are handled by the numeric sort handler.
|
||||
parent::query();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
|
|
|
@ -24,7 +24,7 @@ class ArgumentDateTimeTest extends DateTimeHandlerTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Add some basic test nodes.
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class DateTimeHandlerTestBase extends HandlerTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Add a date field to page nodes.
|
||||
|
|
|
@ -32,7 +32,7 @@ class FilterDateTest extends DateTimeHandlerTestBase {
|
|||
*
|
||||
* Create nodes with relative dates of yesterday, today, and tomorrow.
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Set to 'today'.
|
||||
|
|
|
@ -34,7 +34,7 @@ class FilterDateTimeTest extends DateTimeHandlerTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
static::$date = REQUEST_TIME + 86400;
|
||||
|
|
|
@ -24,7 +24,7 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Add some basic test nodes.
|
||||
|
@ -33,6 +33,9 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
|
|||
'2000-10-10T00:01:00',
|
||||
'2000-10-10T00:02:00',
|
||||
'2000-10-10T00:03:00',
|
||||
'2000-10-10T00:03:02',
|
||||
'2000-10-10T00:03:01',
|
||||
'2000-10-10T00:03:03',
|
||||
];
|
||||
foreach ($dates as $date) {
|
||||
$this->nodes[] = $this->drupalCreateNode([
|
||||
|
@ -50,7 +53,8 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
|
|||
$field = static::$field_name . '_value';
|
||||
$view = Views::getView('test_sort_datetime');
|
||||
|
||||
// Sort order is DESC.
|
||||
// Set granularity to 'minute', and the secondary node ID order should
|
||||
// define the order of nodes with the same minute.
|
||||
$view->initHandlers();
|
||||
$view->sort[$field]->options['granularity'] = 'minute';
|
||||
$view->setDisplay('default');
|
||||
|
@ -58,6 +62,9 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
|
|||
$expected_result = [
|
||||
['nid' => $this->nodes[0]->id()],
|
||||
['nid' => $this->nodes[3]->id()],
|
||||
['nid' => $this->nodes[4]->id()],
|
||||
['nid' => $this->nodes[5]->id()],
|
||||
['nid' => $this->nodes[6]->id()],
|
||||
['nid' => $this->nodes[2]->id()],
|
||||
['nid' => $this->nodes[1]->id()],
|
||||
];
|
||||
|
@ -74,6 +81,9 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
|
|||
['nid' => $this->nodes[1]->id()],
|
||||
['nid' => $this->nodes[2]->id()],
|
||||
['nid' => $this->nodes[3]->id()],
|
||||
['nid' => $this->nodes[5]->id()],
|
||||
['nid' => $this->nodes[4]->id()],
|
||||
['nid' => $this->nodes[6]->id()],
|
||||
['nid' => $this->nodes[0]->id()],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
|
@ -91,6 +101,27 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
|
|||
['nid' => $this->nodes[1]->id()],
|
||||
['nid' => $this->nodes[2]->id()],
|
||||
['nid' => $this->nodes[3]->id()],
|
||||
['nid' => $this->nodes[4]->id()],
|
||||
['nid' => $this->nodes[5]->id()],
|
||||
['nid' => $this->nodes[6]->id()],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
$view->destroy();
|
||||
|
||||
// Change granularity to 'second'.
|
||||
$view->initHandlers();
|
||||
$view->sort[$field]->options['granularity'] = 'second';
|
||||
$view->sort[$field]->options['order'] = 'DESC';
|
||||
$view->setDisplay('default');
|
||||
$this->executeView($view);
|
||||
$expected_result = [
|
||||
['nid' => $this->nodes[0]->id()],
|
||||
['nid' => $this->nodes[6]->id()],
|
||||
['nid' => $this->nodes[4]->id()],
|
||||
['nid' => $this->nodes[5]->id()],
|
||||
['nid' => $this->nodes[3]->id()],
|
||||
['nid' => $this->nodes[2]->id()],
|
||||
['nid' => $this->nodes[1]->id()],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
$view->destroy();
|
||||
|
|
|
@ -238,6 +238,9 @@ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_
|
|||
/**
|
||||
* Loads an individual configured text editor based on text format ID.
|
||||
*
|
||||
* @param int $format_id
|
||||
* A text format ID.
|
||||
*
|
||||
* @return \Drupal\editor\Entity\Editor|null
|
||||
* A text editor object, or NULL.
|
||||
*/
|
||||
|
|
|
@ -2,6 +2,8 @@ editor.filter_xss:
|
|||
path: '/editor/filter_xss/{filter_format}'
|
||||
defaults:
|
||||
_controller: '\Drupal\editor\EditorController::filterXss'
|
||||
options:
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_entity_access: 'filter_format.use'
|
||||
|
||||
|
@ -23,6 +25,8 @@ editor.image_dialog:
|
|||
defaults:
|
||||
_form: '\Drupal\editor\Form\EditorImageDialog'
|
||||
_title: 'Upload image'
|
||||
options:
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_entity_access: 'filter_format.use'
|
||||
|
||||
|
@ -31,5 +35,7 @@ editor.link_dialog:
|
|||
defaults:
|
||||
_form: '\Drupal\editor\Form\EditorLinkDialog'
|
||||
_title: 'Add link'
|
||||
options:
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_entity_access: 'filter_format.use'
|
||||
|
|
|
@ -59,6 +59,11 @@ class Editor extends PluginBase implements InPlaceEditorInterface {
|
|||
|
||||
/**
|
||||
* Returns whether the text format has transformation filters.
|
||||
*
|
||||
* @param int $format_id
|
||||
* A text format ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function textFormatHasTransformationFilters($format_id) {
|
||||
$format = entity_load('filter_format', $format_id);
|
||||
|
|
|
@ -111,7 +111,17 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the in-place editor that Edit selects.
|
||||
* Returns the in-place editor that quickedit selects.
|
||||
*
|
||||
* @param int $entity_id
|
||||
* An entity ID.
|
||||
* @param string $field_name
|
||||
* A field name.
|
||||
* @param string $view_mode
|
||||
* A view mode.
|
||||
*
|
||||
* @return string
|
||||
* Returns the selected in-place editor.
|
||||
*/
|
||||
protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
|
||||
$entity = entity_load('entity_test', $entity_id, TRUE);
|
||||
|
|
|
@ -78,7 +78,7 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
|
|||
// Forbid any update that removes allowed values with actual data.
|
||||
$allowed_values = $field_storage->getSetting('allowed_values');
|
||||
$prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
|
||||
$lost_keys = array_keys(array_diff_key($prior_allowed_values,$allowed_values));
|
||||
$lost_keys = array_keys(array_diff_key($prior_allowed_values, $allowed_values));
|
||||
if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
|
||||
throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
|
||||
}
|
||||
|
@ -106,9 +106,9 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
|
|||
* subclassing \Drupal\Core\Field\WidgetBase). Widget plugins need to be in the
|
||||
* namespace \Drupal\{your_module}\Plugin\Field\FieldWidget.
|
||||
*
|
||||
* Widgets are @link forms_api_reference.html Form API @endlink
|
||||
* elements with additional processing capabilities. The methods of the
|
||||
* WidgetInterface object are typically called by respective methods in the
|
||||
* Widgets are @link form_api Form API @endlink elements with additional
|
||||
* processing capabilities. The methods of the WidgetInterface object are
|
||||
* typically called by respective methods in the
|
||||
* \Drupal\Core\Entity\Entity\EntityFormDisplay class.
|
||||
*
|
||||
* @see field
|
||||
|
|
|
@ -30,7 +30,7 @@ class FieldTypeDefaults extends ProcessPluginBase {
|
|||
$value = 'datetime_default';
|
||||
}
|
||||
else {
|
||||
throw new MigrateException(sprintf('Failed to lookup %s in the static map.', var_export($value, TRUE)));
|
||||
throw new MigrateException(sprintf('Failed to lookup field type %s in the static map.', var_export($value, TRUE)));
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
|
|
2
core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
Executable file → Normal file
2
core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
Executable file → Normal file
|
@ -34,7 +34,7 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
|
|||
'type',
|
||||
'module',
|
||||
))
|
||||
->condition('fci.entity_type','node');
|
||||
->condition('fci.entity_type', 'node');
|
||||
$query->join('field_config', 'fc', 'fci.field_id = fc.id');
|
||||
return $query;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class SqlContentEntityStorageSchemaColumnTest extends KernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('entity_test_rev');
|
||||
|
|
|
@ -36,7 +36,7 @@ class EntityReferenceFileUploadTest extends WebTestBase {
|
|||
/**
|
||||
* Node id.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $nodeId;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class EntityReferenceRelationshipTest extends ViewKernelTestBase {
|
|||
$this->installEntitySchema('entity_test_mul');
|
||||
|
||||
// Create reference from entity_test to entity_test_mul.
|
||||
$this->createEntityReferenceField('entity_test','entity_test','field_test_data','field_test_data','entity_test_mul');
|
||||
$this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_data', 'field_test_data', 'entity_test_mul');
|
||||
|
||||
// Create reference from entity_test_mul to entity_test.
|
||||
$this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test', 'field_data_test', 'entity_test');
|
||||
|
|
|
@ -36,7 +36,7 @@ class SelectionTest extends WebTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create nodes.
|
||||
|
|
|
@ -80,8 +80,8 @@ class FieldDataCountTest extends FieldUnitTestBase {
|
|||
// Create 12 entities to ensure that the purging works as expected.
|
||||
for ($i=0; $i < 12; $i++) {
|
||||
$entity = entity_create('entity_test');
|
||||
$entity->field_int[] = mt_rand(1,99);
|
||||
$entity->field_int[] = mt_rand(1,99);
|
||||
$entity->field_int[] = mt_rand(1, 99);
|
||||
$entity->field_int[] = mt_rand(1, 99);
|
||||
$entity->name[] = $this->randomMachineName();
|
||||
$entity->save();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class FieldDefaultValueCallbackTest extends WebTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->fieldName = 'field_test';
|
||||
|
|
|
@ -39,22 +39,22 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
|
|||
|
||||
// Integer field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_two');
|
||||
$this->assertIdentical("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// Float field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_three');
|
||||
$this->assertIdentical("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// Link field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_link');
|
||||
$this->assertIdentical("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// File field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_filefield');
|
||||
$this->assertIdentical("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_imagefield');
|
||||
$this->assertIdentical("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', array('@fieldtype' => $field_storage->getType())));
|
||||
$settings = $field_storage->getSettings();
|
||||
$this->assertIdentical('file', $settings['target_type']);
|
||||
$this->assertIdentical('public', $settings['uri_scheme']);
|
||||
|
@ -62,15 +62,15 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
|
|||
|
||||
// Phone field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_phone');
|
||||
$this->assertIdentical("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// Date field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_datetime');
|
||||
$this->assertIdentical("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// Decimal field with radio buttons.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_decimal_radio_buttons');
|
||||
$this->assertIdentical("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertNotNull($field_storage->getSetting('allowed_values')['1.2'], t('First allowed value key is set to 1.2'));
|
||||
$this->assertNotNull($field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value key is set to 2.1'));
|
||||
$this->assertIdentical('1.2', $field_storage->getSetting('allowed_values')['1.2'], t('First allowed value is set to 1.2'));
|
||||
|
@ -78,11 +78,11 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
|
|||
|
||||
// Float field with a single checkbox.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_float_single_checkbox');
|
||||
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// Integer field with a select list.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_integer_selectlist');
|
||||
$this->assertIdentical("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertNotNull($field_storage->getSetting('allowed_values')['1234'], t('First allowed value key is set to 1234'));
|
||||
$this->assertNotNull($field_storage->getSetting('allowed_values')['2341'], t('Second allowed value key is set to 2341'));
|
||||
$this->assertNotNull($field_storage->getSetting('allowed_values')['3412'], t('Third allowed value key is set to 3412'));
|
||||
|
@ -94,7 +94,7 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
|
|||
|
||||
// Text field with a single checkbox.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_text_single_checkbox');
|
||||
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
|
||||
|
||||
// Validate that the source count and processed count match up.
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
|
||||
|
|
|
@ -53,9 +53,9 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID in the form ENTITY_TYPE.FIELD_NAME.
|
||||
* @param string $expected_type
|
||||
* The expected field type.
|
||||
* @param boolean $expected_translatable
|
||||
* @param bool $expected_translatable
|
||||
* Whether or not the field is expected to be translatable.
|
||||
* @param integer $expected_cardinality
|
||||
* @param int $expected_cardinality
|
||||
* The expected cardinality of the field.
|
||||
*/
|
||||
protected function assertEntity($id, $expected_type, $expected_translatable, $expected_cardinality) {
|
||||
|
|
|
@ -371,8 +371,8 @@ class NumberFieldTest extends WebTestBase {
|
|||
$decimal_separators = array('.', ',');
|
||||
$prefix = $this->randomMachineName();
|
||||
$suffix = $this->randomMachineName();
|
||||
$random_float = rand(0,pow(10,6));
|
||||
$random_integer = rand(0, pow(10,6));
|
||||
$random_float = rand(0, pow(10, 6));
|
||||
$random_integer = rand(0, pow(10, 6));
|
||||
|
||||
// Create a content type containing float and integer fields.
|
||||
$this->drupalCreateContentType(array('type' => $type));
|
||||
|
|
|
@ -145,7 +145,7 @@ class TimestampFormatterTest extends KernelTestBase {
|
|||
protected function testTimestampAgoFormatter() {
|
||||
$data = [];
|
||||
|
||||
foreach (array(1,2,3,4,5,6) as $granularity) {
|
||||
foreach (array(1, 2, 3, 4, 5, 6) as $granularity) {
|
||||
$data[] = [
|
||||
'future_format' => '@interval hence',
|
||||
'past_format' => '@interval ago',
|
||||
|
|
|
@ -124,7 +124,7 @@ function field_test_field_widget_form_alter(&$element, FormStateInterface $form_
|
|||
function field_test_query_efq_table_prefixing_test_alter(&$query) {
|
||||
// Add an additional join onto the entity base table. This will cause an
|
||||
// exception if the EFQ does not properly prefix the base table.
|
||||
$query->join('entity_test','et2','%alias.id = entity_test.id');
|
||||
$query->join('entity_test', 'et2', '%alias.id = entity_test.id');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldTypeDefaultsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\field\Plugin\migrate\process\d6\FieldTypeDefaults;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 fields defaults.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\field\Plugin\migrate\process\d6\FieldTypeDefaults
|
||||
* @group field
|
||||
*/
|
||||
class FieldTypeDefaultsTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->plugin = new FieldTypeDefaults([], 'field_type_defaults', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests various default cases.
|
||||
*
|
||||
* @covers ::transform
|
||||
*/
|
||||
public function testDefaults() {
|
||||
$this->row->expects($this->once())
|
||||
->method('getSourceProperty')
|
||||
->willReturn('date');
|
||||
|
||||
// Assert common values are passed through without modification.
|
||||
$this->assertNull($this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'property'));
|
||||
$this->assertEquals('string', $this->plugin->transform('string', $this->migrateExecutable, $this->row, 'property'));
|
||||
$this->assertEquals(1234, $this->plugin->transform(1234, $this->migrateExecutable, $this->row, 'property'));
|
||||
// Assert that an array checks that this is a date field(above mock assert)
|
||||
// and returns "datetime_default".
|
||||
$this->assertEquals('datetime_default', $this->plugin->transform([], $this->migrateExecutable, $this->row, 'property'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests an exception is thrown when the input is not a date field.
|
||||
*
|
||||
* @covers ::transform
|
||||
*/
|
||||
public function testDefaultsException() {
|
||||
$this->setExpectedException(MigrateException::class,
|
||||
sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE)));
|
||||
$this->plugin->transform([], $this->migrateExecutable, $this->row, 'property');
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) {
|
|||
$output .= '<dt>' . t('Configuring view and form modes') . '</dt>';
|
||||
$output .= '<dd>' . t('You can add, edit, and delete view modes for entities on the <a href=":view_modes">View modes page</a>, and you can add, edit, and delete form modes for entities on the <a href=":form_modes">Form modes page</a>. Once you have defined a view mode or form mode for an entity type, it will be available on the Manage display or Manage form display page for each sub-type of that entity.', array(':view_modes' => \Drupal::url('entity.entity_view_mode.collection'), ':form_modes' => \Drupal::url('entity.entity_form_mode.collection'))) . '</dd>';
|
||||
$output .= '<dt>' . t('Listing fields') . '</dt>';
|
||||
$output .= '<dd>' . t('There are two reports available that list the fields defined on your site. The <a href=":entity-list" title="Entities field list report">Entities</a> report lists all your fields, showing the field machine names, types, and the entity types or sub-types they are used on (each sub-type links to the Manage fields page). If the <a href=":views">Views</a> and <a href=":views-ui">Views UI</a> modules are enabled, the <a href=":views-list" title="Used in views field list report">Used in views</a> report lists each field that is used in a view, with a link to edit that view.', array(':entity-list' => \Drupal::url('entity.field_storage_config.collection'), ':views-list' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('views_ui.reports_fields') : '#', ':views' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', array('name' => 'views')) : '#',':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', array('name' => 'views_ui')) : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t('There are two reports available that list the fields defined on your site. The <a href=":entity-list" title="Entities field list report">Entities</a> report lists all your fields, showing the field machine names, types, and the entity types or sub-types they are used on (each sub-type links to the Manage fields page). If the <a href=":views">Views</a> and <a href=":views-ui">Views UI</a> modules are enabled, the <a href=":views-list" title="Used in views field list report">Used in views</a> report lists each field that is used in a view, with a link to edit that view.', array(':entity-list' => \Drupal::url('entity.field_storage_config.collection'), ':views-list' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('views_ui.reports_fields') : '#', ':views' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', array('name' => 'views')) : '#', ':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', array('name' => 'views_ui')) : '#')) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field_ui\FieldUI;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Provides a form for the "field storage" edit page.
|
||||
|
@ -33,6 +34,9 @@ class FieldStorageConfigEditForm extends EntityForm {
|
|||
// The URL of this entity form contains only the ID of the field_config
|
||||
// but we are actually editing a field_storage_config entity.
|
||||
$field_config = FieldConfig::load($route_match->getRawParameter('field_config'));
|
||||
if (!$field_config) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
return $field_config->getFieldStorageDefinition();
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ class EntityDisplayTest extends KernelTestBase {
|
|||
$display->save();
|
||||
$components = array_keys($display->getComponents());
|
||||
// The name field is not configurable so will be added automatically.
|
||||
$expected = array ( 0 => 'component_1', 1 => 'component_2', 2 => 'component_3', 'name');
|
||||
$expected = array ( 0 => 'component_1', 1 => 'component_2', 2 => 'component_3', 'name');
|
||||
$this->assertIdentical($components, $expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ trait FieldUiTestTrait {
|
|||
}
|
||||
|
||||
// First step: 'Add field' page.
|
||||
$this->drupalPostForm($bundle_path, $initial_edit, t('Save and continue'));
|
||||
$this->drupalPostForm($bundle_path, $initial_edit, t('Save and continue'));
|
||||
$this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Storage settings page was displayed.');
|
||||
// Test Breadcrumbs.
|
||||
$this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
|
||||
|
|
|
@ -492,13 +492,13 @@ class ManageFieldsTest extends WebTestBase {
|
|||
// Try with an entity key.
|
||||
$edit['field_name'] = 'title';
|
||||
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
|
||||
$this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue'));
|
||||
$this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue'));
|
||||
$this->assertText(t('The machine-readable name is already in use. It must be unique.'));
|
||||
|
||||
// Try with a base field.
|
||||
$edit['field_name'] = 'sticky';
|
||||
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
|
||||
$this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue'));
|
||||
$this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue'));
|
||||
$this->assertText(t('The machine-readable name is already in use. It must be unique.'));
|
||||
}
|
||||
|
||||
|
@ -718,4 +718,17 @@ class ManageFieldsTest extends WebTestBase {
|
|||
$this->assertEqual($view_display->getComponent('field_test_custom_options')['type'], 'field_test_multiple');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the access to non-existent field URLs.
|
||||
*/
|
||||
public function testNonExistentFieldUrls() {
|
||||
$field_id = 'node.foo.bar';
|
||||
|
||||
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
|
||||
$this->assertResponse(404);
|
||||
|
||||
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id . '/storage');
|
||||
$this->assertResponse(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -96,16 +96,16 @@ function file_requirements($phase) {
|
|||
$value = t('Not enabled');
|
||||
$description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php or PHP-FPM and not as FastCGI.');
|
||||
}
|
||||
elseif (!$implementation && extension_loaded('apc')) {
|
||||
elseif (!$implementation && extension_loaded('apcu')) {
|
||||
$value = t('Not enabled');
|
||||
$description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href=":url">PECL uploadprogress</a>, which supports more than one simultaneous upload.', array(':url' => 'http://pecl.php.net/package/uploadprogress'));
|
||||
}
|
||||
elseif (!$implementation) {
|
||||
$value = t('Not enabled');
|
||||
$description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href=":uploadprogress_url">PECL uploadprogress library</a> (preferred) or to install <a href=":apc_url">APC</a>.', array(':uploadprogress_url' => 'http://pecl.php.net/package/uploadprogress', ':apc_url' => 'http://php.net/apc'));
|
||||
$description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href=":uploadprogress_url">PECL uploadprogress library</a> (preferred) or to install <a href=":apc_url">APC</a>.', array(':uploadprogress_url' => 'http://pecl.php.net/package/uploadprogress', ':apc_url' => 'http://php.net/apcu'));
|
||||
}
|
||||
elseif ($implementation == 'apc') {
|
||||
$value = t('Enabled (<a href=":url">APC RFC1867</a>)', array(':url' => 'http://php.net/manual/apc.configuration.php#ini.apc.rfc1867'));
|
||||
$value = t('Enabled (<a href=":url">APC RFC1867</a>)', array(':url' => 'http://php.net/manual/en/apcu.configuration.php#ini.apcu.rfc1867'));
|
||||
$description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href=":url">PECL uploadprogress library</a> if possible.', array(':url' => 'http://pecl.php.net/package/uploadprogress'));
|
||||
}
|
||||
elseif ($implementation == 'uploadprogress') {
|
||||
|
|
|
@ -913,7 +913,7 @@ function file_progress_implementation() {
|
|||
$implementation = FALSE;
|
||||
|
||||
// We prefer the PECL extension uploadprogress because it supports multiple
|
||||
// simultaneous uploads. APC only supports one at a time.
|
||||
// simultaneous uploads. APCu only supports one at a time.
|
||||
if (extension_loaded('uploadprogress')) {
|
||||
$implementation = 'uploadprogress';
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class FileWidgetAjaxController {
|
|||
}
|
||||
}
|
||||
elseif ($implementation == 'apc') {
|
||||
$status = apc_fetch('upload_' . $key);
|
||||
$status = apcu_fetch('upload_' . $key);
|
||||
if (isset($status['current']) && !empty($status['total'])) {
|
||||
$progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total'])));
|
||||
$progress['percentage'] = round(100 * $status['current'] / $status['total']);
|
||||
|
|
|
@ -47,7 +47,7 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static($plugin_id, $plugin_definition,$configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('element_info'));
|
||||
return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('element_info'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -145,11 +145,11 @@ class EntityFile extends EntityContentBase {
|
|||
* Tries to move or copy a file.
|
||||
*
|
||||
* @param string $source
|
||||
* The source path or URI.
|
||||
* The source path or URI.
|
||||
* @param string $destination
|
||||
* The destination path or URI.
|
||||
* @param integer $replace
|
||||
* FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.
|
||||
* The destination path or URI.
|
||||
* @param int $replace
|
||||
* (optional) FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE on success, FALSE on failure.
|
||||
|
@ -170,9 +170,9 @@ class EntityFile extends EntityContentBase {
|
|||
*
|
||||
* @param \Drupal\migrate\Row $row
|
||||
*
|
||||
* @return integer
|
||||
* Either FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME, depending
|
||||
* on the current configuration.
|
||||
* @return int
|
||||
* Either FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME, depending
|
||||
* on the current configuration.
|
||||
*/
|
||||
protected function getOverwriteMode(Row $row) {
|
||||
if (!empty($this->configuration['rename'])) {
|
||||
|
|
|
@ -22,6 +22,7 @@ class Status extends InOperator {
|
|||
if (!isset($this->valueOptions)) {
|
||||
$this->valueOptions = _views_file_status();
|
||||
}
|
||||
return $this->valueOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,15 +30,8 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
|
|||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
$field_name = strtolower($this->randomMachineName());
|
||||
$type_name = 'article';
|
||||
$field_settings = array(
|
||||
'display_field' => '1',
|
||||
'display_default' => '1',
|
||||
);
|
||||
$field_settings = array(
|
||||
'description_field' => '1',
|
||||
);
|
||||
$widget_settings = array();
|
||||
$this->createFileField($field_name, 'node', $type_name, $field_settings, $field_settings, $widget_settings);
|
||||
|
||||
$this->createFileField($field_name, 'node', $type_name);
|
||||
|
||||
// RSS display must be added manually.
|
||||
$this->drupalGet("admin/structure/types/manage/$type_name/display");
|
||||
|
|
|
@ -151,7 +151,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
|
|||
// - First remove the 2nd file.
|
||||
// - Then remove what is then the 2nd file (was originally the 3rd file).
|
||||
// - Then remove the first file.
|
||||
foreach (array(1,1,0) as $delta) {
|
||||
foreach (array(1, 1, 0) as $delta) {
|
||||
// Ensure we have the expected number of Remove buttons, and that they
|
||||
// are numbered sequentially.
|
||||
$buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
|
||||
|
|
|
@ -33,9 +33,9 @@ abstract class FileManagedTestBase extends WebTestBase {
|
|||
* Assert that all of the specified hook_file_* hooks were called once, other
|
||||
* values result in failure.
|
||||
*
|
||||
* @param array $expected
|
||||
* Array with string containing with the hook name, e.g. 'load', 'save',
|
||||
* 'insert', etc.
|
||||
* @param string[] $expected
|
||||
* An array of strings containing with the hook name; for example, 'load',
|
||||
* 'save', 'insert', etc.
|
||||
*/
|
||||
function assertFileHooksCalled($expected) {
|
||||
\Drupal::state()->resetCache();
|
||||
|
@ -66,7 +66,7 @@ abstract class FileManagedTestBase extends WebTestBase {
|
|||
* Assert that a hook_file_* hook was called a certain number of times.
|
||||
*
|
||||
* @param string $hook
|
||||
* String with the hook name, e.g. 'load', 'save', 'insert', etc.
|
||||
* String with the hook name; for instance, 'load', 'save', 'insert', etc.
|
||||
* @param int $expected_count
|
||||
* Optional integer count.
|
||||
* @param string|NULL $message
|
||||
|
|
|
@ -37,7 +37,7 @@ class EntityFileTest extends KernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->destination = new TestEntityFile([]);
|
||||
$this->destination->streamWrapperManager = \Drupal::getContainer()->get('stream_wrapper_manager');
|
||||
|
|
|
@ -50,18 +50,18 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
/**
|
||||
* Asserts a file entity.
|
||||
*
|
||||
* @param integer $fid
|
||||
* The file ID.
|
||||
* @param int $fid
|
||||
* The file ID.
|
||||
* @param string $name
|
||||
* The expected file name.
|
||||
* @param integer $size
|
||||
* The expected file size.
|
||||
* The expected file name.
|
||||
* @param int $size
|
||||
* The expected file size.
|
||||
* @param string $uri
|
||||
* The expected file URI.
|
||||
* The expected file URI.
|
||||
* @param string $type
|
||||
* The expected MIME type.
|
||||
* @param integer $uid
|
||||
* The expected file owner ID.
|
||||
* The expected MIME type.
|
||||
* @param int $uid
|
||||
* The expected file owner ID.
|
||||
*/
|
||||
protected function assertEntity($fid, $name, $size, $uri, $type, $uid) {
|
||||
/** @var \Drupal\file\FileInterface $file */
|
||||
|
|
|
@ -53,22 +53,22 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
|
|||
/**
|
||||
* Tests a single file entity.
|
||||
*
|
||||
* @param integer $id
|
||||
* The file ID.
|
||||
* @param int $id
|
||||
* The file ID.
|
||||
* @param string $name
|
||||
* The expected file name.
|
||||
* The expected file name.
|
||||
* @param string $uri
|
||||
* The expected URI.
|
||||
* The expected URI.
|
||||
* @param string $mime
|
||||
* The expected MIME type.
|
||||
* @param integer $size
|
||||
* The expected file size.
|
||||
* @param integer $created
|
||||
* The expected creation time.
|
||||
* @param integer $changed
|
||||
* The expected modification time.
|
||||
* @param integer $uid
|
||||
* The expected owner ID.
|
||||
* The expected MIME type.
|
||||
* @param int $size
|
||||
* The expected file size.
|
||||
* @param int $created
|
||||
* The expected creation time.
|
||||
* @param int $changed
|
||||
* The expected modification time.
|
||||
* @param int $uid
|
||||
* The expected owner ID.
|
||||
*/
|
||||
protected function assertEntity($id, $name, $uri, $mime, $size, $created, $changed, $uid) {
|
||||
/** @var \Drupal\file\FileInterface $file */
|
||||
|
|
|
@ -22,11 +22,11 @@ function filter_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.filter':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Filter module allows administrators to configure text formats. Text formats change how HTML tags and other text will be <em>processed and displayed</em> in the site. They are used to transform text, and also help to defend your web site against potentially damaging input from malicious users. Visual text editors can be associated with text formats by using the <a href=":editor_help">Text Editor module</a>. For more information, see the <a href=":filter_do">online documentation for the Filter module</a>.', array(':filter_do' => 'https://www.drupal.org/documentation/modules/filter/',':editor_help' => (\Drupal::moduleHandler()->moduleExists('editor')) ? \Drupal::url('help.page', array('name' => 'editor')) : '#')) . '</p>';
|
||||
$output .= '<p>' . t('The Filter module allows administrators to configure text formats. Text formats change how HTML tags and other text will be <em>processed and displayed</em> in the site. They are used to transform text, and also help to defend your web site against potentially damaging input from malicious users. Visual text editors can be associated with text formats by using the <a href=":editor_help">Text Editor module</a>. For more information, see the <a href=":filter_do">online documentation for the Filter module</a>.', array(':filter_do' => 'https://www.drupal.org/documentation/modules/filter/', ':editor_help' => (\Drupal::moduleHandler()->moduleExists('editor')) ? \Drupal::url('help.page', array('name' => 'editor')) : '#')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Managing text formats') . '</dt>';
|
||||
$output .= '<dd>' . t('You can create and edit text formats on the <a href=":formats">Text formats page</a> (if the Text Editor module is enabled, this page is named Text formats and editors). One text format is included by default: Plain text (which removes all HTML tags). Additional text formats may be created during installation. You can create a text format by clicking "<a href=":add_format">Add text format</a>".', array(':formats' => \Drupal::url('filter.admin_overview'),':add_format' => \Drupal::url('filter.format_add'))) . '</dd>';
|
||||
$output .= '<dd>' . t('You can create and edit text formats on the <a href=":formats">Text formats page</a> (if the Text Editor module is enabled, this page is named Text formats and editors). One text format is included by default: Plain text (which removes all HTML tags). Additional text formats may be created during installation. You can create a text format by clicking "<a href=":add_format">Add text format</a>".', array(':formats' => \Drupal::url('filter.admin_overview'), ':add_format' => \Drupal::url('filter.format_add'))) . '</dd>';
|
||||
$output .= '<dt>' . t('Assigning roles to text formats') . '</dt>';
|
||||
$output .= '<dd>' . t('You can define which users will be able to use each text format by selecting roles. To ensure security, anonymous and untrusted users should only have access to text formats that restrict them to either plain text or a safe set of HTML tags. This is because HTML tags can allow embedding malicious links or scripts in text. More trusted registered users may be granted permission to use less restrictive text formats in order to create rich text. <strong>Improper text format configuration is a security risk.</strong>') . '</dd>';
|
||||
$output .= '<dt>' . t('Selecting filters') . '</dt>';
|
||||
|
@ -817,7 +817,7 @@ function filter_filter_secure_image_alter(&$image) {
|
|||
$image->setAttribute('alt', t('Image removed.'));
|
||||
$image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
|
||||
$image->setAttribute('height', '16');
|
||||
$image->setAttribute('width', '16');
|
||||
$image->setAttribute('width', '16');
|
||||
|
||||
// Add a CSS class to aid in styling.
|
||||
$class = ($image->getAttribute('class') ? trim($image->getAttribute('class')) . ' ' : '');
|
||||
|
|
|
@ -21,7 +21,7 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue