diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index ec49512..04ac341 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -239,12 +239,8 @@ function comment_menu() { ); $items['comment/%comment/approve'] = array( 'title' => 'Approve', - 'page callback' => 'comment_approve', - 'page arguments' => array(1), - 'access callback' => 'entity_page_access', - 'access arguments' => array(1, 'approve'), - 'file' => 'comment.pages.inc', 'weight' => 10, + 'route_name' => 'comment_approve', ); $items['comment/%comment/delete'] = array( 'title' => 'Delete', diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index 5e1b190..5f408d4 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -99,26 +99,3 @@ function comment_reply(EntityInterface $node, $pid = NULL) { return $build; } -/** - * Page callback: Publishes the specified comment. - * - * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment - * A comment entity. - * - * @see comment_menu() - */ -function comment_approve(Comment $comment) { - // @todo CSRF tokens are validated in page callbacks rather than access - // callbacks, because access callbacks are also invoked during menu link - // generation. Add token support to routing: http://drupal.org/node/755584. - $token = drupal_container()->get('request')->query->get('token'); - if (!isset($token) || !drupal_valid_token($token, 'comment/' . $comment->id() . '/approve')) { - throw new AccessDeniedHttpException(); - } - - $comment->status->value = COMMENT_PUBLISHED; - $comment->save(); - - drupal_set_message(t('Comment approved.')); - drupal_goto('node/' . $comment->nid->target_id); -} diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index 6f786dd..ddc6048 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -1,7 +1,14 @@ comment_edit_page: - pattern: 'comment/{comment}/edit' - defaults: - _entity_form: comment.default - requirements: - _entity_access: comment.update + pattern: 'comment/{comment}/edit' + defaults: + _entity_form: comment.default + requirements: + _entity_access: comment.update +comment_approve: + pattern: 'comment/{comment}/approve' + defaults: + _content: '\Drupal\comment\Controller\CommentController::commentApprove' + entity_type: 'comment' + requirements: + _entity_access: comment.approve diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php new file mode 100644 index 0000000..3d27901 --- /dev/null +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -0,0 +1,65 @@ +query->get('token'); + if (!isset($token) || !drupal_valid_token($token, 'comment/' . $comment->id() . '/approve')) { + throw new AccessDeniedHttpException(); + } + + $comment->status->value = COMMENT_PUBLISHED; + $comment->save(); + + drupal_set_message(t('Comment approved.')); + return new RedirectResponse(url('node/' . $comment->nid->target_id, array('absolute' => TRUE))); + } + +} diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index 00ebd9c..3598446 100644 --- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -28,34 +28,6 @@ class FieldSqlStorageTest extends EntityUnitTestBase { */ public static $modules = array('field_test', 'text', 'number'); - /** - * The name of the created field. - * - * @var string - */ - protected $field_name; - - /** - * A field to use in this class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $field; - - /** - * A field instance to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ - protected $instance; - - /** - * Name of the revision table of the field. - * - * @var string - */ - protected $revision_table; - public static function getInfo() { return array( 'name' => 'Field SQL Storage tests', @@ -69,20 +41,17 @@ function setUp() { $this->installSchema('field_test', array('test_entity', 'test_entity_revision', 'test_entity_bundle')); $this->field_name = strtolower($this->randomName()); - $this->field = entity_create('field_entity', array( - 'field_name' => $this->field_name, - 'type' => 'test_field', - 'cardinality' => 4, - )); - $this->field->save(); - $this->instance = entity_create('field_instance', array( + $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4); + $this->field = field_create_field($this->field); + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle' - )); - $this->instance->save(); + ); + $this->instance = field_create_instance($this->instance); $this->table = _field_sql_storage_tablename($this->field); $this->revision_table = _field_sql_storage_revision_tablename($this->field); + } /** @@ -184,7 +153,7 @@ function testFieldAttachInsertAndUpdate() { } // Test update. - $entity = field_test_create_entity(0, 1, $this->instance->bundle); + $entity = field_test_create_entity(0, 1, $this->instance['bundle']); $values = array(); // Note: we try to update one extra value ('<=' instead of '<'). for ($delta = 0; $delta <= $this->field['cardinality']; $delta++) { @@ -224,7 +193,7 @@ function testFieldAttachInsertAndUpdate() { field_attach_update($entity); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { - if ($delta < $this->field->cardinality) { + if ($delta < $this->field['cardinality']) { $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Update with no field_name entry leaves value $delta untouched")); } } @@ -241,7 +210,7 @@ function testFieldAttachInsertAndUpdate() { */ function testFieldAttachSaveMissingData() { $entity_type = 'test_entity'; - $entity = field_test_create_entity(0, 0, $this->instance->bundle); + $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $langcode = Language::LANGCODE_NOT_SPECIFIED; // Insert: Field is missing @@ -292,7 +261,7 @@ function testFieldAttachSaveMissingData() { $unavailable_langcode = 'xx'; db_insert($this->table) ->fields(array('entity_type', 'bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode')) - ->values(array($entity_type, $this->instance->bundle, 0, 0, 0, 0, $unavailable_langcode)) + ->values(array($entity_type, $this->instance['bundle'], 0, 0, 0, 0, $unavailable_langcode)) ->execute(); $count = db_select($this->table) ->countQuery() @@ -336,26 +305,18 @@ function testFieldAttachSaveMissingData() { */ function testUpdateFieldSchemaWithData() { // Create a decimal 5.2 field and add some data. - $field = entity_create('field_entity', array( - 'field_name' => 'decimal52', - 'type' => 'number_decimal', - 'settings' => array('precision' => 5, 'scale' => 2), - )); - $field->save(); - $instance = entity_create('field_instance', array( - 'field_name' => 'decimal52', - 'entity_type' => 'test_entity', - 'bundle' => 'test_bundle', - )); - $instance->save(); - $entity = field_test_create_entity(0, 0, $instance->bundle); + $field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2)); + $field = field_create_field($field); + $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); + $instance = field_create_instance($instance); + $entity = field_test_create_entity(0, 0, $instance['bundle']); $entity->decimal52[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = '1.235'; $entity->save(); // Attempt to update the field in a way that would work without data. - $field->settings['scale'] = 3; + $field['settings']['scale'] = 3; try { - $field->save(); + field_update_field($field); $this->fail(t('Cannot update field schema with data.')); } catch (FieldException $e) { @@ -368,18 +329,14 @@ function testUpdateFieldSchemaWithData() { */ function testFieldUpdateFailure() { // Create a text field. - $field = entity_create('field_entity', array( - 'field_name' => 'test_text', - 'type' => 'text', - 'settings' => array('max_length' => 255), - )); - $field->save(); + $field = array('field_name' => 'test_text', 'type' => 'text', 'settings' => array('max_length' => 255)); + $field = field_create_field($field); // Attempt to update the field in a way that would break the storage. $prior_field = $field; - $field->settings['max_length'] = -1; + $field['settings']['max_length'] = -1; try { - $field->save(); + field_update_field($field); $this->fail(t('Update succeeded.')); } catch (\Exception $e) { @@ -396,18 +353,13 @@ function testFieldUpdateFailure() { * Test adding and removing indexes while data is present. */ function testFieldUpdateIndexesWithData() { + // Create a decimal field. $field_name = 'testfield'; - $field = entity_create('field_entity', array( - 'field_name' => $field_name, - 'type' => 'text')); - $field->save(); - $instance = entity_create('field_instance', array( - 'field_name' => $field_name, - 'entity_type' => 'test_entity', - 'bundle' => 'test_bundle', - )); - $instance->save(); + $field = array('field_name' => $field_name, 'type' => 'text'); + $field = field_create_field($field); + $instance = array('field_name' => $field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); + $instance = field_create_instance($instance); $tables = array(_field_sql_storage_tablename($field), _field_sql_storage_revision_tablename($field)); // Verify the indexes we will create do not exist yet. @@ -417,27 +369,27 @@ function testFieldUpdateIndexesWithData() { } // Add data so the table cannot be dropped. - $entity = field_test_create_entity(1, 1, $instance->bundle); + $entity = field_test_create_entity(1, 1, $instance['bundle']); $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = 'field data'; $entity->save(); - // Add an index. - $field->indexes = array('value' => array(array('value', 255))); - $field->save(); + // Add an index + $field = array('field_name' => $field_name, 'indexes' => array('value' => array(array('value', 255)))); + field_update_field($field); foreach ($tables as $table) { $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table")); } // Add a different index, removing the existing custom one. - $field->indexes = array('value_format' => array(array('value', 127), array('format', 127))); - $field->save(); + $field = array('field_name' => $field_name, 'indexes' => array('value_format' => array(array('value', 127), array('format', 127)))); + field_update_field($field); foreach ($tables as $table) { $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table")); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table")); } // Verify that the tables were not dropped. - $entity = field_test_create_entity(1, 1, $instance->bundle); + $entity = field_test_create_entity(1, 1, $instance['bundle']); field_attach_load('test_entity', array(1 => $entity)); $this->assertEqual($entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables")); } @@ -450,23 +402,21 @@ function testFieldStorageDetails() { $revision = _field_sql_storage_revision_tablename($this->field); // Retrieve the field and instance with field_info so the storage details are attached. - $field = field_info_field($this->field_name); - $instance = field_info_instance($this->instance->entity_type, $field->id(), $this->instance->bundle); + $field = field_info_field($this->field['field_name']); + $instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']); // The storage details are indexed by a storage engine type. - $storage_details = $field->getStorageDetails(); - $this->assertTrue(array_key_exists('sql', $storage_details), 'The storage type is SQL.'); + $this->assertTrue(array_key_exists('sql', $field['storage_details']), 'The storage type is SQL.'); // The SQL details are indexed by table name. - $details = $storage_details['sql']; + $details = $field['storage_details']['sql']; $this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), 'Table name is available in the instance array.'); $this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), 'Revision table name is available in the instance array.'); // Test current and revision storage details together because the columns // are the same. - $schema = $this->field->getSchema(); - foreach ($schema['columns'] as $column_name => $attributes) { - $storage_column_name = _field_sql_storage_columnname($this->field_name, $column_name); + foreach ((array) $this->field['columns'] as $column_name => $attributes) { + $storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name); $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current))); $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision))); } @@ -480,32 +430,25 @@ function testFieldSqlStorageForeignKeys() { // field_test_field_schema()). $field_name = 'testfield'; $foreign_key_name = 'shape'; - $field = entity_create('field_entity', array( - 'field_name' => $field_name, - 'type' => 'shape', - 'settings' => array('foreign_key_name' => $foreign_key_name), - )); - $field->save(); - // Get the field schema. - $schema = $field->getSchema(); + $field = array('field_name' => $field_name, 'type' => 'shape', 'settings' => array('foreign_key_name' => $foreign_key_name)); + field_create_field($field); // Retrieve the field definition and check that the foreign key is in place. - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD'); - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD'); + $field = field_info_field($field_name); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD'); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD'); // Update the field settings, it should update the foreign key definition too. $foreign_key_name = 'color'; - $field->settings['foreign_key_name'] = $foreign_key_name; - $field->save(); - // Reload the field schema after the update. - $schema = $field->getSchema(); + $field['settings']['foreign_key_name'] = $foreign_key_name; + field_update_field($field); // Retrieve the field definition and check that the foreign key is in place. $field = field_info_field($field_name); - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, t('Foreign key table name modified after update')); - $this->assertEqual($schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', t('Foreign key column name modified after update')); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, t('Foreign key table name modified after update')); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', t('Foreign key column name modified after update')); - // Verify the SQL schema. + // Now grab the SQL schema and verify that too. $schemas = _field_sql_storage_schema($field); $schema = $schemas[_field_sql_storage_tablename($field)]; $this->assertEqual(count($schema['foreign keys']), 1, 'There is 1 foreign key in the schema'); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index c643cd0..55028d1 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -207,7 +207,7 @@ function testNoFieldsDisplayOverview() { $this->drupalCreateContentType(array('type' => 'no_fields', 'name' => 'No fields')); // Remove the 'body' field. - field_info_instance('node', 'body', 'no_fields')->delete(); + field_delete_instance(field_info_instance('node', 'body', 'no_fields')); $this->drupalGet('admin/structure/types/manage/no_fields/display'); $this->assertRaw(t('There are no fields yet added. You can add new fields on the Manage fields page.', array('@link' => url('admin/structure/types/manage/no_fields/fields')))); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 471a575..dd362cd 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -45,7 +45,7 @@ function setUp() { 'field_name' => 'field_' . $vocabulary->id(), 'type' => 'taxonomy_term_reference', ); - entity_create('field_entity', $field)->save(); + field_create_field($field); $instance = array( 'field_name' => 'field_' . $vocabulary->id(), @@ -53,7 +53,7 @@ function setUp() { 'label' => 'Tags', 'bundle' => 'article', ); - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); entity_get_form_display('node', 'article', 'default') ->setComponent('field_' . $vocabulary->id()) @@ -280,16 +280,17 @@ function testFieldPrefix() { function testDefaultValue() { // Create a test field and instance. $field_name = 'test'; - entity_create('field_entity', array( + $field = array( 'field_name' => $field_name, 'type' => 'test_field' - ))->save(); - $instance = entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => $this->type, - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('node', $this->type, 'default') ->setComponent($field_name) @@ -430,14 +431,14 @@ function testHiddenFields() { // Create a field and an instance programmatically. $field_name = 'hidden_test_field'; - entity_create('field_entity', array('field_name' => $field_name, 'type' => $field_name))->save(); + field_create_field(array('field_name' => $field_name, 'type' => $field_name)); $instance = array( 'field_name' => $field_name, 'bundle' => $this->type, 'entity_type' => 'node', 'label' => t('Hidden field'), ); - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); entity_get_form_display('node', $this->type, 'default') ->setComponent($field_name) ->save(); diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php index 65e3aec..7697423 100644 --- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php @@ -16,11 +16,10 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase { /** - * The field name to create. + * Modules to enable. * - * @var string + * @var array */ - protected $field_name; public static function getInfo() { return array( @@ -40,14 +39,15 @@ function testMultiStepNodeFormBasicOptions() { // Create an unlimited cardinality field. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_entity', array( - 'field_name' => $this->field_name, + $this->field = array( + 'field_name' => drupal_strtolower($this->field_name), 'type' => 'text', 'cardinality' => -1, - ))->save(); + ); + field_create_field($this->field); // Attach an instance of the field to the page content type. - entity_create('field_instance', array( + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', @@ -55,7 +55,8 @@ function testMultiStepNodeFormBasicOptions() { 'settings' => array( 'text_processing' => TRUE, ), - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('node', 'page', 'default') ->setComponent($this->field_name, array( 'type' => 'text_textfield', @@ -68,11 +69,10 @@ function testMultiStepNodeFormBasicOptions() { 'title' => 'a', 'promote' => FALSE, 'sticky' => 1, - "{$this->field_name}[$langcode][0][value]" => $this->randomString(32), + "$this->field_name[$langcode][0][value]" => $this->randomString(32), ); $this->drupalPost('node/add/page', $edit, t('Add another item')); $this->assertNoFieldChecked('edit-promote', 'promote stayed unchecked'); $this->assertFieldChecked('edit-sticky', 'sticky stayed checked'); } - } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php index e1a33aa..4b3dc88 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php @@ -21,27 +21,6 @@ class NodeAccessFieldTest extends NodeTestBase { */ public static $modules = array('node_access_test', 'field_ui'); - /** - * A user with permission to bypass access content. - * - * @var \Drupal\user\UserInterface - */ - protected $admin_user; - - /** - * A user with permission to manage content types and fields. - * - * @var \Drupal\user\UserInterface - */ - protected $content_admin_user; - - /** - * The name of the created field. - * - * @var string - */ - protected $field_name; - public static function getInfo() { return array( 'name' => 'Node access and fields', @@ -61,15 +40,13 @@ public function setUp() { // Add a custom field to the page content type. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - entity_create('field_entity', array( - 'field_name' => $this->field_name, - 'type' => 'text' - ))->save(); - entity_create('field_instance', array( + $this->field = field_create_field(array('field_name' => $this->field_name, 'type' => 'text')); + $instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + $this->instance = field_create_instance($instance); entity_get_display('node', 'page', 'default') ->setComponent($this->field_name) ->save(); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php index d613cc4..6b60907 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -31,17 +31,10 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase { /** * A normal authenticated user. * - * @var \Drupal\user\Plugin\Core\Entity\UserInterface. + * @var \Drupal\user\Plugin\Core\Entity\User. */ protected $web_user; - /** - * User 1. - * - * @var \Drupal\user\Plugin\Core\Entity\UserInterface. - */ - protected $admin_user; - public static function getInfo() { return array( 'name' => 'Node access language-aware combination', diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index e9447ec..18c879f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -60,8 +60,8 @@ function setUp() { // Make node body translatable. $field = field_info_field('body'); - $field->translatable = TRUE; - $field->save(); + $field['translatable'] = TRUE; + field_update_field($field); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index 9344355..ac024bb 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -169,7 +169,7 @@ function testFieldTranslationForm() { $this->assertRaw('Not translated'); // Delete the only translatable field. - field_info_field('field_test_et_ui_test')->delete(); + field_delete_field('field_test_et_ui_test'); // Visit translation page. $this->drupalGet('node/' . $article->nid . '/translations'); diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php index ae7529b..d46c24e 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php @@ -21,13 +21,6 @@ class PagePreviewTest extends NodeTestBase { */ public static $modules = array('node', 'taxonomy'); - /** - * The name of the created field. - * - * @var string - */ - protected $field_name; - public static function getInfo() { return array( 'name' => 'Node preview', @@ -67,7 +60,7 @@ function setUp() { // Set up a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_entity', array( + $this->field = array( 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'settings' => array( @@ -79,27 +72,30 @@ function setUp() { ), ), 'cardinality' => '-1', - ))->save(); - entity_create('field_instance', array( + ); + + field_create_field($this->field); + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('node', 'page', 'default') - ->setComponent($this->field_name, array( + ->setComponent($this->field['field_name'], array( 'type' => 'taxonomy_autocomplete', )) ->save(); // Show on default display and teaser. entity_get_display('node', 'page', 'default') - ->setComponent($this->field_name, array( + ->setComponent($this->field['field_name'], array( 'type' => 'taxonomy_term_reference_link', )) ->save(); entity_get_display('node', 'page', 'teaser') - ->setComponent($this->field_name, array( + ->setComponent($this->field['field_name'], array( 'type' => 'taxonomy_term_reference_link', )) ->save(); @@ -210,5 +206,4 @@ function testPagePreviewWithRevisions() { // Check that the log field has the correct value. $this->assertFieldByName('log', $edit['log'], 'Log field displayed.'); } - } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 1d90683..9904f0d 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -530,39 +530,39 @@ function node_add_body_field($type, $label = 'Body') { $field = field_info_field('body'); $instance = field_info_instance('node', 'body', $type->type); if (empty($field)) { - $field = entity_create('field_entity', array( + $field = array( 'field_name' => 'body', 'type' => 'text_with_summary', 'entity_types' => array('node'), - )); - $field->save(); + ); + $field = field_create_field($field); } if (empty($instance)) { - $instance = entity_create('field_instance', array( + $instance = array( 'field_name' => 'body', 'entity_type' => 'node', 'bundle' => $type->type, 'label' => $label, 'settings' => array('display_summary' => TRUE), - )); - $instance->save(); + ); + $instance = field_create_instance($instance); // Assign widget settings for the 'default' form mode. entity_get_form_display('node', $type->type, 'default') - ->setComponent($field->id(), array( + ->setComponent($field['field_name'], array( 'type' => 'text_textarea_with_summary', )) ->save(); // Assign display settings for the 'default' and 'teaser' view modes. entity_get_display('node', $type->type, 'default') - ->setComponent($field->id(), array( + ->setComponent($field['field_name'], array( 'label' => 'hidden', 'type' => 'text_default', )) ->save(); entity_get_display('node', $type->type, 'teaser') - ->setComponent($field->id(), array( + ->setComponent($field['field_name'], array( 'label' => 'hidden', 'type' => 'text_summary_or_trimmed', )) diff --git a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module index 1baa48e..3d67454 100644 --- a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module +++ b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module @@ -49,7 +49,7 @@ function node_access_test_language_node_access_records(EntityInterface $node) { * (restricted access) in a given translation. */ function node_access_test_language_enable() { - $field_private = entity_create('field_entity', array( + $field_private = array( 'field_name' => 'field_private', 'type' => 'list_boolean', 'cardinality' => 1, @@ -57,22 +57,23 @@ function node_access_test_language_enable() { 'settings' => array( 'allowed_values' => array(0 => 'Not private', 1 => 'Private'), ), - )); - $field_private->save(); + ); + $field_private = field_create_field($field_private); - entity_create('field_instance', array( - 'field_name' => $field_private->id(), + $instance = array( + 'field_name' => $field_private['field_name'], 'entity_type' => 'node', 'bundle' => 'page', 'widget' => array( 'type' => 'options_buttons', ), - ))->save(); + ); + $instance = field_create_instance($instance); } /** * Implements hook_disable(). */ function node_access_test_language_disable() { - field_read_instance('node', 'field_private', 'page')->delete(); + field_delete_instance(field_read_instance('node', 'field_private', 'page')); } diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php index 904509c..f9a817f 100644 --- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php +++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php @@ -22,25 +22,8 @@ class NumberFieldTest extends WebTestBase { */ public static $modules = array('node', 'entity_test', 'number', 'field_ui'); - /** - * A field to use in this class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ protected $field; - - /** - * A field instance to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ protected $instance; - - /** - * A user with permission to view and manage entities and content types. - * - * @var \Drupal\user\UserInterface - */ protected $web_user; public static function getInfo() { @@ -63,22 +46,23 @@ function setUp() { */ function testNumberDecimalField() { // Create a field with settings to validate. - $this->field = entity_create('field_entity', array( + $this->field = array( 'field_name' => drupal_strtolower($this->randomName()), 'type' => 'number_decimal', 'settings' => array( 'precision' => 8, 'scale' => 4, 'decimal_separator' => '.', ) - )); - $this->field->save(); - entity_create('field_instance', array( - 'field_name' => $this->field->id(), + ); + field_create_field($this->field); + $this->instance = array( + 'field_name' => $this->field['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->field->id(), array( + ->setComponent($this->field['field_name'], array( 'type' => 'number', 'settings' => array( 'placeholder' => '0.00' @@ -86,7 +70,7 @@ function testNumberDecimalField() { )) ->save(); entity_get_display('entity_test', 'entity_test', 'default') - ->setComponent($this->field->id(), array( + ->setComponent($this->field['field_name'], array( 'type' => 'number_decimal', )) ->save(); diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php index a0cc904..fa7e0fa 100644 --- a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php +++ b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php @@ -36,15 +36,17 @@ public function setUp() { // Create number fields and instances for validation. foreach (array('integer', 'float', 'decimal') as $type) { - entity_create('field_entity', array( + $this->field[$type] = array( 'field_name' => 'field_' . $type, 'type' => 'number_' . $type, - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($this->field[$type]); + $this->instance[$type] = array( 'entity_type' => 'entity_test', 'field_name' => 'field_' . $type, 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($this->instance[$type]); } } diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php index c270e4a..df3ac66 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php @@ -32,20 +32,23 @@ function setUp() { parent::setUp(); $this->field_name = 'test_options'; - entity_create('field_entity', array( + $this->field = array( 'field_name' => $this->field_name, 'type' => 'list_text', 'cardinality' => 1, 'settings' => array( 'allowed_values_function' => 'options_test_dynamic_values_callback', ), - ))->save(); - $this->instance = entity_create('field_instance', array( + ); + $this->field = field_create_field($this->field); + + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE, - ))->save(); + ); + $this->instance = field_create_instance($this->instance); entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default') ->setComponent($this->field_name, array( 'type' => 'options_select', diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php index 218e413..cc42901 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php @@ -48,9 +48,9 @@ function testUpdateAllowedValues() { $entity = entity_create('entity_test', array()); $entity->{$this->fieldName}->value = 1; $entity->save(); - $this->field->settings['allowed_values'] = array(2 => 'Two'); + $this->field['settings']['allowed_values'] = array(2 => 'Two'); try { - $this->field->save(); + field_update_field($this->field); $this->fail(t('Cannot update a list field to not include keys with existing data.')); } catch (FieldException $e) { @@ -61,8 +61,8 @@ function testUpdateAllowedValues() { $entity->save(); // Removed options do not appear. - $this->field->settings['allowed_values'] = array(2 => 'Two'); - $this->field->save(); + $this->field['settings']['allowed_values'] = array(2 => 'Two'); + field_update_field($this->field); $entity = entity_create('entity_test', array()); $form = \Drupal::entityManager()->getForm($entity); $this->assertTrue(empty($form[$this->fieldName][$langcode][1]), 'Option 1 does not exist'); @@ -71,7 +71,7 @@ function testUpdateAllowedValues() { // Completely new options appear. $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); - $this->field->save(); + field_update_field($this->field); $form = \Drupal::entityManager()->getForm($entity); $this->assertTrue(empty($form[$this->fieldName][$langcode][1]), 'Option 1 does not exist'); $this->assertTrue(empty($form[$this->fieldName][$langcode][2]), 'Option 2 does not exist'); @@ -80,13 +80,15 @@ function testUpdateAllowedValues() { $this->assertTrue(!empty($form[$this->fieldName][$langcode][20]), 'Option 20 exists'); // Options are reset when a new field with the same name is created. - $this->field->delete(); - entity_create('field_entity', $this->fieldDefinition)->save(); - entity_create('field_instance', array( + field_delete_field($this->fieldName); + unset($this->field['id']); + field_create_field($this->fieldDefinition); + $this->instance = array( 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($this->instance); entity_get_form_display('entity_test', 'entity_test', 'default') ->setComponent($this->fieldName, array( 'type' => 'options_buttons', diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php index d34f178..f28fb7c 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php @@ -78,7 +78,7 @@ function testOptionsAllowedValuesInteger() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(array('value' => 1)), + $this->field_name =>array(array('value' => 1)), ); $node = $this->drupalCreateNode($settings); @@ -258,15 +258,17 @@ function testOptionsTrimmedValuesText() { */ protected function createOptionsField($type) { // Create a test field and instance. - entity_create('field_entity', array( + $field = array( 'field_name' => $this->field_name, 'type' => $type, - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => $this->type, - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', $this->type, 'default')->setComponent($this->field_name)->save(); diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php index 8d335c3..f206d0e 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php @@ -22,35 +22,6 @@ class OptionsWidgetsTest extends FieldTestBase { */ public static $modules = array('options', 'entity_test', 'options_test', 'taxonomy', 'field_ui'); - /** - * A field with cardinality 1 to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $card_1; - - /** - * A field with cardinality 2 to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $card_2; - - /** - * A boolean field to use in this test class. - * - * @var \Drupal\field\Plugin\Core\Entity\Field - */ - protected $bool; - - /** - * A user with permission to view and manage entities. - * - * @var \Drupal\user\UserInterface - */ - protected $web_user; - - public static function getInfo() { return array( 'name' => 'Options widgets', @@ -63,7 +34,7 @@ function setUp() { parent::setUp(); // Field with cardinality 1. - $this->card_1 = entity_create('field_entity', array( + $this->card_1 = array( 'field_name' => 'card_1', 'type' => 'list_integer', 'cardinality' => 1, @@ -71,11 +42,11 @@ function setUp() { // Make sure that 0 works as an option. 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'), ), - )); - $this->card_1->save(); + ); + $this->card_1 = field_create_field($this->card_1); // Field with cardinality 2. - $this->card_2 = entity_create('field_entity', array( + $this->card_2 = array( 'field_name' => 'card_2', 'type' => 'list_integer', 'cardinality' => 2, @@ -83,19 +54,19 @@ function setUp() { // Make sure that 0 works as an option. 'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'), ), - )); - $this->card_2->save(); + ); + $this->card_2 = field_create_field($this->card_2); // Boolean field. - $this->bool = entity_create('field_entity', array( + $this->bool = array( 'field_name' => 'bool', 'type' => 'list_boolean', 'cardinality' => 1, 'settings' => array( 'allowed_values' => array(0 => 'Zero', 1 => 'Some & unescaped markup'), ), - )); - $this->bool->save(); + ); + $this->bool = field_create_field($this->bool); // Create a web user. $this->web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); @@ -107,14 +78,14 @@ function setUp() { */ function testRadioButtons() { // Create an instance of the 'single value' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_1->id(), + $instance = array( + 'field_name' => $this->card_1['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_1->id(), array( + ->setComponent($this->card_1['field_name'], array( 'type' => 'options_buttons', )) ->save(); @@ -153,10 +124,10 @@ function testRadioButtons() { $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); // Check that required radios with one option is auto-selected. - $this->card_1->settings['allowed_values'] = array(99 => 'Only allowed value'); - $this->card_1->save(); - $instance->required = TRUE; - $instance->save(); + $this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value'); + field_update_field($this->card_1); + $instance['required'] = TRUE; + field_update_instance($instance); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); $this->assertFieldChecked("edit-card-1-$langcode-99"); } @@ -166,14 +137,14 @@ function testRadioButtons() { */ function testCheckBoxes() { // Create an instance of the 'multiple values' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_2->id(), + $instance = array( + 'field_name' => $this->card_2['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_2->id(), array( + ->setComponent($this->card_2['field_name'], array( 'type' => 'options_buttons', )) ->save(); @@ -245,10 +216,10 @@ function testCheckBoxes() { $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); // Required checkbox with one option is auto-selected. - $this->card_2->settings['allowed_values'] = array(99 => 'Only allowed value'); - $this->card_2->save(); - $instance->required = TRUE; - $instance->save(); + $this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value'); + field_update_field($this->card_2); + $instance['required'] = TRUE; + field_update_instance($instance); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); $this->assertFieldChecked("edit-card-2-$langcode-99"); } @@ -258,15 +229,15 @@ function testCheckBoxes() { */ function testSelectListSingle() { // Create an instance of the 'single value' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_1->id(), + $instance = array( + 'field_name' => $this->card_1['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'required' => TRUE, - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_1->id(), array( + ->setComponent($this->card_1['field_name'], array( 'type' => 'options_select', )) ->save(); @@ -312,8 +283,8 @@ function testSelectListSingle() { $this->assertNoOptionSelected("edit-card-1-$langcode", 2); // Make the field non required. - $instance->required = FALSE; - $instance->save(); + $instance['required'] = FALSE; + field_update_instance($instance); // Display form. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); @@ -328,7 +299,7 @@ function testSelectListSingle() { $this->card_1['settings']['allowed_values'] = array(); $this->card_1['settings']['allowed_values_function'] = 'options_test_allowed_values_callback'; - $this->card_1->save(); + field_update_field($this->card_1); // Display form: with no field data, nothing is selected $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); @@ -360,14 +331,14 @@ function testSelectListSingle() { */ function testSelectListMultiple() { // Create an instance of the 'multiple values' field. - $instance = entity_create('field_instance', array( - 'field_name' => $this->card_2->id(), + $instance = array( + 'field_name' => $this->card_2['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - )); - $instance->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->card_2->id(), array( + ->setComponent($this->card_2['field_name'], array( 'type' => 'options_select', )) ->save(); @@ -435,8 +406,8 @@ function testSelectListMultiple() { $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); // A required select list does not have an empty key. - $instance->required = TRUE; - $instance->save(); + $instance['required'] = TRUE; + field_update_instance($instance); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.'); @@ -446,11 +417,11 @@ function testSelectListMultiple() { // Test optgroups. // Use a callback function defining optgroups. - $this->card_2->settings['allowed_values'] = array(); - $this->card_2->settings['allowed_values_function'] = 'options_test_allowed_values_callback'; - $this->card_2->save(); - $instance->required = FALSE; - $instance->save(); + $this->card_2['settings']['allowed_values'] = array(); + $this->card_2['settings']['allowed_values_function'] = 'options_test_allowed_values_callback'; + field_update_field($this->card_2); + $instance['required'] = FALSE; + field_update_instance($instance); // Display form: with no field data, nothing is selected. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); @@ -482,13 +453,14 @@ function testSelectListMultiple() { */ function testOnOffCheckbox() { // Create an instance of the 'boolean' field. - entity_create('field_instance', array( - 'field_name' => $this->bool->id(), + $instance = array( + 'field_name' => $this->bool['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + $instance = field_create_instance($instance); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->bool->id(), array( + ->setComponent($this->bool['field_name'], array( 'type' => 'options_onoff', )) ->save(); @@ -536,12 +508,13 @@ function testOnOffCheckbox() { // Create a test field instance. $fieldUpdate = $this->bool; $fieldUpdate['settings']['allowed_values'] = array(0 => 0, 1 => 'MyOnValue'); - $fieldUpdate->save(); - entity_create('field_instance', array( + field_update_field($fieldUpdate); + $instance = array( 'field_name' => $this->bool['field_name'], 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', 'page', 'default') ->setComponent($this->bool['field_name'], array( diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php index 82eb211..320126c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php @@ -107,15 +107,17 @@ function testAttributesInMarkupFile() { $bundle_name = "article"; $field_name = 'file_test'; - entity_create('field_entity', array( + $field = array( 'field_name' => $field_name, 'type' => 'file', - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => $bundle_name, - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', $bundle_name, 'default') ->setComponent($field_name, array( diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index f35b254..e9526d8 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -49,8 +49,8 @@ function setUp() { // Make the body field translatable. // The parent class has already created the article and page content types. $field = field_info_field('body'); - $field->translatable = TRUE; - $field->save(); + $field['translatable'] = TRUE; + field_update_field($field); // Create a few page nodes with multilingual body values. $default_format = filter_default_format(); diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php index 48d0293..dfbb7ba 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php @@ -34,20 +34,22 @@ protected function setUp() { parent::setUp(); // Create the test field. - entity_create('field_entity', array( + $field = array( 'settings' => array( 'target_type' => 'entity_test_mulrev', ), 'field_name' => 'field_test_entity_reference', 'type' => 'entity_reference', - ))->save(); + ); + field_create_field($field); // Create the test field instance. - entity_create('field_instance', array( + $instance = array( 'entity_type' => 'entity_test_mulrev', 'field_name' => 'field_test_entity_reference', 'bundle' => 'entity_test_mulrev', - ))->save(); + ); + field_create_instance($instance); } /** diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php index 74fa8d9..1d9bff6 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php @@ -26,13 +26,13 @@ protected function setUp() { $this->installConfig(array('field')); // Auto-create a field for testing. - entity_create('field_entity', array( + field_create_field(array( 'field_name' => 'field_test_text', 'type' => 'text', 'cardinality' => 1, 'translatable' => FALSE, - ))->save(); - entity_create('field_instance', array( + )); + $instance = array( 'entity_type' => 'entity_test_mulrev', 'field_name' => 'field_test_text', 'bundle' => 'entity_test_mulrev', @@ -41,7 +41,7 @@ protected function setUp() { 'type' => 'text_textfield', 'weight' => 0, ), - ))->save(); + ); + field_create_instance($instance); } - } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 4615b39..b2eed63 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -231,16 +231,17 @@ function testEnableModulesFixedList() { 'bundle' => 'entity_test', 'mode' => 'default', )); - $field = entity_create('field_entity', array( + $field = array( 'field_name' => 'test_field', 'type' => 'test_field' - )); - $field->save(); - entity_create('field_instance', array( - 'field_name' => $field->id(), + ); + field_create_field($field); + $instance = array( + 'field_name' => $field['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($instance); } /** diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module index fe781c3..8af77c1 100644 --- a/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -33,7 +33,7 @@ function syslog_help($path, $arg) { $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Logging for UNIX, Linux, and Mac OS X') . '
'; - $output .= '
' . t('On UNIX, Linux, and Mac OS X, you will find the configuration in the file /etc/syslog.conf, or in /etc/rsyslog.conf or in the directory /etc/rsyslog.d. These files define the routing configuration. Messages can be flagged with the codes LOG_LOCAL0 through LOG_LOCAL7. For information on Syslog facilities, severity levels, and how to set up syslog.conf or rsyslog.conf, see the syslog.conf or rsyslog.conf manual page on your command line.') . '
'; + $output .= '
' . t('On UNIX, Linux, and Mac OS X, the file /etc/syslog.conf defines the routing configuration. Messages can be flagged with the codes LOG_LOCAL0 through LOG_LOCAL7. For information on Syslog facilities, severity levels, and how to set up syslog.conf, see the syslog.conf manual page on your command line.') . '
'; $output .= '
' . t('Logging for Microsoft Windows') . '
'; $output .= '
' . t('On Microsoft Windows, messages are always sent to the Event Log using the code LOG_USER.') . '
'; $output .= '
'; diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php index f15f382..d3ba0b7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php @@ -34,16 +34,18 @@ function setUp() { // Create a multi-valued field for 'page' nodes to use for Ajax testing. $field_name = 'field_ajax_test'; - entity_create('field_entity', array( + $field = array( 'field_name' => $field_name, 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, array('type' => 'text_default')) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 4d24a51..93fc552 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -598,8 +598,8 @@ public function testComputedProperties() { protected function assertComputedProperties($entity_type) { // Make the test text field processed. $instance = field_info_instance($entity_type, 'field_test_text', $entity_type); - $instance->settings['text_processing'] = 1; - $instance->save(); + $instance['settings']['text_processing'] = 1; + field_update_instance($instance); $entity = $this->createTestEntity($entity_type); $entity->field_test_text->value = "The text text to filter."; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php index faa7090..54c6934 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php @@ -60,17 +60,18 @@ public function setUp() { // Add some fieldapi fields to be used in the test. for ($i = 1; $i <= 2; $i++) { - $field_name = 'field_test_' . $i; - entity_create('field_entity', array( - 'field_name' => $field_name, + $field = array( + 'field_name' => 'field_test_' . $i, 'type' => 'number_integer', 'cardinality' => 2, - ))->save(); - entity_create('field_instance', array( - 'field_name' => $field_name, + ); + field_create_field($field); + $instance = array( + 'field_name' => $field['field_name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($instance); } $entity = $this->entityStorageController->create(array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php index 7a40d9b..f36fca7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php @@ -85,13 +85,14 @@ public function setUp() { 'type' => 'taxonomy_term_reference', ); $field['settings']['allowed_values']['vocabulary'] = $vocabulary->id(); - entity_create('field_entity', $field)->save(); + field_create_field($field); // Third, create the instance. - entity_create('field_instance', array( + $instance = array( 'entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'entity_test', - ))->save(); + ); + field_create_instance($instance); // Create two terms and also two accounts. for ($i = 0; $i <= 1; $i++) { $term = entity_create('taxonomy_term', array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index cd6fa31..8b5b19b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -61,14 +61,13 @@ function setUp() { $figures = drupal_strtolower($this->randomName()); $greetings = drupal_strtolower($this->randomName()); foreach (array($figures => 'shape', $greetings => 'text') as $field_name => $field_type) { - $field = entity_create('field_entity', array( + $field = array( 'field_name' => $field_name, 'type' => $field_type, 'cardinality' => 2, 'translatable' => TRUE, - )); - $field->save(); - $fields[] = $field; + ); + $fields[] = field_create_field($field); } $bundles = array(); for ($i = 0; $i < 2; $i++) { @@ -79,11 +78,12 @@ function setUp() { } while ($bundles && strtolower($bundles[0]) >= strtolower($bundle)); entity_test_create_bundle($bundle); foreach ($fields as $field) { - entity_create('field_instance', array( - 'field_name' => $field->id(), + $instance = array( + 'field_name' => $field['field_name'], 'entity_type' => 'entity_test_mulrev', 'bundle' => $bundle, - ))->save(); + ); + field_create_instance($instance); } $bundles[] = $bundle; } @@ -410,11 +410,12 @@ protected function testCount() { // can test whether cross entity type fields produce the correct query. $field_name = $this->figures; $bundle = $this->randomName(); - entity_create('field_instance', array( + $instance = array( 'field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => $bundle, - ))->save(); + ); + field_create_instance($instance); $entity = entity_create('entity_test', array( 'id' => 1, diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 80d00b8..ff78829 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -105,8 +105,8 @@ function testEntityFormLanguage() { // Make body translatable. $field = field_info_field('body'); - $field->translatable = TRUE; - $field->save(); + $field['translatable'] = TRUE; + field_update_field($field); $field = field_info_field('body'); $this->assertTrue($field['translatable'], 'Field body is translatable.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index a235add..919565c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -50,21 +50,23 @@ function setUp() { // Create a translatable test field. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - entity_create('field_entity', array( + $field = array( 'field_name' => $this->field_name, 'type' => 'text', 'cardinality' => 4, 'translatable' => TRUE, - ))->save(); + ); + field_create_field($field); $this->field = field_read_field($this->field_name); // Create instance in all entity variations. foreach (entity_test_entity_types() as $entity_type) { - entity_create('field_instance', array( + $instance = array( 'field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, - ))->save(); + ); + field_create_instance($instance); $this->instance[$entity_type] = field_read_instance($entity_type, $this->field_name, $entity_type); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php index ff1bad3..f049ac8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php @@ -33,13 +33,15 @@ function setUp() { parent::setUp(); // Auto-create a field for testing. - entity_create('field_entity', array( + $field = array( 'field_name' => 'test_multiple', 'type' => 'text', 'cardinality' => -1, 'translatable' => FALSE, - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($field); + + $instance = array( 'entity_type' => 'user', 'field_name' => 'test_multiple', 'bundle' => 'user', @@ -47,7 +49,8 @@ function setUp() { 'settings' => array( 'user_register_form' => TRUE, ), - ))->save(); + ); + field_create_instance($instance); entity_get_form_display('user', 'user', 'default') ->setComponent('test_multiple', array( 'type' => 'text_textfield', diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php index c580e88..8e9f649 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php @@ -76,13 +76,13 @@ function testPreserveFormActionAfterAJAX() { 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, ); - entity_create('field_entity', $field)->save(); + field_create_field($field); $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page', ); - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, array('type' => 'text_test')) ->save(); diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install index d6f1b34..f7b8726 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.install +++ b/core/modules/system/tests/modules/entity_test/entity_test.install @@ -10,12 +10,13 @@ */ function entity_test_install() { // Auto-create a field for testing. - entity_create('field_entity', array( + $field = array( 'field_name' => 'field_test_text', 'type' => 'text', 'cardinality' => 1, 'translatable' => FALSE, - ))->save(); + ); + field_create_field($field); $entity_types = array( 'entity_test', @@ -24,12 +25,13 @@ function entity_test_install() { 'entity_test_mulrev', ); foreach ($entity_types as $entity_type) { - entity_create('field_instance', array( + $instance = array( 'entity_type' => $entity_type, 'field_name' => 'field_test_text', 'bundle' => $entity_type, 'label' => 'Test text-field', - ))->save(); + ); + field_create_instance($instance); entity_get_form_display($entity_type, $entity_type, 'default') ->setComponent('field_test_text', array('type' => 'text_text')) diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 57283ea..96f00f1 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -193,7 +193,7 @@ function _update_process_fetch_task($project) { // Now that we processed the fetch task for this project, clear out the // record for this task so we're willing to fetch again. - Drupal::keyValue('update_fetch_task')->delete($project_name); + drupal_container()->get('keyvalue')->get('update_fetch_task')->delete($project_name); return $success; } @@ -245,12 +245,12 @@ function _update_refresh() { function _update_create_fetch_task($project) { $fetch_tasks = &drupal_static(__FUNCTION__, array()); if (empty($fetch_tasks)) { - $fetch_tasks = Drupal::keyValue('update_fetch_task')->getAll(); + $fetch_tasks = drupal_container()->get('keyvalue')->get('update_fetch_task')->getAll(); } if (empty($fetch_tasks[$project['name']])) { $queue = Drupal::queue('update_fetch_tasks'); $queue->createItem($project); - Drupal::keyValue('update_fetch_task')->set($project['name'], $project); + drupal_container()->get('keyvalue')->get('update_fetch_task')->set($project['name'], $project); $fetch_tasks[$project['name']] = REQUEST_TIME; } } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php index d7269a3..847512a 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php @@ -72,11 +72,7 @@ public function build() { '#items' => array(), ); foreach ($items as $account) { - $username = array( - '#theme' => 'username', - '#account' => $account, - ); - $build['#items'][] = drupal_render($username); + $build['#items'][] = theme('username', array('account' => $account)); } return $build; } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserOnlineBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserOnlineBlock.php index 3f5b0b2..f2452c9 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserOnlineBlock.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserOnlineBlock.php @@ -95,11 +95,7 @@ public function build() { if ($authenticated_count && $max_users) { $uids = db_query_range('SELECT uid FROM {users} WHERE access >= :interval AND uid > 0 ORDER BY access DESC', 0, $max_users, array(':interval' => $interval))->fetchCol(); foreach (user_load_multiple($uids) as $account) { - $username = array( - '#theme' => 'username', - '#account' => $account, - ); - $build['#items'][] = drupal_render($username); + $build['#items'][] = theme('username', array('account' => $account)); } } diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php index b09e84a..d36f618 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php @@ -85,11 +85,7 @@ function render_link($data, $values) { } elseif (!empty($this->options['link_to_user'])) { $account->name = $this->getValue($values); - $username = array( - '#theme' => 'username', - '#account' => $account, - ); - return drupal_render($username); + return theme('username', array('account' => $account)); } } // If we want a formatted username, do that. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index 683bbda..8da2c2b 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -195,34 +195,34 @@ function testRegistrationDefaultValues() { */ function testRegistrationWithUserFields() { // Create a field, and an instance on 'user' entity type. - $field = entity_create('field_entity', array( + $field = array( 'type' => 'test_field', 'field_name' => 'test_user_field', 'cardinality' => 1, - )); - $field->save(); - $instance = entity_create('field_instance', array( + ); + field_create_field($field); + $instance = array( 'field_name' => 'test_user_field', 'entity_type' => 'user', 'label' => 'Some user field', 'bundle' => 'user', 'required' => TRUE, 'settings' => array('user_register_form' => FALSE), - )); - $instance->save(); + ); + field_create_instance($instance); entity_get_form_display('user', 'user', 'default') ->setComponent('test_user_field', array('type' => 'test_field_widget')) ->save(); // Check that the field does not appear on the registration form. $this->drupalGet('user/register'); - $this->assertNoText($instance->label(), 'The field does not appear on user registration form'); + $this->assertNoText($instance['label'], 'The field does not appear on user registration form'); // Have the field appear on the registration form. - $instance->settings['user_register_form'] = TRUE; - $instance->save(); + $instance['settings']['user_register_form'] = TRUE; + field_update_instance($instance); $this->drupalGet('user/register'); - $this->assertText($instance->label(), 'The field appears on user registration form'); + $this->assertText($instance['label'], 'The field appears on user registration form'); // Check that validation errors are correctly reported. $edit = array(); @@ -231,11 +231,11 @@ function testRegistrationWithUserFields() { // Missing input in required field. $edit['test_user_field[und][0][value]'] = ''; $this->drupalPost(NULL, $edit, t('Create new account')); - $this->assertRaw(t('@name field is required.', array('@name' => $instance->label())), 'Field validation error was correctly reported.'); + $this->assertRaw(t('@name field is required.', array('@name' => $instance['label'])), 'Field validation error was correctly reported.'); // Invalid input. $edit['test_user_field[und][0][value]'] = '-1'; $this->drupalPost(NULL, $edit, t('Create new account')); - $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $instance->label())), 'Field validation error was correctly reported.'); + $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $instance['label'])), 'Field validation error was correctly reported.'); // Submit with valid data. $value = rand(1, 255); @@ -247,8 +247,8 @@ function testRegistrationWithUserFields() { $this->assertEqual($new_user->test_user_field->value, $value, 'The field value was correclty saved.'); // Check that the 'add more' button works. - $field->cardinality = FIELD_CARDINALITY_UNLIMITED; - $field->save(); + $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED; + field_update_field($field); foreach (array('js', 'nojs') as $js) { $this->drupalGet('user/register'); // Add two inputs. diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index f9982e8..95a0382 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -47,20 +47,13 @@ function user_admin_account() { $users_roles[] = $roles[$user_role->rid]; } asort($users_roles); - $username = array( - '#theme' => 'username', - '#account' => $account, - ); - $item_list = array( - '#theme' => 'item_list', - '#items' => $users_roles, - ); + $options[$account->uid] = array( - 'username' => drupal_render($username), - 'status' => $status[$account->status], - 'roles' => drupal_render($item_list), + 'username' => theme('username', array('account' => $account)), + 'status' => $status[$account->status], + 'roles' => theme('item_list', array('items' => $users_roles)), 'member_for' => format_interval(REQUEST_TIME - $account->created), - 'access' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'), + 'access' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'), ); $links = array(); $links['edit'] = array( @@ -90,9 +83,7 @@ function user_admin_account() { '#rows' => $options, '#empty' => t('No people available.'), ); - $form['pager'] = array( - '#theme' =>'pager', - ); + $form['pager'] = array('#markup' => theme('pager')); return $form; } @@ -146,15 +137,10 @@ function user_admin_permissions($form, $form_state, $rid = NULL) { 'warning' => !empty($perm_item['restrict access']) ? t('Warning: Give to trusted roles only; this permission has security implications.') : '', ); $options[$perm] = ''; - $user_permission_description = array( - '#theme' => 'user_permission_description', - '#permission_item' => $perm_item, - '#hide' => $hide_descriptions, - ); $form['permission'][$perm] = array( '#type' => 'item', '#markup' => $perm_item['title'], - '#description' => drupal_render($user_permission_description), + '#description' => theme('user_permission_description', array('permission_item' => $perm_item, 'hide' => $hide_descriptions)), ); foreach ($role_names as $rid => $name) { // Builds arrays for checked boxes for each role @@ -238,19 +224,8 @@ function theme_user_admin_permissions($variables) { foreach (element_children($form['role_names']) as $rid) { $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox')); } - $system_compact_link = array( - '#theme' => 'system_compact_link', - ); - $table = array( - '#theme' => 'table', - '#header' => $header, - '#rows' => $rows, - '#attributes' => array( - 'id' => 'permissions', - ), - ); - $output = drupal_render($system_compact_link); - $output .= drupal_render($table); + $output = theme('system_compact_link'); + $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions'))); $output .= drupal_render_children($form); return $output; } diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 6793baa..94c9d5d 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -315,7 +315,7 @@ function user_install_picture_field() { 'default_image' => FALSE, ), ); - entity_create('field_entity', $field)->save(); + $field = field_create_field($field); $instance = array( 'field_name' => 'user_picture', @@ -335,7 +335,7 @@ function user_install_picture_field() { 'default_image' => 0, ), ); - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); // Assign form display settings for the 'default' view mode. entity_get_form_display('user', 'user', 'default') diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 0a10bf1..9cfdce9 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -61,7 +61,7 @@ protected function setUp() { // Setup a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_entity', array( + $this->field = array( 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'settings' => array( @@ -72,12 +72,14 @@ protected function setUp() { ), ), ) - ))->save(); - entity_create('field_instance', array( + ); + field_create_field($this->field); + $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', - ))->save(); + ); + field_create_instance($this->instance); // Create a time in the past for the archive. $time = REQUEST_TIME - 3600; diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php index 2f870d8..bb52895 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php @@ -55,7 +55,7 @@ function setUp() { $this->tag_vocabulary->save(); // Create the tag field itself. - $this->tag_field = entity_create('field_entity', array( + $this->tag_field = array( 'field_name' => 'field_views_testing_tags', 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -67,8 +67,8 @@ function setUp() { ), ), ), - )); - $this->tag_field->save(); + ); + field_create_field($this->tag_field); // Create an instance of the tag field on one of the content types, and // configure it to display an autocomplete widget. @@ -77,7 +77,7 @@ function setUp() { 'entity_type' => 'node', 'bundle' => $this->node_type_with_tags->type, ); - entity_create('field_instance', $this->tag_instance)->save(); + field_create_instance($this->tag_instance); entity_get_form_display('node', $this->node_type_with_tags->type, 'default') ->setComponent('field_views_testing_tags', array( @@ -108,7 +108,7 @@ function testTaggedWith() { $node_add_path = 'node/add/' . $this->node_type_with_tags->type; // Create three nodes, with different tags. - $tag_field = $this->tag_field->id() . '[' . Language::LANGCODE_NOT_SPECIFIED . ']'; + $tag_field = $this->tag_field['field_name'] . '[' . Language::LANGCODE_NOT_SPECIFIED . ']'; $edit = array(); $edit['title'] = $node_tag1_title = $this->randomName(); $edit[$tag_field] = 'tag1'; @@ -189,7 +189,7 @@ function testTaggedWithByNodeType() { // "tagged with" form element should not appear for it too. $instance = $this->tag_instance; $instance['bundle'] = $this->node_type_without_tags->type; - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); entity_get_form_display('node', $this->node_type_without_tags->type, 'default') ->setComponent('field_views_testing_tags', array( 'type' => 'taxonomy_autocomplete', diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh index 87ec22a..bb81e5a 100644 --- a/core/scripts/generate-d7-content.sh +++ b/core/scripts/generate-d7-content.sh @@ -93,7 +93,7 @@ ), ), ); - entity_create('field_entity', $field)->save(); + field_create_field($field); $node_types = $i > 11 ? array('page') : array_keys(node_type_get_types()); foreach ($node_types as $bundle) { $instance = array( @@ -132,7 +132,7 @@ 'settings' => array(), ); } - entity_create('field_instance', $instance)->save(); + field_create_instance($instance); } $parents = array(); // Vocabularies without hierarchy get one term, single parent vocabularies get diff --git a/core/themes/seven/ie.css b/core/themes/seven/ie.css new file mode 100644 index 0000000..df7056e --- /dev/null +++ b/core/themes/seven/ie.css @@ -0,0 +1,38 @@ +/* IE renders monospace font too big. */ +code, +pre, +kbd { + font-size: 1em; +} + +/* Node Add/Edit Page Layout */ + +.layout-node-form { + overflow: hidden; +} + +.overlay .node-actions { + margin-bottom: 1em; +} + +.node-main-content, +.node-actions { + padding: 0.5em 1.5em 0 1.5em; +} + +/** + * 1. Applies the Position Is Everything technique for equal-height columns; + * @see http://www.positioniseverything.net/articles/onetruelayout/equalheight + * 2. When animating the height of elements within this region, prevent + * vertical jittering of elements further down in the document flow. + */ +.node-advanced-settings { + margin-bottom: -999em; + padding-bottom: 999em; + display: table; + + -moz-box-shadow: inset 0.1em -1em 0.6em rgba(100, 100, 100, .1); + -webkit-box-shadow: inset 0.1em -1em 0.6em rgba(100, 100, 100, .1); + box-shadow: inset 0.1em -1em 0.6em rgba(100, 100, 100, .1); + border: none; +} \ No newline at end of file diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 3b11032..0e33a77 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -22,6 +22,8 @@ function seven_preprocess_maintenance_page(&$vars) { */ function seven_preprocess_html(&$vars) { drupal_add_library('system', 'normalize'); + // Add conditional CSS for IE8 and below. + drupal_add_css(path_to_theme() . '/ie.css', array('group' => CSS_AGGREGATE_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE)); } /** @@ -120,11 +122,11 @@ function seven_tablesort_indicator($variables) { if($variables['style'] == 'asc') { $image_uri = $theme_path . '/images/arrow-asc.png'; - $text = t('Sort ascending'); + $text = t('sort ascending'); } else { $image_uri = $theme_path . '/images/arrow-desc.png'; - $text = t('Sort descending'); + $text = t('sort descending'); } $image = array( diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index fe16cfc..8e081fd 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -624,9 +624,9 @@ * * Remove the leading hash signs if you would like to alter this functionality. */ -#$conf['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)\//'; -#$conf['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; -#$conf['system.performance']['fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; +#$conf['system.performance]['fast_404']['exclude_paths'] = '/\/(?:styles)\//'; +#$conf['system.performance]['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +#$conf['system.performance]['fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; /** * Load local development override configuration, if available.