9d5672c0fe895dfa40df43385dfd9dadf31c381c
[yaffs-website] / web / modules / contrib / dropzonejs / src / DropzoneJsUploadSaveInterface.php
1 <?php
2
3 namespace Drupal\dropzonejs;
4
5 use Drupal\Core\Session\AccountProxyInterface;
6 use Drupal\file\FileInterface;
7
8 /**
9  * Provides an interface for classes that save DropzoneJs uploads.
10  */
11 interface DropzoneJsUploadSaveInterface {
12
13   /**
14    * Creates a file entity form an uploaded file.
15    *
16    * Note: files being created using this method are flagged as temporary and
17    * not saved yet.
18    *
19    * @param string $uri
20    *   The path to the file we want to upload.
21    * @param string $destination
22    *   A string containing the URI that the file should be copied to. This must
23    *   be a stream wrapper URI.
24    * @param string $extensions
25    *   A space separated list of valid extensions.
26    * @param \Drupal\Core\Session\AccountProxyInterface $user
27    *   The owner of the file.
28    * @param array $validators
29    *   (Optional) Associative array of callback functions used to validate the
30    *   file. See file_validate() for more documentation. Note that we add
31    *   file_validate_extensions and file_validate_name_length in this method
32    *   already.
33    *
34    * @return \Drupal\file\FileInterface|bool
35    *   The file entity of the newly uploaded file or false in case of a failure.
36    *   The file isn't saved yet. That should be handled by the caller.
37    */
38   public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, array $validators = []);
39
40   /**
41    * Validate the uploaded file.
42    *
43    * @param \Drupal\file\FileInterface $file
44    *   The file entity object.
45    * @param string $extensions
46    *   A space separated string of valid extensions.
47    * @param array $additional_validators
48    *   An optional, associative array of callback functions used to validate the
49    *   file. See file_validate() for more documentation. Note that we add
50    *   file_validate_extensions and file_validate_name_length in this method
51    *   already.
52    *
53    * @return array
54    *   An array containing validation error messages.
55    */
56   public function validateFile(FileInterface $file, $extensions, array $additional_validators = []);
57
58 }