diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php index 387c2a3..260da45 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php @@ -15,11 +15,13 @@ class CommentPreviewTest extends CommentTestBase { /** - * Modules to enable. + * The profile to install as a basis for testing. * - * @var array + * Using the standard profile to test user picture display in comments. + * + * @var string */ - public static $modules = array('image'); + protected $profile = 'standard'; public static function getInfo() { return array( @@ -32,10 +34,6 @@ public static function getInfo() { function setUp() { parent::setUp(); - // Create user picture field. - module_load_install('user'); - user_install_picture_field(); - // Add the basic_html filter format from the standard install profile. $filter_format_storage_controller = $this->container->get('entity.manager')->getStorageController('filter_format'); $filter_format = $filter_format_storage_controller->create(array( diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php index d418eef..fa88502 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php @@ -15,11 +15,14 @@ class UserPictureTest extends WebTestBase { /** - * Modules to enable. + * The profile to install as a basis for testing. * - * @var array + * Using the standard profile to test user picture config provided by the + * standard profile. + * + * @var string */ - public static $modules = array('image', 'comment'); + protected $profile = 'standard'; protected $user; protected $_directory_test; @@ -41,12 +44,6 @@ function setUp() { 'post comments', 'skip comment approval', )); - $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - $this->container->get('comment.manager')->addDefaultField('node', 'article'); - - // @see standard.install - module_load_install('user'); - user_install_picture_field(); } /** diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 9d25ccc..8f6cbe2 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -6,6 +6,7 @@ */ use Drupal\Core\Language\Language; +use Drupal\field\Field; /** * Implements hook_schema(). @@ -256,97 +257,6 @@ function user_install() { } /** - * Creates a user picture image field for the User entity. - * - * This is only used in core's standard.install, but is kept as a separate - * helper function so that other install profiles can reuse it. - */ -function user_install_picture_field() { - $field = array( - 'name' => 'user_picture', - 'entity_type' => 'user', - 'module' => 'image', - 'type' => 'image', - 'cardinality' => 1, - 'locked' => FALSE, - 'indexes' => array('target_id' => array('target_id')), - 'settings' => array( - 'uri_scheme' => 'public', - 'default_image' => array( - 'fid' => NULL, - 'alt' => '', - 'title' => '', - 'width' => NULL, - 'height' => NULL, - ), - ), - ); - entity_create('field_entity', $field)->save(); - - $instance = array( - 'field_name' => 'user_picture', - 'entity_type' => 'user', - 'label' => 'Picture', - 'bundle' => 'user', - 'description' => t('Your virtual face or picture.'), - 'required' => FALSE, - 'settings' => array( - 'file_extensions' => 'png gif jpg jpeg', - 'file_directory' => 'pictures', - 'max_filesize' => '30 KB', - 'alt_field' => 0, - 'title_field' => 0, - 'max_resolution' => '85x85', - 'min_resolution' => '', - 'default_image' => array( - 'fid' => NULL, - 'alt' => '', - 'title' => '', - 'width' => NULL, - 'height' => NULL, - ), - ), - ); - entity_create('field_instance', $instance)->save(); - - // Assign form display settings for the 'default' view mode. - entity_get_form_display('user', 'user', 'default') - ->setComponent('user_picture', array( - 'type' => 'image_image', - 'settings' => array( - 'progress_indicator' => 'throbber', - 'preview_image_style' => 'thumbnail', - ), - 'weight' => -1, - )) - ->save(); - - // Assign display settings for the 'default' and 'compact' view modes. - entity_get_display('user', 'user', 'default') - ->setComponent('user_picture', array( - 'label' => 'hidden', - 'type' => 'image', - 'settings' => array( - 'image_style' => 'thumbnail', - 'image_link' => 'content', - ), - )) - ->save(); - entity_get_display('user', 'user', 'compact') - ->setComponent('user_picture', array( - 'label' => 'hidden', - 'type' => 'image', - 'settings' => array( - 'image_style' => 'thumbnail', - 'image_link' => 'content', - ), - )) - // Additionally, hide 'summary' pseudo-field from compact view mode.. - ->removeComponent('member_for') - ->save(); -} - -/** * Implements hook_update_dependencies(). */ function user_update_dependencies() { diff --git a/core/profiles/standard/config/entity.display.user.user.compact.yml b/core/profiles/standard/config/entity.display.user.user.compact.yml new file mode 100644 index 0000000..d83a3dd --- /dev/null +++ b/core/profiles/standard/config/entity.display.user.user.compact.yml @@ -0,0 +1,16 @@ +id: user.user.compact +uuid: 70911b08-bf47-4a3f-b400-f99cf136effd +targetEntityType: user +bundle: user +mode: compact +content: + user_picture: + label: hidden + type: image + settings: + image_style: thumbnail + image_link: content + weight: 0 + member_for: + visible: false +status: true diff --git a/core/profiles/standard/config/entity.display.user.user.default.yml b/core/profiles/standard/config/entity.display.user.user.default.yml new file mode 100644 index 0000000..b19d602 --- /dev/null +++ b/core/profiles/standard/config/entity.display.user.user.default.yml @@ -0,0 +1,14 @@ +id: user.user.default +uuid: 7a60b270-a584-46dc-ba00-a510230e9f45 +targetEntityType: user +bundle: user +mode: default +content: + user_picture: + label: hidden + type: image + settings: + image_style: thumbnail + image_link: content + weight: 0 +status: true diff --git a/core/profiles/standard/config/entity.form_display.user.user.default.yml b/core/profiles/standard/config/entity.form_display.user.user.default.yml new file mode 100644 index 0000000..0758cf6 --- /dev/null +++ b/core/profiles/standard/config/entity.form_display.user.user.default.yml @@ -0,0 +1,13 @@ +id: user.user.default +uuid: 9a01a9bf-791b-4e46-8d32-50136be8596f +targetEntityType: user +bundle: user +mode: default +content: + user_picture: + type: image_image + settings: + progress_indicator: throbber + preview_image_style: thumbnail + weight: -1 +status: true diff --git a/core/profiles/standard/config/field.field.user.user_picture.yml b/core/profiles/standard/config/field.field.user.user_picture.yml new file mode 100644 index 0000000..27c3069 --- /dev/null +++ b/core/profiles/standard/config/field.field.user.user_picture.yml @@ -0,0 +1,31 @@ +id: user.user_picture +uuid: 745b0ce0-aece-42dd-a800-ade5b8455e84 +status: true +langcode: en +name: user_picture +entity_type: user +type: image +settings: + uri_scheme: public + default_image: false + column_groups: + file: + label: File + columns: + - target_id + - width + - height + alt: + label: Alt + translatable: true + title: + label: Title + translatable: true +module: image +active: true +locked: false +cardinality: 1 +translatable: false +indexes: + target_id: + - target_id diff --git a/core/profiles/standard/config/field.instance.user.user.user_picture.yml b/core/profiles/standard/config/field.instance.user.user.user_picture.yml new file mode 100644 index 0000000..2a3beec --- /dev/null +++ b/core/profiles/standard/config/field.instance.user.user.user_picture.yml @@ -0,0 +1,29 @@ +id: user.user.user_picture +uuid: 1e125e81-5211-4c73-a500-c45099ab9014 +status: true +langcode: en +field_uuid: 745b0ce0-aece-42dd-a800-ade5b8455e84 +entity_type: user +bundle: user +label: Picture +description: 'Your virtual face or picture.' +required: false +default_value: { } +default_value_function: '' +settings: + file_extensions: 'png gif jpg jpeg' + file_directory: pictures + max_filesize: '30 KB' + alt_field: 0 + title_field: 0 + max_resolution: 85x85 + min_resolution: '' + default_image: + fid: null + alt: '' + title: '' + width: null + height: null + alt_field_required: '0' + title_field_required: '0' +field_type: image diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index 5aa1dd7..e127a2f 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -31,10 +31,6 @@ function standard_install() { $user_settings = \Drupal::config('user.settings'); $user_settings->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(); - // Create user picture field. - module_load_install('user'); - user_install_picture_field(); - // Enable default permissions for system roles. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments')); user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval'));