Example #1
0
 /**
  * Create new ElggFile entities from uploaded files
  *
  * @param string $input      Name of the file input
  * @param array  $attributes Attributes and metadata for saving files
  * @param array  $options    Additional factory options (including entity attributes such as type, subtype, owner_guid, container_guid, access_id etc
  *                             'icon_sizes'            ARR Optional. An array of icon sizes to create (for image uploads)
  *                             'coords'                ARR Optional. Coordinates for icon cropping
  *                             'filestore_prefix'      STR Optional. Custom prefix on Elgg filestore
  *                             'icon_filestore_prefix' STR Optional. Custom prefix for created icons on Elgg filestore
  * @return ElggFile[]
  */
 public function handle($input = '', array $attributes = array(), array $options = array())
 {
     $result = array();
     $uploads = $this->getUploads($input);
     $filestore_prefix = elgg_extract('filestore_prefix', $options, $this->config->getDefaultFilestorePrefix());
     unset($options['filestore_prefix']);
     foreach ($uploads as $props) {
         $upload = new Upload($props);
         $upload->save($attributes, $filestore_prefix);
         if ($upload->file instanceof ElggEntity && $upload->simpletype == 'image') {
             $this->iconFactory->create($upload->file, null, $options);
         }
         $result[] = $upload;
     }
     return $result;
 }