Sha1FileHashingService
class Sha1FileHashingService implements FileHashingService, Flushable (View source)
Utility for computing and comparing unique file hash. All $fs
parameters can either be:
- an
AssetStore
constant VISIBILITY constant or - an actual
Filesystem
object.
Traits
Provides extensions to this object to integrate it with standard config API methods.
A class that can be instantiated or replaced via DI
Config options
default_cachable | bool | Whetever Sha1FileHashingService should cache hash values by default. |
Properties
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Compute the hash of the provided file
This function is triggered early in the request if the "flush" query parameter has been set. Each class that implements Flushable implements this function which looks after it's own specific flushing functionality.
Determined if we have an hash for the provided key and return the hash if present
Move the specified hash value to a different cached key.
Details
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
stat(string $name)
deprecated
deprecated
Get inherited config value
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
$this
set_stat(string $name, mixed $value)
deprecated
deprecated
Update the config value for a given property
static Injectable
create(mixed ...$args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
string
computeFromStream(resource $stream)
Compute the Hash value of the provided stream.
protected string
algo()
Valid hashing algorithm constant that can be passed to hash_init
.
string
computeFromFile(string $fileID, Filesystem|string $fs)
Compute the hash of the provided file
bool
compare($hashOne, $hashTwo)
Compare 2 full or partial hashes.
bool
isCached()
Whatever computed values should be cached
void
enableCache()
Enable caching of computed hash.
void
disableCache()
Disable caching of computed hash.
void
invalidate($fileID, $fs)
Invlaidate the cache for a specific key.
static
flush()
This function is triggered early in the request if the "flush" query parameter has been set. Each class that implements Flushable implements this function which looks after it's own specific flushing functionality.
false|string
get(string $fileID, Filesystem|string $fs)
Determined if we have an hash for the provided key and return the hash if present
void
set($fileID, $fs, $hash)
Explicitely set the cached hash for the provided key.
void
move(string $fromFileID, Filesystem|string $fromFs, string $toFileID, Filesystem|string $toFs = false)
Move the specified hash value to a different cached key.