src/File/FileUtil.php
public function getFolderFromDca($folder, DataContainer $dc = null)
    {
        // upload folder
        if (\is_array($folder) && null !== $dc) {
            $callback = $folder;
            $folder = System::importStatic($callback[0])->{$callback[1]}($dc);
        } elseif (\is_callable($folder) && null !== $dc) {
            $method = $folder;
            $folder = $method($dc);
        } elseif (\is_string($folder)) {
            if (false !== strpos($folder, '../')) {
                throw new \Exception("Invalid target path $folder");
            }
        }

        if ($folder instanceof File) {
            $folder = $folder->value;
        } elseif ($folder instanceof FilesModel) {
            $folder = $folder->path;
        }

        if (Validator::isUuid($folder)) {
            $folderObj = $this->getFolderFromUuid($folder);
            $folder = $folderObj->value;
        }

        return $folder;
    }
public function getFolderFromDca($folder, DataContainer $dc = null)
    {
        // upload folder
        if (\is_array($folder) && null !== $dc) {
            $callback = $folder;
            $folder = System::importStatic($callback[0])->{$callback[1]}($dc);
        } elseif (\is_callable($folder) && null !== $dc) {
            $method = $folder;
            $folder = $method($dc);
        } elseif (\is_string($folder)) {
            if (false !== strpos($folder, '../')) {
                throw new \Exception("Invalid target path $folder");
            }
        }

        if ($folder instanceof File) {
            $folder = $folder->value;
        } elseif ($folder instanceof FilesModel) {
            $folder = $folder->path;
        }

        if (Validator::isUuid($folder)) {
            $folderObj = $this->getFolderFromUuid($folder);
            $folder = $folderObj->value;
        }

        return $folder;
    }
public function getFolderFromDca ( $ folder , DataContainer $ dc = null ) { // upload folder if ( \ is_array ( $ folder ) && null !== $ dc ) { $ callback = $ folder ; $ folder = System :: importStatic ( $ callback [ 0 ] ) -> { $ callback [ 1 ] } ( $ dc ) ; } elseif ( \ is_callable ( $ folder ) && null !== $ dc ) { $ method = $ folder ; $ folder = $ method ( $ dc ) ; } elseif ( \ is_string ( $ folder ) ) { if ( false !== strpos ( $ folder , '../' ) ) { throw new \ Exception ( "Invalid target path $folder" ) ; } } if ( $ folder instanceof File ) { $ folder = $ folder -> value ; } elseif ( $ folder instanceof FilesModel ) { $ folder = $ folder -> path ; } if ( Validator :: isUuid ( $ folder ) ) { $ folderObj = $ this -> getFolderFromUuid ( $ folder ) ; $ folder = $ folderObj -> value ; } return $ folder ; }
Get real folder from datacontainer attribute.

@param mixed              $folder The folder as uuid, function, callback array('CLASS', 'method') or string (files/...)
@param DataContainer|null $dc     Optional \DataContainer, required for function and callback

@throws \Exception If ../ is part of the path

@return mixed|null The folder path or null
Get real folder from datacontainer attribute .