Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / migrate / src / Plugin / migrate / process / FileProcessBase.php
1 <?php
2
3 namespace Drupal\migrate\Plugin\migrate\process;
4
5 use Drupal\migrate\ProcessPluginBase;
6
7 /**
8  * Provides functionality for file process plugins.
9  *
10  * Available configuration keys:
11  * - file_exists: (optional) Replace behavior when the destination file already
12  *   exists:
13  *   - 'replace' - (default) Replace the existing file.
14  *   - 'rename' - Append _{incrementing number} until the filename is
15  *     unique.
16  *   - 'use existing' - Do nothing and return FALSE.
17  */
18 abstract class FileProcessBase extends ProcessPluginBase {
19
20   /**
21    * Constructs a file process plugin.
22    *
23    * @param array $configuration
24    *   The plugin configuration.
25    * @param string $plugin_id
26    *   The plugin ID.
27    * @param mixed $plugin_definition
28    *   The plugin definition.
29    */
30   public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
31     if (array_key_exists('file_exists', $configuration)) {
32       switch ($configuration['file_exists']) {
33         case 'use existing':
34           $configuration['file_exists'] = FILE_EXISTS_ERROR;
35           break;
36         case 'rename':
37           $configuration['file_exists'] = FILE_EXISTS_RENAME;
38           break;
39         default:
40           $configuration['file_exists'] = FILE_EXISTS_REPLACE;
41       }
42     }
43     if (array_key_exists('reuse', $configuration)) {
44       @trigger_error("Using the key 'reuse' is deprecated, use 'file_exists' => 'use existing' instead. See https://www.drupal.org/node/2981389.", E_USER_DEPRECATED);
45       if (!empty($configuration['reuse'])) {
46         $configuration['file_exists'] = FILE_EXISTS_ERROR;
47       }
48     }
49     if (array_key_exists('rename', $configuration)) {
50       @trigger_error("Using the key 'rename' is deprecated, use 'file_exists' => 'rename' instead. See https://www.drupal.org/node/2981389.", E_USER_DEPRECATED);
51       if (!empty($configuration['rename'])) {
52         $configuration['file_exists'] = FILE_EXISTS_RENAME;
53       }
54     }
55     $configuration += ['file_exists' => FILE_EXISTS_REPLACE];
56     parent::__construct($configuration, $plugin_id, $plugin_definition);
57   }
58
59 }