Deserializes data into a PublicFile into an entity.

@param \stdClass $data
@param File|null $file
@param array     $options

@return File
176729
public function deserialize($data, File $file = null, array $options = [])
    {
        $this->sipe('log', 'setLog', $data, $file);
        $this->sipe('status', 'setStatus', $data, $file);
        $this->sipe('executionDate', 'setExecutionDate', $data, $file);
        $this->sipe('action', 'setAction', $data, $file);

        if (isset($data['uploadedFile'])) {
            $uploadedFile = $this->fileSerializer->deserialize($data['uploadedFile']);
            if ($uploadedFile) {
                $file->setFile($uploadedFile);
            }
        }

        return $file;
    }
1322356
public function storeFile($file, array &$document, array $options = [])
    {
        $this->log([
            'storeFile' => true,
            'count' => count($document),
            'options' => $options,
        ]);

        return parent::storeFile($file, $document, $options);
    }
581422
public function download($file, $filename = '', $options = array())
    {
        $readfile = empty($options['text']);

        if ($readfile && !is_file($file)) {
            return null;
        }

        if ($readfile && empty($filename)) {
            $filename = basename($file);
        }

        $size = $readfile ? filesize($file) : strlen($file);

        $this->addHeader('Expires', 0)
            ->addHeader('Pragma', 'public')
            ->addHeader('Content-Length', $size)
            ->addHeader('Cache-Control', 'must-revalidate')
            ->addHeader('Content-Description', 'File Transfer')
            ->addHeader('Content-Type', 'application/octet-stream')
            ->addHeader('Content-Disposition', 'attachment; filename=' . $filename)
            ->addOptionalHeaders($options)
            ->sendHeaders();

        if ($readfile) {
            readfile($file);
        } else {
            echo $file;
        }

        exit;
    }
593922
public function upload($file, array $options = [])
    {
        $filename = sprintf('%s-%s', rand(100, 999), $file->getClientOriginalName());
        return Storage::putFileAs($this->uploadFolder, $file, $filename);
    }
1260564
public function xSendFile($file, $options = array())
    {
        Yii::app()->request->xSendFile($file->resolvePath(), $options);
    }
88592
public function unpack(Data $data, array $options = null)
    {
        $defaults = ['dirty' => false];
        $options = $options ? array_merge($defaults, $options) : $defaults;

        $attributes = $this->getAttributes();

        $record = [];
        foreach ($data->pick(array_keys($attributes)) as $key => $value) {
            if ($options['dirty'] && !$data->isDirty($key)) {
                continue;
            }

            if ($value !== null) {
                $attribute = $attributes[$key];
                $value = Type::factory($attribute['type'])->store($value, $attribute);
            }

            $record[$key] = $value;
        }

        return $record;
    }
1311762
public function deserialize($data, Plugin $plugin, array $options = [])
    {
        $this->sipe('id', 'setUuid', $data, $plugin);
        $this->sipe('name', 'setDisplayName', $data, $plugin);
        $this->sipe('vendor', 'setVendorName', $data, $plugin);
        $this->sipe('bundle', 'setBundleName', $data, $plugin);

        return $plugin;
    }
850933
public function file($name, array $options = [])
    {
        return $this->form->file($name, $this->addFormControlClass($this->getFieldOptions($name, $options)));
    }
1155283
protected static function mergeJsonData( $file, $data )
    {
        return static::saveJsonData( $file, ArrayUtils::merge(
            (array) static::loadJsonData( $file ),
            $data
        ) );
    }
45401
public function provide($data = null, array $options = [])
    {
        if (empty($data) && ! empty($options['entity'])) {
            $data = $options['entity'];
        }

        if ($data instanceof EntityInterface) {
            return $this->provideFromEntity($data, $this->config->getField());
        }

        if ($data instanceof RequestInterface) {
            return $this->provideFromRequest($data, $this->config->getField());
        }

        return $data;
    }
749416
public function process($file, $options)
    {
        $process = $this->execute($file, $options);

        return $this->setError($process);
    }
61707
public function createFormBuilder($data = null, array $options = array())
    {
        return $this->getContainer()->get('form.factory')->createBuilder('form', $data, $options);
    }
729780
public function putFile($path, $file, $options = [], $defaults = 'hashName')
    {
        return $this->putFileAs($path, $file, $file->$defaults(), $options);
    }
157192
public function deserialize($data, BadgeClass $badge = null, array $options = [])
    {
        $this->sipe('name', 'setName', $data, $badge);
        $this->sipe('description', 'setDescription', $data, $badge);
        $this->sipe('criteria', 'setCriteria', $data, $badge);
        $this->sipe('duration', 'setDurationValidation', $data, $badge);
        $this->sipe('issuingMode', 'setIssuingMode', $data, $badge);

        if (isset($data['issuer'])) {
            $badge->setIssuer($this->om->getObject($data['issuer'], Organization::class));
        }

        if (isset($data['image']) && isset($data['image']['id'])) {
            $thumbnail = $this->om->getObject($data['image'], PublicFile::class);
            $badge->setImage($data['image']['url']);
            $this->fileUt->createFileUse(
                $thumbnail,
                BadgeClass::class,
                $badge->getUuid()
            );
        }

        if (isset($data['workspace']) && isset($data['workspace']['id'])) {
            $workspace = $this->om->getRepository(Workspace::class)->find($data['workspace']['id']);
            $badge->setWorkspace($workspace);
            //main orga maybe instead ? this is fishy
            $badge->setIssuer($workspace->getOrganizations()[0]);
        }

        if (isset($data['tags'])) {
            if (is_string($data['tags'])) {
                $this->deserializeTags($badge, explode(',', $data['tags']));
            } else {
                $this->deserializeTags($badge, $data['tags']);
            }
        }

        if (isset($data['allowedUsers'])) {
            $allowed = [];
            foreach ($data['allowedUsers'] as $user) {
                $allowed[] = $this->om->getObject($user, User::class);
            }
            $badge->setAllowedIssuers($allowed);
        }

        if (isset($data['allowedGroups'])) {
            $allowed = [];
            foreach ($data['allowedGroups'] as $group) {
                $allowed[] = $this->om->getObject($group, Group::class);
            }
            $badge->setAllowedIssuersGroups($allowed);
        }

        return $badge;
    }
753747
public function serialize(PublicFile $file, array $options = [])
    {
        return [
            'id' => $file->getId(),
            'type' => $file->getMimeType(),
            'name' => $file->getFilename(),
            'size' => $file->getSize(),
            'directory' => $file->getDirectoryName(), // I'm not sure this is needed
            'sourceType' => $file->getSourceType(),
            'url' => $file->getUrl(),

            // deprecated use `type` / `name` (this is to be compliant with the js File API)
            'mimeType' => $file->getMimeType(),
            'filename' => $file->getFilename(),
          ];
    }
662355
public function load($file, array $options = [])
    {
        if ($this->getDefault($options, self::SIMPLEXML, false)) {
            return $this->loadSimpleXml($file, $options);
        }

        return $this->loadDom($file, $options);
    }
1018139
public static function createUniqueNodeParser($file, $options = array())
    {
        $stream = new Stream\File($file, 16384);
        $parser = new Parser\UniqueNode($options);
        return new XmlStringStreamer($parser, $stream);
    }