Gumdrop\FileHandler::getSourceFolderHash PHP Метод

getSourceFolderHash() публичный Метод

public getSourceFolderHash ( $location = '' )
    public function getSourceFolderHash($location = '')
    {
        if ($location == '') {
            $location = $this->app->getSourceLocation();
        }
        $files = array();
        $items = glob($location . '/*');
        if (is_array($items) && count($items) > 0) {
            foreach ($items as $item) {
                $relative_path = ltrim(str_replace(realpath($location), '', realpath($item)), DIRECTORY_SEPARATOR);
                if (strpos($relative_path, '_') !== 0 || $relative_path == '_layout') {
                    if (is_dir($item)) {
                        $files = array_merge($files, $this->getSourceFolderHash($item));
                    } else {
                        $files[] = $item;
                    }
                }
            }
        }
        if ($location == $this->app->getSourceLocation()) {
            $content = '';
            sort($files);
            foreach ($files as $file) {
                $content .= $file . file_get_contents($file);
            }
            //Using crc32 because it's fast and it's a non-cryptographic use case
            $checksum = crc32($content);
            $checksum = sprintf("%u", $checksum);
            return $checksum;
        }
        return $files;
    }