Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -247,7 +247,7 @@ display:
|
|||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: 'Mime type'
|
||||
label: 'MIME type'
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
|
@ -623,7 +623,7 @@ display:
|
|||
exposed: true
|
||||
expose:
|
||||
operator_id: filemime_op
|
||||
label: 'Mime type'
|
||||
label: 'MIME type'
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: filemime_op
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
migrate.destination.entity:file:
|
||||
type: migrate_destination
|
||||
label: 'File'
|
||||
mapping:
|
||||
source_path_property:
|
||||
type: string
|
||||
label: 'Source path'
|
||||
urlencode:
|
||||
type: boolean
|
||||
label: 'Whether to urlencode incoming file paths'
|
|
@ -121,11 +121,3 @@ field.formatter.settings.file_extension:
|
|||
extension_detect_tar:
|
||||
type: boolean
|
||||
label: 'Detect tar'
|
||||
|
||||
migrate.source.d6_upload_instance:
|
||||
type: migrate_source_sql
|
||||
label: 'Drupal 6 upload form display'
|
||||
mapping:
|
||||
constants:
|
||||
type: migrate_entity_constant
|
||||
label: 'Constants'
|
||||
|
|
|
@ -98,18 +98,18 @@ function file_requirements($phase) {
|
|||
}
|
||||
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'));
|
||||
$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="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
|
||||
}
|
||||
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/apcu'));
|
||||
$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="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://php.net/apcu">APC</a>.');
|
||||
}
|
||||
elseif ($implementation == 'apc') {
|
||||
$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'));
|
||||
$value = t('Enabled (<a href="http://php.net/manual/apcu.configuration.php#ini.apcu.rfc1867">APC RFC1867</a>)');
|
||||
$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="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
|
||||
}
|
||||
elseif ($implementation == 'uploadprogress') {
|
||||
$value = t('Enabled (<a href=":url">PECL uploadprogress</a>)', array(':url' => 'http://pecl.php.net/package/uploadprogress'));
|
||||
$value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
|
||||
}
|
||||
$requirements['file_progress'] = array(
|
||||
'title' => t('Upload progress'),
|
||||
|
|
|
@ -504,11 +504,11 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
|
|||
|
||||
if ($uri = file_unmanaged_save_data($data, $destination, $replace)) {
|
||||
// Create a file entity.
|
||||
$file = entity_create('file', array(
|
||||
$file = File::create([
|
||||
'uri' => $uri,
|
||||
'uid' => $user->id(),
|
||||
'status' => FILE_STATUS_PERMANENT,
|
||||
));
|
||||
]);
|
||||
// If we are replacing an existing file re-use its database record.
|
||||
// @todo Do not create a new entity in order to update it. See
|
||||
// https://www.drupal.org/node/2241865.
|
||||
|
@ -772,7 +772,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
|
|||
'filesize' => $file_info->getSize(),
|
||||
);
|
||||
$values['filemime'] = \Drupal::service('file.mime_type.guesser')->guess($values['filename']);
|
||||
$file = entity_create('file', $values);
|
||||
$file = File::create($values);
|
||||
|
||||
$extensions = '';
|
||||
if (isset($validators['file_validate_extensions'])) {
|
||||
|
@ -1266,7 +1266,7 @@ function template_preprocess_file_link(&$variables) {
|
|||
'file',
|
||||
// Add a specific class for each and every mime type.
|
||||
'file--mime-' . strtr($mime_type, array('/' => '-', '.' => '-')),
|
||||
// Add a more general class for groups of well known mime types.
|
||||
// Add a more general class for groups of well known MIME types.
|
||||
'file--' . file_icon_class($mime_type),
|
||||
);
|
||||
|
||||
|
|
|
@ -23,5 +23,5 @@ destination:
|
|||
migration_dependencies:
|
||||
required:
|
||||
- d6_file
|
||||
- d6_node:*
|
||||
- d6_node
|
||||
- d6_upload_field_instance
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Controller\FileWidgetAjaxController.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Element\ManagedFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Element;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Entity\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Entity;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileAccessControlHandler.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileAccessFormatterControlHandlerInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\Core\Entity\EntityAccessControlHandlerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileStorage.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileStorageInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityStorageInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileStorageSchema.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileUsage\DatabaseFileUsageBackend.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\FileUsage;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileUsage\FileUsageBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\FileUsage;
|
||||
|
||||
use Drupal\file\FileInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileUsage\FileUsageInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\FileUsage;
|
||||
|
||||
use Drupal\file\FileInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\FileViewsData.
|
||||
*/
|
||||
|
||||
namespace Drupal\file;
|
||||
|
||||
use Drupal\views\EntityViewsData;
|
||||
|
@ -21,7 +16,7 @@ class FileViewsData extends EntityViewsData {
|
|||
$data = parent::getViewsData();
|
||||
|
||||
// @TODO There is no corresponding information in entity metadata.
|
||||
$data['file_managed']['table']['base']['help'] = t('Files maintained by Drupal and various modules.');
|
||||
$data['file_managed']['table']['base']['help'] = $this->t('Files maintained by Drupal and various modules.');
|
||||
$data['file_managed']['table']['base']['defaults']['field'] = 'filename';
|
||||
$data['file_managed']['table']['wizard_id'] = 'file_managed';
|
||||
|
||||
|
@ -32,13 +27,13 @@ class FileViewsData extends EntityViewsData {
|
|||
'numeric' => TRUE,
|
||||
);
|
||||
$data['file_managed']['fid']['relationship'] = array(
|
||||
'title' => t('File usage'),
|
||||
'help' => t('Relate file entities to their usage.'),
|
||||
'title' => $this->t('File usage'),
|
||||
'help' => $this->t('Relate file entities to their usage.'),
|
||||
'id' => 'standard',
|
||||
'base' => 'file_usage',
|
||||
'base field' => 'fid',
|
||||
'field' => 'fid',
|
||||
'label' => t('File usage'),
|
||||
'label' => $this->t('File usage'),
|
||||
);
|
||||
|
||||
$data['file_managed']['uri']['field']['default_formatter'] = 'file_uri';
|
||||
|
@ -46,8 +41,8 @@ class FileViewsData extends EntityViewsData {
|
|||
$data['file_managed']['filemime']['field']['default_formatter'] = 'file_filemime';
|
||||
|
||||
$data['file_managed']['extension'] = array(
|
||||
'title' => t('Extension'),
|
||||
'help' => t('The extension of the file.'),
|
||||
'title' => $this->t('Extension'),
|
||||
'help' => $this->t('The extension of the file.'),
|
||||
'real field' => 'filename',
|
||||
'field' => array(
|
||||
'entity_type' => 'file',
|
||||
|
@ -63,14 +58,14 @@ class FileViewsData extends EntityViewsData {
|
|||
$data['file_managed']['status']['field']['default_formatter_settings'] = [
|
||||
'format' => 'custom',
|
||||
'format_custom_false' => $this->t('Temporary'),
|
||||
'format_custom_true' => t('Permanent'),
|
||||
'format_custom_true' => $this->t('Permanent'),
|
||||
];
|
||||
$data['file_managed']['status']['filter']['id'] = 'file_status';
|
||||
|
||||
$data['file_managed']['uid']['relationship']['title'] = t('User who uploaded');
|
||||
$data['file_managed']['uid']['relationship']['label'] = t('User who uploaded');
|
||||
$data['file_managed']['uid']['relationship']['title'] = $this->t('User who uploaded');
|
||||
$data['file_managed']['uid']['relationship']['label'] = $this->t('User who uploaded');
|
||||
|
||||
$data['file_usage']['table']['group'] = t('File Usage');
|
||||
$data['file_usage']['table']['group'] = $this->t('File Usage');
|
||||
|
||||
// Provide field-type-things to several base tables; on the core files table
|
||||
// ("file_managed") so that we can create relationships from files to
|
||||
|
@ -119,15 +114,15 @@ class FileViewsData extends EntityViewsData {
|
|||
|
||||
// Describes relationships between files and nodes.
|
||||
$data['file_usage']['file_to_node'] = array(
|
||||
'title' => t('Content'),
|
||||
'help' => t('Content that is associated with this file, usually because this file is in a field on the content.'),
|
||||
'title' => $this->t('Content'),
|
||||
'help' => $this->t('Content that is associated with this file, usually because this file is in a field on the content.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'file_managed' base table is present.
|
||||
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'id',
|
||||
'relationship' => array(
|
||||
'title' => t('Content'),
|
||||
'label' => t('Content'),
|
||||
'title' => $this->t('Content'),
|
||||
'label' => $this->t('Content'),
|
||||
'base' => 'node_field_data',
|
||||
'base field' => 'nid',
|
||||
'relationship field' => 'id',
|
||||
|
@ -135,15 +130,15 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['node_to_file'] = array(
|
||||
'title' => t('File'),
|
||||
'help' => t('A file that is associated with this node, usually because it is in a field on the node.'),
|
||||
'title' => $this->t('File'),
|
||||
'help' => $this->t('A file that is associated with this node, usually because it is in a field on the node.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'node' base table is present.
|
||||
'skip base' => array('file_managed', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'fid',
|
||||
'relationship' => array(
|
||||
'title' => t('File'),
|
||||
'label' => t('File'),
|
||||
'title' => $this->t('File'),
|
||||
'label' => $this->t('File'),
|
||||
'base' => 'file_managed',
|
||||
'base field' => 'fid',
|
||||
'relationship field' => 'fid',
|
||||
|
@ -152,15 +147,15 @@ class FileViewsData extends EntityViewsData {
|
|||
|
||||
// Describes relationships between files and users.
|
||||
$data['file_usage']['file_to_user'] = array(
|
||||
'title' => t('User'),
|
||||
'help' => t('A user that is associated with this file, usually because this file is in a field on the user.'),
|
||||
'title' => $this->t('User'),
|
||||
'help' => $this->t('A user that is associated with this file, usually because this file is in a field on the user.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'file_managed' base table is present.
|
||||
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'id',
|
||||
'relationship' => array(
|
||||
'title' => t('User'),
|
||||
'label' => t('User'),
|
||||
'title' => $this->t('User'),
|
||||
'label' => $this->t('User'),
|
||||
'base' => 'users',
|
||||
'base field' => 'uid',
|
||||
'relationship field' => 'id',
|
||||
|
@ -168,15 +163,15 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['user_to_file'] = array(
|
||||
'title' => t('File'),
|
||||
'help' => t('A file that is associated with this user, usually because it is in a field on the user.'),
|
||||
'title' => $this->t('File'),
|
||||
'help' => $this->t('A file that is associated with this user, usually because it is in a field on the user.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'users' base table is present.
|
||||
'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'comment_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'fid',
|
||||
'relationship' => array(
|
||||
'title' => t('File'),
|
||||
'label' => t('File'),
|
||||
'title' => $this->t('File'),
|
||||
'label' => $this->t('File'),
|
||||
'base' => 'file_managed',
|
||||
'base field' => 'fid',
|
||||
'relationship field' => 'fid',
|
||||
|
@ -185,15 +180,15 @@ class FileViewsData extends EntityViewsData {
|
|||
|
||||
// Describes relationships between files and comments.
|
||||
$data['file_usage']['file_to_comment'] = array(
|
||||
'title' => t('Comment'),
|
||||
'help' => t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
|
||||
'title' => $this->t('Comment'),
|
||||
'help' => $this->t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'file_managed' base table is present.
|
||||
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'id',
|
||||
'relationship' => array(
|
||||
'title' => t('Comment'),
|
||||
'label' => t('Comment'),
|
||||
'title' => $this->t('Comment'),
|
||||
'label' => $this->t('Comment'),
|
||||
'base' => 'comment_field_data',
|
||||
'base field' => 'cid',
|
||||
'relationship field' => 'id',
|
||||
|
@ -201,15 +196,15 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['comment_to_file'] = array(
|
||||
'title' => t('File'),
|
||||
'help' => t('A file that is associated with this comment, usually because it is in a field on the comment.'),
|
||||
'title' => $this->t('File'),
|
||||
'help' => $this->t('A file that is associated with this comment, usually because it is in a field on the comment.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'comment' base table is present.
|
||||
'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'fid',
|
||||
'relationship' => array(
|
||||
'title' => t('File'),
|
||||
'label' => t('File'),
|
||||
'title' => $this->t('File'),
|
||||
'label' => $this->t('File'),
|
||||
'base' => 'file_managed',
|
||||
'base field' => 'fid',
|
||||
'relationship field' => 'fid',
|
||||
|
@ -218,15 +213,15 @@ class FileViewsData extends EntityViewsData {
|
|||
|
||||
// Describes relationships between files and taxonomy_terms.
|
||||
$data['file_usage']['file_to_taxonomy_term'] = array(
|
||||
'title' => t('Taxonomy Term'),
|
||||
'help' => t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
|
||||
'title' => $this->t('Taxonomy Term'),
|
||||
'help' => $this->t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'file_managed' base table is present.
|
||||
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
|
||||
'real field' => 'id',
|
||||
'relationship' => array(
|
||||
'title' => t('Taxonomy Term'),
|
||||
'label' => t('Taxonomy Term'),
|
||||
'title' => $this->t('Taxonomy Term'),
|
||||
'label' => $this->t('Taxonomy Term'),
|
||||
'base' => 'taxonomy_term_data',
|
||||
'base field' => 'tid',
|
||||
'relationship field' => 'id',
|
||||
|
@ -234,15 +229,15 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['taxonomy_term_to_file'] = array(
|
||||
'title' => t('File'),
|
||||
'help' => t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
|
||||
'title' => $this->t('File'),
|
||||
'help' => $this->t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
|
||||
// Only provide this field/relationship/etc.,
|
||||
// when the 'taxonomy_term_data' base table is present.
|
||||
'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data'),
|
||||
'real field' => 'fid',
|
||||
'relationship' => array(
|
||||
'title' => t('File'),
|
||||
'label' => t('File'),
|
||||
'title' => $this->t('File'),
|
||||
'label' => $this->t('File'),
|
||||
'base' => 'file_managed',
|
||||
'base field' => 'fid',
|
||||
'relationship field' => 'fid',
|
||||
|
@ -253,8 +248,8 @@ class FileViewsData extends EntityViewsData {
|
|||
// we've declared joins to, because there is no 'skip base' property on these
|
||||
// fields.
|
||||
$data['file_usage']['module'] = array(
|
||||
'title' => t('Module'),
|
||||
'help' => t('The module managing this file relationship.'),
|
||||
'title' => $this->t('Module'),
|
||||
'help' => $this->t('The module managing this file relationship.'),
|
||||
'field' => array(
|
||||
'id' => 'standard',
|
||||
),
|
||||
|
@ -269,8 +264,8 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['type'] = array(
|
||||
'title' => t('Entity type'),
|
||||
'help' => t('The type of entity that is related to the file.'),
|
||||
'title' => $this->t('Entity type'),
|
||||
'help' => $this->t('The type of entity that is related to the file.'),
|
||||
'field' => array(
|
||||
'id' => 'standard',
|
||||
),
|
||||
|
@ -285,8 +280,8 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['id'] = array(
|
||||
'title' => t('Entity ID'),
|
||||
'help' => t('The ID of the entity that is related to the file.'),
|
||||
'title' => $this->t('Entity ID'),
|
||||
'help' => $this->t('The ID of the entity that is related to the file.'),
|
||||
'field' => array(
|
||||
'id' => 'numeric',
|
||||
),
|
||||
|
@ -301,8 +296,8 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['count'] = array(
|
||||
'title' => t('Use count'),
|
||||
'help' => t('The number of times the file is used by this entity.'),
|
||||
'title' => $this->t('Use count'),
|
||||
'help' => $this->t('The number of times the file is used by this entity.'),
|
||||
'field' => array(
|
||||
'id' => 'numeric',
|
||||
),
|
||||
|
@ -314,8 +309,8 @@ class FileViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
$data['file_usage']['entity_label'] = array(
|
||||
'title' => t('Entity label'),
|
||||
'help' => t('The label of the entity that is related to the file.'),
|
||||
'title' => $this->t('Entity label'),
|
||||
'help' => $this->t('The label of the entity that is related to the file.'),
|
||||
'real field' => 'id',
|
||||
'field' => array(
|
||||
'id' => 'entity_label',
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\EntityReferenceSelection\FileSelection.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\EntityReferenceSelection;
|
||||
|
||||
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\BaseFieldFileFormatterBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\DefaultFileFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldItemInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\FileExtensionFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\FileSize.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\FileUriFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\FilemimeFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
@ -12,11 +7,11 @@ use Drupal\Core\Field\FieldItemInterface;
|
|||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Formatter to render the file mime type, with an optional icon.
|
||||
* Formatter to render the file MIME type, with an optional icon.
|
||||
*
|
||||
* @FieldFormatter(
|
||||
* id = "file_filemime",
|
||||
* label = @Translation("File mime"),
|
||||
* label = @Translation("File MIME"),
|
||||
* field_types = {
|
||||
* "string"
|
||||
* }
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\GenericFileFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\RSSEnclosureFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
@ -28,7 +23,7 @@ class RSSEnclosureFormatter extends FileFormatterBase {
|
|||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$entity = $items->getEntity();
|
||||
// Add the first file as an enclosure to the RSS item. RSS allows only one
|
||||
// enclosure per item. See: http://en.wikipedia.org/wiki/RSS_enclosure
|
||||
// enclosure per item. See: http://wikipedia.org/wiki/RSS_enclosure
|
||||
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
|
||||
$entity->rss_elements[] = array(
|
||||
'key' => 'enclosure',
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\TableFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldFormatter\UrlPlainFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldType\FileFieldItemList.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Core\Field\EntityReferenceFieldItemList;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldType\FileItem.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Component\Utility\Bytes;
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Field\FieldWidget\FileWidget.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Field\FieldWidget;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldFilteredMarkup;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Field\WidgetBase;
|
||||
|
@ -119,7 +113,7 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
|
|||
}
|
||||
|
||||
$title = $this->fieldDefinition->getLabel();
|
||||
$description = FieldFilteredMarkup::create($this->fieldDefinition->getDescription());
|
||||
$description = $this->getFilteredDescription();
|
||||
|
||||
$elements = array();
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Validation\Constraint\FileUriUnique.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Validation\Constraint;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Validation\Constraint\FileValidationConstraint.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Validation\Constraint;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\Validation\Constraint\FileValidationConstraintValidator.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\Validation\Constraint;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\cckfield\d6\FileField.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\cckfield\d6;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\cckfield\d7\FileField.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\cckfield\d7;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\cckfield\d7\ImageField.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\cckfield\d7;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\destination\EntityFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\destination;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
@ -15,7 +10,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\UriItem;
|
|||
use Drupal\Core\File\FileSystemInterface;
|
||||
use Drupal\Core\StreamWrapper\LocalStream;
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
|
||||
|
@ -192,7 +187,7 @@ class EntityFile extends EntityContentBase {
|
|||
* API functions (such as file_prepare_directory()).
|
||||
*
|
||||
* @param string $uri
|
||||
* The URI or path.
|
||||
* The URI or path.
|
||||
*
|
||||
* @return string|false
|
||||
* The directory component of the path or URI, or FALSE if it could not
|
||||
|
@ -213,9 +208,9 @@ class EntityFile extends EntityContentBase {
|
|||
* If either URI is a remote stream, will return FALSE.
|
||||
*
|
||||
* @param string $source
|
||||
* The source URI.
|
||||
* The source URI.
|
||||
* @param string $destination
|
||||
* The destination URI.
|
||||
* The destination URI.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the source and destination URIs refer to the same physical path,
|
||||
|
@ -238,7 +233,7 @@ class EntityFile extends EntityContentBase {
|
|||
* \Drupal\Core\StreamWrapper\LocalStream.
|
||||
*
|
||||
* @param string $uri
|
||||
* The URI or path to test.
|
||||
* The URI or path to test.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\process\d6\CckFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\MigrateSkipRowException;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
|
@ -39,7 +34,7 @@ class CckFile extends ProcessPluginBase implements ContainerFactoryPluginInterfa
|
|||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The current migration.
|
||||
* @param \Drupal\migrate\Plugin\MigrateProcessInterface $migration_plugin
|
||||
* An instance of the 'migration' process plugin.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\process\d6\FileUri.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\source\d6\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
@ -85,7 +80,7 @@ class File extends DrupalSqlBase {
|
|||
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
|
||||
'filename' => $this->t('File name'),
|
||||
'filepath' => $this->t('File path'),
|
||||
'filemime' => $this->t('File Mime Type'),
|
||||
'filemime' => $this->t('File MIME Type'),
|
||||
'status' => $this->t('The published status of a file.'),
|
||||
'timestamp' => $this->t('The time that the file was added.'),
|
||||
'file_directory_path' => $this->t('The Drupal files path.'),
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\source\d6\Upload.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\source\d6\UploadInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\migrate\source\d7\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
|
@ -89,9 +84,9 @@ class File extends DrupalSqlBase {
|
|||
// At this point, $path could be an absolute path or a relative path,
|
||||
// depending on how the scheme's variable was set. So we need to shear out
|
||||
// the source_base_path in order to make them all relative.
|
||||
// @todo Don't depend on destination configuration.
|
||||
// @see https://www.drupal.org/node/2577871
|
||||
$path = str_replace($this->migration->get('destination')['source_base_path'], NULL, $path);
|
||||
// @todo https://www.drupal.org/node/2577871 Don't depend on destination
|
||||
// configuration and figure out if this is even needed at all?
|
||||
$path = str_replace($this->migration->getDestinationConfiguration()['source_base_path'], NULL, $path);
|
||||
$row->setSourceProperty('filepath', $path);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
@ -105,7 +100,7 @@ class File extends DrupalSqlBase {
|
|||
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
|
||||
'filename' => $this->t('File name'),
|
||||
'filepath' => $this->t('File path'),
|
||||
'filemime' => $this->t('File Mime Type'),
|
||||
'filemime' => $this->t('File MIME Type'),
|
||||
'status' => $this->t('The published status of a file.'),
|
||||
'timestamp' => $this->t('The time that the file was added.'),
|
||||
);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\views\argument\Fid.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\views\field\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\views\filter\Status.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\views\filter;
|
||||
|
||||
use Drupal\views\Plugin\views\filter\InOperator;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Plugin\views\wizard\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Plugin\views\wizard;
|
||||
|
||||
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\DownloadTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +90,7 @@ class DownloadTest extends FileManagedTestBase {
|
|||
|
||||
// Tilde (~) is excluded from this test because it is encoded by
|
||||
// rawurlencode() in PHP 5.2 but not in PHP 5.3, as per RFC 3986.
|
||||
// @see http://www.php.net/manual/function.rawurlencode.php#86506
|
||||
// @see http://php.net/manual/function.rawurlencode.php#86506
|
||||
$basename = " -._!$'\"()*@[]?&+%#,;=:\n\x00" . // "Special" ASCII characters.
|
||||
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
|
||||
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldDisplayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldFormatterAccessTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldPathTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldRSSContentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldRevisionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
@ -50,7 +45,7 @@ abstract class FileFieldTestBase extends WebTestBase {
|
|||
// \Drupal\file\Entity\File::load().
|
||||
$file->filesize = filesize($file->uri);
|
||||
|
||||
return entity_create('file', (array) $file);
|
||||
return File::create((array) $file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +72,7 @@ abstract class FileFieldTestBase extends WebTestBase {
|
|||
* A list of widget settings that will be added to the widget defaults.
|
||||
*/
|
||||
function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $field_settings = array(), $widget_settings = array()) {
|
||||
$field_storage = entity_create('field_storage_config', array(
|
||||
$field_storage = FieldStorageConfig::create(array(
|
||||
'entity_type' => $entity_type,
|
||||
'field_name' => $name,
|
||||
'type' => 'file',
|
||||
|
@ -113,7 +108,7 @@ abstract class FileFieldTestBase extends WebTestBase {
|
|||
'required' => !empty($field_settings['required']),
|
||||
'settings' => $field_settings,
|
||||
);
|
||||
entity_create('field_config', $field)->save();
|
||||
FieldConfig::create($field)->save();
|
||||
|
||||
entity_get_form_display($entity_type, $bundle, 'default')
|
||||
->setComponent($name, array(
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldValidateTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileFieldWidgetTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\comment\Entity\Comment;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileListingTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
|
@ -157,7 +152,7 @@ class FileListingTest extends FileFieldTestBase {
|
|||
*/
|
||||
protected function createFile() {
|
||||
// Create a new file entity.
|
||||
$file = entity_create('file', array(
|
||||
$file = File::create([
|
||||
'uid' => 1,
|
||||
'filename' => 'druplicon.txt',
|
||||
'uri' => 'public://druplicon.txt',
|
||||
|
@ -165,7 +160,7 @@ class FileListingTest extends FileFieldTestBase {
|
|||
'created' => 1,
|
||||
'changed' => 1,
|
||||
'status' => FILE_STATUS_PERMANENT,
|
||||
));
|
||||
]);
|
||||
file_put_contents($file->getFileUri(), 'hello world');
|
||||
|
||||
// Save it, inserting a new record.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileManagedAccessTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileManagedFileElementTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileManagedTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\file\FileInterface;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
|
@ -152,10 +148,10 @@ abstract class FileManagedTestBase extends WebTestBase {
|
|||
function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) {
|
||||
// Don't count hook invocations caused by creating the file.
|
||||
\Drupal::state()->set('file_test.count_hook_invocations', FALSE);
|
||||
$file = entity_create('file', array(
|
||||
$file = File::create([
|
||||
'uri' => $this->createUri($filepath, $contents, $scheme),
|
||||
'uid' => 1,
|
||||
));
|
||||
]);
|
||||
$file->save();
|
||||
// Write the record directly rather than using the API so we don't invoke
|
||||
// the hooks.
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileOnTranslatedEntityTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Uploads files to translated nodes.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FilePrivateTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\Core\Entity\Plugin\Validation\Constraint\ReferenceAccessConstraint;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileTokenReplaceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\PrivateFileOnTranslatedEntityTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\RemoteFileSaveUploadTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\SaveUploadTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
@ -52,7 +47,7 @@ class SaveUploadTest extends FileManagedTestBase {
|
|||
$this->drupalLogin($account);
|
||||
|
||||
$image_files = $this->drupalGetTestFiles('image');
|
||||
$this->image = entity_create('file', (array) current($image_files));
|
||||
$this->image = File::create((array) current($image_files));
|
||||
|
||||
list(, $this->imageExtension) = explode('.', $this->image->getFilename());
|
||||
$this->assertTrue(is_file($this->image->getFileUri()), "The image file we're going to upload exists.");
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Views\FileViewsDataTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Views;
|
||||
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\views\Tests\ViewKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests file views data.
|
||||
*
|
||||
* @group file
|
||||
*/
|
||||
class FileViewsDataTest extends ViewKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('file', 'views', 'entity_test', 'user', 'field');
|
||||
|
||||
/**
|
||||
* Tests views data generated for file field relationship.
|
||||
*
|
||||
* @see file_field_views_data()
|
||||
* @see file_field_views_data_views_data_alter()
|
||||
*/
|
||||
public function testRelationshipViewsData() {
|
||||
// Create file field to entity_test.
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_base_file',
|
||||
'type' => 'file',
|
||||
))->save();
|
||||
FieldConfig::create(array(
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_base_file',
|
||||
'bundle' => 'entity_test',
|
||||
))->save();
|
||||
// Check the generated views data.
|
||||
$views_data = Views::viewsData()->get('entity_test__field_base_file');
|
||||
$relationship = $views_data['field_base_file_target_id']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'standard');
|
||||
$this->assertEqual($relationship['base'], 'file_managed');
|
||||
$this->assertEqual($relationship['base field'], 'fid');
|
||||
$this->assertEqual($relationship['entity type'], 'file');
|
||||
// Check the backwards reference.
|
||||
$views_data = Views::viewsData()->get('file_managed');
|
||||
$relationship = $views_data['reverse_field_base_file_entity_test']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'entity_reverse');
|
||||
$this->assertEqual($relationship['base'], 'entity_test');
|
||||
$this->assertEqual($relationship['base field'], 'id');
|
||||
$this->assertEqual($relationship['field table'], 'entity_test__field_base_file');
|
||||
$this->assertEqual($relationship['field field'], 'field_base_file_target_id');
|
||||
$this->assertEqual($relationship['field_name'], 'field_base_file');
|
||||
$this->assertEqual($relationship['entity_type'], 'entity_test');
|
||||
$this->assertEqual($relationship['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]);
|
||||
|
||||
// Create file field to entity_test_mul.
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'entity_test_mul',
|
||||
'field_name' => 'field_data_file',
|
||||
'type' => 'file',
|
||||
))->save();
|
||||
FieldConfig::create(array(
|
||||
'entity_type' => 'entity_test_mul',
|
||||
'field_name' => 'field_data_file',
|
||||
'bundle' => 'entity_test_mul',
|
||||
))->save();
|
||||
// Check the generated views data.
|
||||
$views_data = Views::viewsData()->get('entity_test_mul__field_data_file');
|
||||
$relationship = $views_data['field_data_file_target_id']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'standard');
|
||||
$this->assertEqual($relationship['base'], 'file_managed');
|
||||
$this->assertEqual($relationship['base field'], 'fid');
|
||||
$this->assertEqual($relationship['entity type'], 'file');
|
||||
// Check the backwards reference.
|
||||
$views_data = Views::viewsData()->get('file_managed');
|
||||
$relationship = $views_data['reverse_field_data_file_entity_test_mul']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'entity_reverse');
|
||||
$this->assertEqual($relationship['base'], 'entity_test_mul_property_data');
|
||||
$this->assertEqual($relationship['base field'], 'id');
|
||||
$this->assertEqual($relationship['field table'], 'entity_test_mul__field_data_file');
|
||||
$this->assertEqual($relationship['field field'], 'field_data_file_target_id');
|
||||
$this->assertEqual($relationship['field_name'], 'field_data_file');
|
||||
$this->assertEqual($relationship['entity_type'], 'entity_test_mul');
|
||||
$this->assertEqual($relationship['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Views\RelationshipUserFileDataTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Views;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Tests file on user relationship handler.
|
||||
|
@ -36,20 +34,20 @@ class RelationshipUserFileDataTest extends ViewTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Create the user profile field and instance.
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'user',
|
||||
'field_name' => 'user_file',
|
||||
'type' => 'file',
|
||||
'translatable' => '0',
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'label' => 'User File',
|
||||
'description' => '',
|
||||
'field_name' => 'user_file',
|
||||
'entity_type' => 'user',
|
||||
'bundle' => 'user',
|
||||
'required' => 0,
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('file_test_views'));
|
||||
}
|
||||
|
@ -58,7 +56,7 @@ class RelationshipUserFileDataTest extends ViewTestBase {
|
|||
* Tests using the views file relationship.
|
||||
*/
|
||||
public function testViewsHandlerRelationshipUserFileData() {
|
||||
$file = entity_create('file', array(
|
||||
$file = File::create([
|
||||
'fid' => 2,
|
||||
'uid' => 2,
|
||||
'filename' => 'image-test.jpg',
|
||||
|
@ -67,7 +65,7 @@ class RelationshipUserFileDataTest extends ViewTestBase {
|
|||
'created' => 1,
|
||||
'changed' => 1,
|
||||
'status' => FILE_STATUS_PERMANENT,
|
||||
));
|
||||
]);
|
||||
$file->enforceIsNew();
|
||||
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
|
||||
$file->save();
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file_module_test\Form\FileModuleTestForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\file_module_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file_test\FileTestAccessControlHandler.
|
||||
*/
|
||||
|
||||
namespace Drupal\file_test;
|
||||
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file_test\Form\FileTestForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\file_test\Form;
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file_test\StreamWrapper\DummyReadOnlyStreamWrapper.
|
||||
*/
|
||||
|
||||
namespace Drupal\file_test\StreamWrapper;
|
||||
|
||||
use Drupal\Core\StreamWrapper\LocalReadOnlyStream;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file_test\StreamWrapper\DummyRemoteStreamWrapper.
|
||||
*/
|
||||
|
||||
namespace Drupal\file_test\StreamWrapper;
|
||||
|
||||
use Drupal\Core\StreamWrapper\PublicStream;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file_test\StreamWrapper\DummyStreamWrapper.
|
||||
*/
|
||||
|
||||
namespace Drupal\file_test\StreamWrapper;
|
||||
|
||||
use Drupal\Core\StreamWrapper\LocalStream;
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\CopyTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\DeleteTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
@ -1,24 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileItemTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\Core\Field\FieldItemInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Tests\FieldUnitTestBase;
|
||||
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\file\Entity\File;
|
||||
|
||||
/**
|
||||
* Tests using entity fields of the file field type.
|
||||
*
|
||||
* @group file
|
||||
*/
|
||||
class FileItemTest extends FieldUnitTestBase {
|
||||
class FileItemTest extends FieldKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -47,23 +45,23 @@ class FileItemTest extends FieldUnitTestBase {
|
|||
$this->installEntitySchema('file');
|
||||
$this->installSchema('file', array('file_usage'));
|
||||
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'field_name' => 'file_test',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'file',
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
))->save();
|
||||
$this->directory = $this->getRandomGenerator()->name(8);
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'file_test',
|
||||
'bundle' => 'entity_test',
|
||||
'settings' => array('file_directory' => $this->directory),
|
||||
))->save();
|
||||
])->save();
|
||||
file_put_contents('public://example.txt', $this->randomMachineName());
|
||||
$this->file = entity_create('file', array(
|
||||
$this->file = File::create([
|
||||
'uri' => 'public://example.txt',
|
||||
));
|
||||
]);
|
||||
$this->file->save();
|
||||
}
|
||||
|
||||
|
@ -78,7 +76,7 @@ class FileItemTest extends FieldUnitTestBase {
|
|||
$this->assertEqual($handler_id, 'default:file');
|
||||
|
||||
// Create a test entity with the
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$entity->file_test->target_id = $this->file->id();
|
||||
$entity->file_test->display = 1;
|
||||
$entity->file_test->description = $description = $this->randomMachineName();
|
||||
|
@ -98,9 +96,9 @@ class FileItemTest extends FieldUnitTestBase {
|
|||
|
||||
// Make sure the computed files reflects updates to the file.
|
||||
file_put_contents('public://example-2.txt', $this->randomMachineName());
|
||||
$file2 = entity_create('file', array(
|
||||
$file2 = File::create([
|
||||
'uri' => 'public://example-2.txt',
|
||||
));
|
||||
]);
|
||||
$file2->save();
|
||||
|
||||
$entity->file_test->target_id = $file2->id();
|
||||
|
@ -113,7 +111,7 @@ class FileItemTest extends FieldUnitTestBase {
|
|||
$entity->delete();
|
||||
|
||||
// Test the generateSampleValue() method.
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$entity->file_test->generateSampleItems();
|
||||
$this->entityValidateAndSave($entity);
|
||||
// Verify that the sample file was stored in the correct directory.
|
||||
|
@ -123,16 +121,16 @@ class FileItemTest extends FieldUnitTestBase {
|
|||
// Make sure the computed files reflects updates to the file.
|
||||
file_put_contents('public://example-3.txt', $this->randomMachineName());
|
||||
// Test unsaved file entity.
|
||||
$file3 = entity_create('file', array(
|
||||
$file3 = File::create([
|
||||
'uri' => 'public://example-3.txt',
|
||||
));
|
||||
]);
|
||||
$display = entity_get_display('entity_test', 'entity_test', 'default');
|
||||
$display->setComponent('file_test', [
|
||||
'label' => 'above',
|
||||
'type' => 'file_default',
|
||||
'weight' => 1,
|
||||
])->save();
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$entity->file_test = array('entity' => $file3);
|
||||
$uri = $file3->getFileUri();
|
||||
$output = entity_view($entity, 'default');
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\file\Kernel\FileItemValidationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\FileManagedUnitTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\file\FileInterface;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\user\Entity\User;
|
||||
|
||||
/**
|
||||
* Base class for file unit tests that use the file_test module to test uploads and
|
||||
|
@ -35,7 +32,7 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
|
|||
|
||||
// Make sure that a user with uid 1 exists, self::createFile() relies on
|
||||
// it.
|
||||
$user = entity_create('user', array('uid' => 1, 'name' => $this->randomMachineName()));
|
||||
$user = User::create(['uid' => 1, 'name' => $this->randomMachineName()]);
|
||||
$user->enforceIsNew();
|
||||
$user->save();
|
||||
\Drupal::currentUser()->setAccount($user);
|
||||
|
@ -164,10 +161,10 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
|
|||
function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) {
|
||||
// Don't count hook invocations caused by creating the file.
|
||||
\Drupal::state()->set('file_test.count_hook_invocations', FALSE);
|
||||
$file = entity_create('file', array(
|
||||
$file = File::create([
|
||||
'uri' => $this->createUri($filepath, $contents, $scheme),
|
||||
'uid' => 1,
|
||||
));
|
||||
]);
|
||||
$file->save();
|
||||
// Write the record directly rather than using the API so we don't invoke
|
||||
// the hooks.
|
|
@ -1,16 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Formatter\FileEntityFormatterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Formatter;
|
||||
namespace Drupal\Tests\file\Kernel\Formatter;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests the default file formatter.
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\LoadTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\EntityFileTest.
|
||||
* Contains \Drupal\Tests\file\Kernel\Migrate\EntityFileTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate;
|
||||
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\file\Plugin\migrate\destination\EntityFile;
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests the entity file destination plugin.
|
||||
|
@ -30,7 +30,7 @@ class EntityFileTest extends KernelTestBase {
|
|||
public static $modules = array('system', 'entity_test', 'user', 'file');
|
||||
|
||||
/**
|
||||
* @var \Drupal\file\Tests\Migrate\TestEntityFile $destination
|
||||
* @var \Drupal\Tests\file\Kernel\Migrate\TestEntityFile $destination
|
||||
*/
|
||||
protected $destination;
|
||||
|
||||
|
@ -39,9 +39,8 @@ class EntityFileTest extends KernelTestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
\Drupal::getContainer()->get('stream_wrapper_manager')->registerWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream', StreamWrapperInterface::NORMAL);
|
||||
$this->destination = new TestEntityFile([]);
|
||||
$this->destination->streamWrapperManager = \Drupal::getContainer()->get('stream_wrapper_manager');
|
||||
$this->destination->fileSystem = \Drupal::getContainer()->get('file_system');
|
||||
$this->installEntitySchema('file');
|
||||
|
||||
file_put_contents('/tmp/test-file.jpg', '');
|
||||
|
@ -67,18 +66,17 @@ class EntityFileTest extends KernelTestBase {
|
|||
* An array of file permutations to test.
|
||||
*/
|
||||
protected function localFileDataProvider() {
|
||||
global $base_url;
|
||||
return [
|
||||
// Test a local to local copy.
|
||||
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://file1.jpg', TRUE, DRUPAL_ROOT . '/'],
|
||||
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://file1.jpg', TRUE, $this->root . '/'],
|
||||
// Test a temporary file using an absolute path.
|
||||
[['filepath' => '/tmp/test-file.jpg'], 'temporary://test.jpg', TRUE, ''],
|
||||
// Test a temporary file using a relative path.
|
||||
[['filepath' => 'test-file.jpg'], 'temporary://core/modules/simpletest/files/test.jpg', TRUE, '/tmp/'],
|
||||
// Test a remote path to local.
|
||||
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://remote-file.jpg', TRUE, $base_url . '/'],
|
||||
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://remote-file.jpg', TRUE, $this->root . '/'],
|
||||
// Test a remote path to local inside a folder that doesn't exist.
|
||||
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://folder/remote-file.jpg', TRUE, DRUPAL_ROOT . '/'],
|
||||
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://folder/remote-file.jpg', TRUE, $this->root . '/'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -164,11 +162,11 @@ class EntityFileTest extends KernelTestBase {
|
|||
$method = new \ReflectionMethod($plugin, 'getDirectory');
|
||||
$method->setAccessible(TRUE);
|
||||
|
||||
$this->assertEqual('public://foo', $method->invoke($plugin, 'public://foo/baz.txt'));
|
||||
$this->assertEqual('/path/to', $method->invoke($plugin, '/path/to/foo.txt'));
|
||||
$this->assertSame('public://foo', $method->invoke($plugin, 'public://foo/baz.txt'));
|
||||
$this->assertSame('/path/to', $method->invoke($plugin, '/path/to/foo.txt'));
|
||||
// A directory like public:// (no path) needs to resolve to a physical path.
|
||||
$fs = \Drupal::getContainer()->get('file_system');
|
||||
$this->assertEqual($fs->realpath(Settings::get('file_public_path')), $method->invoke($plugin, 'public://foo.txt'));
|
||||
$this->assertSame($fs->realpath('public://'), $method->invoke($plugin, 'public://foo.txt'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,13 +177,6 @@ class EntityFileTest extends KernelTestBase {
|
|||
$method = new \ReflectionMethod($plugin, 'isLocationUnchanged');
|
||||
$method->setAccessible(TRUE);
|
||||
|
||||
$public_dir = Settings::get('file_public_path');
|
||||
|
||||
// Due to the limitations of realpath(), the source file must exist.
|
||||
touch('public://foo.txt');
|
||||
$this->assertTrue($method->invoke($plugin, $public_dir . '/foo.txt', 'public://foo.txt'));
|
||||
unlink('public://foo.txt');
|
||||
|
||||
$temporary_file = '/tmp/foo.txt';
|
||||
touch($temporary_file);
|
||||
$this->assertTrue($method->invoke($plugin, $temporary_file, 'temporary://foo.txt'));
|
||||
|
@ -257,17 +248,7 @@ class TestEntityFile extends EntityFile {
|
|||
*/
|
||||
public $storage;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
|
||||
*/
|
||||
public $streamWrapperManager;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\File\FileSystemInterface
|
||||
*/
|
||||
public $fileSystem;
|
||||
|
||||
public function __construct($configuration) {
|
||||
public function __construct($configuration = []) {
|
||||
$configuration += array(
|
||||
'source_base_path' => '',
|
||||
'source_path_property' => 'filepath',
|
||||
|
@ -278,6 +259,8 @@ class TestEntityFile extends EntityFile {
|
|||
$this->configuration = $configuration;
|
||||
// We need a mock entity to be passed to save to prevent strict exceptions.
|
||||
$this->mockEntity = EntityTest::create();
|
||||
$this->streamWrapperManager = \Drupal::getContainer()->get('stream_wrapper_manager');
|
||||
$this->fileSystem = \Drupal::getContainer()->get('file_system');
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\MigrateFileStubTest.
|
||||
*/
|
||||
namespace Drupal\Tests\file\Kernel\Migrate;
|
||||
|
||||
namespace Drupal\file\Tests\Migrate;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
use Drupal\migrate_drupal\Tests\StubTestTrait;
|
||||
|
||||
/**
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
/**
|
||||
* Helper for setting up a file migration test.
|
||||
*/
|
||||
trait FileMigrationTestTrait {
|
||||
|
||||
/**
|
||||
* Setup and execute d6_file migration.
|
||||
*/
|
||||
protected function setUpMigratedFiles() {
|
||||
$this->installEntitySchema('file');
|
||||
$this->installConfig(['file']);
|
||||
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration_plugin_manager = $this->container->get('plugin.manager.migration');
|
||||
|
||||
/** @var \Drupal\migrate\Plugin\migration $migration */
|
||||
$migration = $migration_plugin_manager->createInstance('d6_file');
|
||||
$source = $migration->getSourceConfiguration();
|
||||
$source['site_path'] = 'core/modules/simpletest';
|
||||
$migration->set('source', $source);
|
||||
$this->executeMigration($migration);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateFileConfigsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to file.settings.yml.
|
|
@ -1,20 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateFileTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Component\Utility\Random;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\file\FileInterface;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\Tests\MigrateDumpAlterInterface;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\simpletest\TestBase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateDumpAlterInterface;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* file migration.
|
||||
|
@ -23,6 +17,8 @@ use Drupal\simpletest\TestBase;
|
|||
*/
|
||||
class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlterInterface {
|
||||
|
||||
use FileMigrationTestTrait;
|
||||
|
||||
/**
|
||||
* The filename of a file used to test temporary file migration.
|
||||
*
|
||||
|
@ -36,15 +32,7 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('file');
|
||||
$this->installConfig(['file']);
|
||||
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
|
||||
$migration = Migration::load('d6_file');
|
||||
$source = $migration->get('source');
|
||||
$source['site_path'] = 'core/modules/simpletest';
|
||||
$migration->set('source', $source);
|
||||
$this->executeMigration($migration);
|
||||
$this->setUpMigratedFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,8 +72,9 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
$this->assertEntity(5, 'html-1.txt', '24', 'public://html-1.txt', 'text/plain', '1');
|
||||
|
||||
// Test that we can re-import and also test with file_directory_path set.
|
||||
$migration_plugin_manager = $this->container->get('plugin.manager.migration');
|
||||
\Drupal::database()
|
||||
->truncate(Migration::load('d6_file')->getIdMap()->mapTableName())
|
||||
->truncate($migration_plugin_manager->createInstance('d6_file')->getIdMap()->mapTableName())
|
||||
->execute();
|
||||
|
||||
// Update the file_directory_path.
|
||||
|
@ -96,11 +85,11 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
->execute();
|
||||
Database::getConnection('default', 'migrate')
|
||||
->update('variable')
|
||||
->fields(array('value' => serialize($this->getTempFilesDirectory())))
|
||||
->fields(array('value' => serialize(file_directory_temp())))
|
||||
->condition('name', 'file_directory_temp')
|
||||
->execute();
|
||||
|
||||
$migration = \Drupal::entityManager()->getStorage('migration')->loadUnchanged('d6_file');
|
||||
$migration = $migration_plugin_manager->createInstance('d6_file');
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$file = File::load(2);
|
||||
|
@ -126,10 +115,10 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function migrateDumpAlter(TestBase $test) {
|
||||
public static function migrateDumpAlter(KernelTestBase $test) {
|
||||
// Creates a random filename and updates the source database.
|
||||
$random = new Random();
|
||||
$temp_directory = $test->getTempFilesDirectory();
|
||||
$temp_directory = file_directory_temp();
|
||||
file_prepare_directory($temp_directory, FILE_CREATE_DIRECTORY);
|
||||
static::$tempFilename = $test->getDatabasePrefix() . $random->name() . '.jpg';
|
||||
$file_path = $temp_directory . '/' . static::$tempFilename;
|
|
@ -1,15 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateUploadEntityDisplayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upload entity display.
|
||||
|
@ -44,7 +38,7 @@ class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase {
|
|||
$component = $display->getComponent('upload');
|
||||
$this->assertTrue(is_null($component));
|
||||
|
||||
$this->assertIdentical(array('node', 'page', 'default', 'upload'), Migration::load('d6_upload_entity_display')->getIdMap()->lookupDestinationID(array('page')));
|
||||
$this->assertIdentical(array('node', 'page', 'default', 'upload'), $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(array('page')));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateUploadEntityFormDisplayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upload form entity display.
|
||||
|
@ -44,7 +38,7 @@ class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase {
|
|||
$component = $display->getComponent('upload');
|
||||
$this->assertTrue(is_null($component));
|
||||
|
||||
$this->assertIdentical(array('node', 'page', 'default', 'upload'), Migration::load('d6_upload_entity_form_display')->getIdMap()->lookupDestinationID(array('page')));
|
||||
$this->assertIdentical(array('node', 'page', 'default', 'upload'), $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationID(array('page')));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateUploadFieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Uploads migration.
|
||||
|
@ -32,7 +26,7 @@ class MigrateUploadFieldTest extends MigrateDrupal6TestBase {
|
|||
public function testUpload() {
|
||||
$field_storage = FieldStorageConfig::load('node.upload');
|
||||
$this->assertIdentical('node.upload', $field_storage->id());
|
||||
$this->assertIdentical(array('node', 'upload'), Migration::load('d6_upload_field')->getIdMap()->lookupDestinationID(array('')));
|
||||
$this->assertIdentical(array('node', 'upload'), $this->getMigration('d6_upload_field')->getIdMap()->lookupDestinationID(array('')));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateUploadInstanceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upload field instance migration.
|
||||
|
@ -44,7 +38,7 @@ class MigrateUploadInstanceTest extends MigrateDrupal6TestBase {
|
|||
$field = FieldConfig::load('node.article.upload');
|
||||
$this->assertTrue(is_null($field));
|
||||
|
||||
$this->assertIdentical(array('node', 'page', 'upload'), Migration::load('d6_upload_field_instance')->getIdMap()->lookupDestinationID(array('page')));
|
||||
$this->assertIdentical(array('node', 'page', 'upload'), $this->getMigration('d6_upload_field_instance')->getIdMap()->lookupDestinationID(array('page')));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d6\MigrateUploadTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d6;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +49,7 @@ class MigrateUploadTest extends MigrateDrupal6TestBase {
|
|||
$this->migrateContent();
|
||||
// Since we are only testing a subset of the file migration, do not check
|
||||
// that the full file migration has been run.
|
||||
$migration = Migration::load('d6_upload');
|
||||
$migration = $this->getMigration('d6_upload');
|
||||
$migration->set('requirements', []);
|
||||
$this->executeMigration($migration);
|
||||
}
|
|
@ -1,15 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\Migrate\d7\MigrateFileTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests\Migrate\d7;
|
||||
namespace Drupal\Tests\file\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\file\FileInterface;
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Migrates all files in the file_managed table.
|
||||
|
@ -27,6 +23,7 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
|
|||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('file');
|
||||
$this->container->get('stream_wrapper_manager')->registerWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream', StreamWrapperInterface::NORMAL);
|
||||
|
||||
$fs = \Drupal::service('file_system');
|
||||
// The public file directory active during the test will serve as the
|
||||
|
@ -34,15 +31,15 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
|
|||
$fs->mkdir('public://sites/default/files', NULL, TRUE);
|
||||
file_put_contents('public://sites/default/files/cube.jpeg', str_repeat('*', 3620));
|
||||
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
|
||||
$migration = entity_load('migration', 'd7_file');
|
||||
/** @var \Drupal\migrate\Plugin\Migration $migration */
|
||||
$migration = $this->getMigration('d7_file');
|
||||
// Set the destination plugin's source_base_path configuration value, which
|
||||
// would normally be set by the user running the migration.
|
||||
$migration->set('destination', [
|
||||
'plugin' => 'entity:file',
|
||||
// Note that source_base_path must include a trailing slash because it's
|
||||
// prepended directly to the value of the source path property.
|
||||
'source_base_path' => $fs->realpath($this->publicFilesDirectory) . '/',
|
||||
'source_base_path' => $fs->realpath('public://') . '/',
|
||||
// This is set in the migration's YAML file, but we need to repeat it
|
||||
// here because all the destination configuration must be set at once.
|
||||
'source_path_property' => 'filepath',
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\MoveTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\SaveDataTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\SaveTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\file\Tests\SpaceUsedTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\file\Tests;
|
||||
namespace Drupal\Tests\file\Kernel;
|
||||
use Drupal\file\Entity\File;
|
||||
|
||||
/**
|
||||
* Tests the spaceUsed() function.
|
||||
|
@ -44,11 +40,11 @@ class SpaceUsedTest extends FileManagedUnitTestBase {
|
|||
*/
|
||||
protected function createFileWithSize($uri, $size, $uid, $status = FILE_STATUS_PERMANENT) {
|
||||
file_put_contents($uri, $this->randomMachineName($size));
|
||||
$file = entity_create('file', array(
|
||||
$file = File::create([
|
||||
'uri' => $uri,
|
||||
'uid' => $uid,
|
||||
'status' => $status,
|
||||
));
|
||||
]);
|
||||
$file->save();
|
||||
return $file;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue