Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668

This commit is contained in:
Pantheon Automation 2015-10-21 21:44:50 -07:00 committed by Greg Anderson
parent f32e58e4b1
commit 8e18df8c36
3062 changed files with 15044 additions and 172506 deletions

View file

@ -10,7 +10,6 @@ namespace Drupal\file;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\user\EntityOwnerInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\user\UserInterface;
/**
* Defines getter and setter methods for file entity base fields.

View file

@ -8,7 +8,6 @@
namespace Drupal\file\FileUsage;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\file\FileInterface;
/**

View file

@ -51,7 +51,7 @@ class FileItem extends EntityReferenceItem {
public static function defaultFieldSettings() {
return array(
'file_extensions' => 'txt',
'file_directory' => '',
'file_directory' => '[date:custom:Y]-[date:custom:m]',
'max_filesize' => '',
'description_field' => 0,
) + parent::defaultFieldSettings();
@ -267,7 +267,22 @@ class FileItem extends EntityReferenceItem {
* @see token_replace()
*/
public function getUploadLocation($data = array()) {
$settings = $this->getSettings();
return static::doGetUploadLocation($this->getSettings(), $data);
}
/**
* Determines the URI for a file field.
*
* @param array $settings
* The array of field settings.
* @param array $data
* An array of token objects to pass to token_replace().
*
* @return string
* An unsanitized file directory URI with tokens replaced. The result of
* the token replacement is then converted to plain text and returned.
*/
protected static function doGetUploadLocation(array $settings, $data = []) {
$destination = trim($settings['file_directory'], '/');
// Replace tokens. As the tokens might contain HTML we convert it to plain
@ -312,7 +327,7 @@ class FileItem extends EntityReferenceItem {
$settings = $field_definition->getSettings();
// Prepare destination.
$dirname = $settings['uri_scheme'] . '://' . $settings['file_directory'];
$dirname = static::doGetUploadLocation($settings);
file_prepare_directory($dirname, FILE_CREATE_DIRECTORY);
// Generate a file entity.

View file

@ -17,7 +17,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\ElementInfoManagerInterface;
use Drupal\Core\Url;
use Drupal\file\Element\ManagedFile;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\file\Entity\File;

View file

@ -23,6 +23,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class CckFile extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* The migration process plugin, configured for lookups in d6_file.
*
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
*/
protected $migrationPlugin;
/**
@ -92,6 +97,8 @@ class CckFile extends ProcessPluginBase implements ContainerFactoryPluginInterfa
'target_id' => $fid,
'display' => $value['list'],
'description' => isset($options['description']) ? $options['description'] : '',
'alt' => isset($options['alt']) ? $options['alt'] : '',
'title' => isset($options['title']) ? $options['title'] : '',
];
}
else {

View file

@ -8,7 +8,6 @@
namespace Drupal\file\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;

View file

@ -7,8 +7,6 @@
namespace Drupal\file\Tests;
use Symfony\Component\HttpFoundation\Request;
/**
* Tests for download/file transfer functions.
*

View file

@ -19,20 +19,29 @@ class FileFieldPathTest extends FileFieldTestBase {
* Tests the normal formatter display on node display.
*/
function testUploadPath() {
/** @var \Drupal\node\NodeStorageInterface $node_storage */
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$field_name = strtolower($this->randomMachineName());
$type_name = 'article';
$this->createFileField($field_name, 'node', $type_name);
/** @var \Drupal\file\FileInterface $test_file */
$test_file = $this->getTestFile('text');
// Create a new node.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Check that the file was uploaded to the file root.
// Check that the file was uploaded to the correct location.
$node_storage->resetCache(array($nid));
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
$this->assertPathMatch('public://' . $test_file->getFilename(), $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
/** @var \Drupal\file\FileInterface $node_file */
$node_file = $node->{$field_name}->entity;
$date_formatter = $this->container->get('date.formatter');
$expected_filename =
'public://' .
$date_formatter->format(REQUEST_TIME, 'custom', 'Y') . '-' .
$date_formatter->format(REQUEST_TIME, 'custom', 'm') . '/' .
$test_file->getFilename();
$this->assertPathMatch($expected_filename, $node_file->getFileUri(), format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->getFileUri())));
// Change the path to contain multiple subdirectories.
$this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz'));

View file

@ -7,7 +7,6 @@
namespace Drupal\file\Tests;
use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;
/**

View file

@ -8,9 +8,6 @@
namespace Drupal\file\Tests;
use Drupal\file\Entity\File;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\Sql\SqlEntityStorageInterface;
/**
* File saving tests.