checkSingleDirectoryPermissions example

public function check(): ValidationResult
    {
        $directories = [];
        $checkedDirectories = [];

        $fullPath = rtrim($this->rootDir . '/');
        $checkedDirectories[] = $fullPath;

        $directories = array_merge(
            $directories,
            $this->filesystem->checkSingleDirectoryPermissions($fullPath, true)
        );

        if (empty($directories)) {
            return new ValidationResult(
                'writeableCheck',
                true,
                'writeableCheckValid',
                ['checkedDirectories' => implode('<br>', $checkedDirectories)]
            );
        }

        
if (!\is_array($requirement['value'])) {
            throw new InvalidArgumentException(__CLASS__ . ' needs an array as value for the requirement check');
        }

        foreach ($requirement['value'] as $path) {
            $fullPath = rtrim(Shopware()->DocPath($path), '/');
            $checkedDirectories[] = $fullPath;

            $fixPermissions = true;
            $directories = array_merge(
                $directories,
                $this->fileSystem->checkSingleDirectoryPermissions($fullPath$fixPermissions)
            );
        }

        if (empty($directories)) {
            return [
                'type' => self::CHECK_TYPE,
                'errorLevel' => Validation::REQUIREMENT_VALID,
                'message' => sprintf(
                    $successMessage,
                    implode('<br>', $checkedDirectories)
                ),
            ];
return $errors;
    }

    /** * @param string $directory * @param bool $fixPermission * * @return array of errors */
    public function checkDirectoryPermissions($directory$fixPermission = false)
    {
        $errors = $this->checkSingleDirectoryPermissions($directory$fixPermission);

        if (!empty($errors)) {
            return $errors;
        }

        /** @var DirectoryIterator $fileInfo */
        foreach (new DirectoryIterator($directory) as $fileInfo) {
            if ($fileInfo->isDot()) {
                continue;
            }

            
Home | Imprint | This part of the site doesn't use cookies.