checkDirectoryPermissions example

'data' => $result,
        ]);
    }

    /** * @return void */
    public function isUpdateAllowedAction()
    {
        $fs = new SwagUpdateFileSystem();

        $result = $fs->checkDirectoryPermissions(Shopware()->DocPath(), true);

        if (!empty($result)) {
            $wrongPermissionCount = \count($result);

            $this->container->get('corelogger')->error(
                sprintf('SwagUpdate: There are %d files without write permission. FTP credentials are needed.', $wrongPermissionCount),
                $result
            );

            $this->View()->assign([
                'success' => true,
                


            if ($fixPermission && !$fileInfo->isWritable()) {
                $this->fixDirectoryPermission($fileInfo);
            }

            if (!$fileInfo->isWritable()) {
                $errors[] = $fileInfo->getPathname();
                continue;
            }

            $errors = array_merge($errors$this->checkDirectoryPermissions($fileInfo->getPathname()$fixPermission));
        }

        return $errors;
    }

    private function fixDirectoryPermission(SplFileInfo $fileInfo)
    {
        try {
            $permission = substr(sprintf('%o', $fileInfo->getPerms()), -4);
        } catch (Exception $e) {
            // cannot get permissions...
Home | Imprint | This part of the site doesn't use cookies.