コード例 #1
0
 /**
  * Converts the given string or array to a Resource object.
  *
  * If the input format is an array, this method assumes the resource to be a
  * fresh file upload and imports the temporary upload file through the
  * resource manager.
  *
  * @param array $source The upload info (expected keys: error, name, tmp_name)
  * @return object An object or an instance of F3\FLOW3\Error\Error if the input format is not supported or could not be converted for other reasons
  * @author Robert Lemke <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function convertFrom($source)
 {
     if (is_array($source)) {
         if ($source['error'] === \UPLOAD_ERR_NO_FILE) {
             return NULL;
         }
         if ($source['error'] !== \UPLOAD_ERR_OK) {
             return $this->objectFactory->create('F3\\FLOW3\\Error\\Error', \F3\FLOW3\Utility\Files::getUploadErrorMessage($source['error']), 1264440823);
         }
         $resource = $this->resourceManager->importUploadedResource($source);
         if ($resource === FALSE) {
             return $this->objectFactory->create('F3\\FLOW3\\Error\\Error', 'The resource manager could not create a resource instance.', 1264517906);
         } else {
             return $resource;
         }
     } else {
         return $this->objectFactory->create('F3\\FLOW3\\Error\\Error', 'The source for conversion to a resource object was not an array.', 1264440811);
     }
 }