Pimcore\Model\Asset\WebDAV\Folder::createFile PHP Method

createFile() public method

public createFile ( string $name, null $data = null ) : null | string | void
$name string
$data null
return null | string | void
    public function createFile($name, $data = null)
    {
        $tmpFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/asset-dav-tmp-file-" . uniqid();
        file_put_contents($tmpFile, $data);
        $user = AdminTool::getCurrentUser();
        if ($this->asset->isAllowed("create")) {
            $asset = Asset::create($this->asset->getId(), ["filename" => Element\Service::getValidKey($name, "asset"), "sourcePath" => $tmpFile, "userModification" => $user->getId(), "userOwner" => $user->getId()]);
            unlink($tmpFile);
        } else {
            throw new DAV\Exception\Forbidden();
        }
    }