PVFileManager allows easy manipulation of the file system such as making directories or getting mime types.
The class has various functions that make file manipulation reasonably easy.
Examples:
//Count the number of files in a directory
echo PVFileManager::getFilesInDirectory('/path/to/directry');
//Get Mime Type
echo PVFileManager::getFileMimeType('image.jpg');
//Write To File
PVFileManager::getFileMimeType('/path/to/file', 'Hello World!');
| package |
util |
|---|
__callStatic(string $method, mixed $args = array()) : mixed
| access |
public |
|---|
stringThe key/name assigned to the method when added
mixedArguements to pass to the annoymous function. The function is called using call_user_func_array.
mixed$value The value returned is the value the stored function returns
_applyFilter(string $class, string $method, mixed $data, array $options = array()) : mixed
| access |
protected |
|---|
stringThe name of the class the filter is in
stringThe method the filter is in
mixedThe data that is being passed to the filter
arrayoptions to be passed to the filter. Passed options we be passed to the function. -'default_return' mixed: If no filter is return, the data passed in by default will be return. Can be overriden -'event' string: An event to associate with the filter. Default is null
mixed$data The data the function returns
_callAdapter(string $class, string $method) : mixed
| access |
protected |
|---|
stringThe name of the class the adapter is in
stringTHe name of the method the class is being called from.
mixed$value A value that the adapter returns
_hasAdapter( $class, string $method) : \boolea
| access |
protected |
|---|
stringThe associated method
\boolea$hasAdapter Returns true if it has an adapter or false if it doesn not
_hasFilter(string $class, string $method)
stringThe class the filter is in
stringThe method of the class that the filter is in
_invokeMethod(string $class, string $method, array $args) : mixed
| access |
protected |
|---|
stringThe name of the class to be called
stringThe name of the method in the class to be called
arrayAn array of arguements. Arguements have to be embedded in an array to be called.
mixed$data Data returned by the function called
_invokeStaticMethod(string $class, string $method, array $args) : mixed
| access |
protected |
|---|
stringThe name of the class to be called
stringThe name of the method in the class to be called
arrayAn array of arguements. Arguements have to be embedded in an array to be called.
mixed$data Data returned by the function called
_logAdapter(array $data) : void
| access |
private |
|---|
arrayThe data in the adapter
_logFilter(array $data) : void
| access |
private |
|---|
arrayThe data in the filter
_logObserver(array $data) : void
| access |
private |
|---|
arrayThe data in the observer
_notify(string $event) : void
| access |
protected |
|---|
stringThe name of the even that occured that will trigger notifies
_prepareLogData(array $data) : string
| access |
private |
|---|
array
string$message JSON encode message of information about the data
addAdapter(string $trigger_class, string $trigger_method, string $call_class, array $options = array()) : void
| access |
public |
|---|---|
| todo |
add ability to adapt singleton class |
stringThe class that contains the function the adapter will respond too
stringThe method called that will have the adapter to be called.
stringThe new class to be called that has the same method name
arrayAn array of options that be called -'object' string : Assumes that default method in the class to be called is static. If called object needs to be instantiated, change to object to 'instance' and one will be created before the adapter calls the function -'call_method' string: By default the method to be called to override the current one should be the same name. But this can be ovveridden to call a different method. -'type' string: The type of method being called. Default is class_method but if the method is a closure, set the type to be 'closure' and make the $trigger_method the closure
addClassAdapter(mixed $trigger_class, string $call_class, array $options = array()) : void
| access |
public |
|---|---|
| todo |
Add ability to use singleton classes |
mixedThis can either be the name of the class or an object whose methods will be adapted to another class. The class should be included or be autoloaded by this point.
stringThe call class is the classes methods that will be called in place of the methods in the trigger_class. These class does not have to be included as this point.
arrayOptions that be used to further distinguish the behavior of the adapters added -'object' string: Determines if the object being adapted to is static or an instance.Default is static -'call_class' string: The name of the class that the methods will be adapted too. -'class' string: The name of the whose methods will be adapted to another class
addFilter(string $class, string $method, string $filter_class, string $filter_method, array $options = array()) : void
| access |
public |
|---|
stringThe name of the class the filter is going in
stringThe name of the method the filter is in
stringThe class that the filter resides in.
stringThe method in the class that the parameters will be passed too.
arrayOptions that can be set for further modifying the filter. -'object' string: If the method being called is static, static should be inserted. If its in an instance, 'instance' should be set. Default is set to static. -'event' string: Associate this filter with an event. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $filter_method the closure
addMethod(string $method, \function $closure) : void
| access |
public |
|---|
stringThe key/value that will be used to call the function
\functionThe anonymous function/closure to be added
addObserver(string $event, string $class, string $method, array $options = array()) : void
| access |
public |
|---|
stringThe name of the event that will cause a certain class and method to fire
stringThe name of the class that contains the function that will be fired for this event
stringThe name of the method that will be fired when the event occurs
arrayOptions to further the define the firing of an event -'object' string : If the method being called is static, should be set to static. Else set to instance -'class' stinrg : The name of the class to be called. Default is the class that is passed in. -'method' string: The name of the method to be called. Default is the method that is passed in. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $method the closure
addToCollection(mixed $data) : void
| access |
public |
|---|
mixedAny data type( Object, Array, int, etc) to add to the public data collection
addToCollectionWithName(string $name, mixed $data) : void
| access |
public |
|---|---|
| todo |
check the relevance of get and set |
stringThe key/index to assign the value to
mixedData to be stored in the collection
clearFilters(string $class, string $method) : void
| access |
public |
|---|
stringThe class the filter is in
stringThe method of the class that the filter is in
clearObservers(string $event) : void
| access |
public |
|---|
stringThe event to remove all the observers from
copyDirectory(string $oldDirectory, string $newDirectory) : void
| access |
public |
|---|
stringThe location of the old directory
stringThe location of the new directory
copyFile(string $currentFile, string $newFile) : boolean
| access |
public |
|---|
stringThe location of the current file to be copied
stringThe location of the new file to be copied
boolean$copied Returns true if the file was succesfully copied
copyFileFromUrl(string $url, string $destination, string $filename = '') : boolean
stringThe url in which the file to copy exist
stringThe location the server to copy the file to
stringAn optional name to assign the file
boolean$success Returns true if the file was succesfully copied
copyNewDirectory(string $oldDirectory, string $newDirectory) : void
| access |
public |
|---|
stringThe location of the old directory
stringThe location of the new directory
copyNewFile(string $currentFile, string $newFile) : boolean
| access |
public |
|---|
stringThe location of the current file to be copied
stringThe location of the new file to be copied
boolean$copied Returns true if the file was succesfully copied
deleteDirectory(mixed $directory) : boolean
| access |
public |
|---|
mixedCan either be an array of directories or a single directory.
boolean$deleted
deleteFile(string $file) : boolean
| access |
public |
|---|
stringThe location of the file to be deleted
boolean$deleted Returns true if the file was successfully deleted. Otherwise false.
get(string $index) : mixed
| access |
public |
|---|
stringThe index to retrieve a value from
mixed$data The data that was stored at that index
getFileMimeType(string $file, array $options = array()) : string
| access |
public |
|---|
stringThe name and location of the file
arrayOptions that can alter how the mime type is found -'magic_file' string: If finfo_open is installed, the magic file can be set for retreiving the mime type. Default is null
string$mime_type The mime type of the file.
getFilesInDirectory(string $directory, array $options = array()) : array
| access |
public |
|---|
stringThe directory to be scanned
arrayOptions that can alter how the directory is scanned -'verbose' boolean: Enabling this mode will return everything in array of arrays. The array will contain more detailed information such as mime_type, extension, base name, etc. Default is false. -'magic_file' string: If finfo is installed and verbose is set to true, use this option to specifiy the magic file to use when getting the mime type of the file. Default is null
array$files An array of subdirectories and fules
getFileSize_NTFS(string $file) : boolean
| access |
public |
|---|
stringThe location of the file to get the size of
boolean$size Returns the size of the file
getFileSize_PERL(string $file) : boolean
| access |
public |
|---|
stringThe location of the file to get the size of
boolean$size Returns the size of the file
getInstance() : object
| access |
public |
|---|---|
object$instance Returns the instance of a class.
getIterator() : \PVIterator
getLastestFileInDirectory(string $directory) : string
| access |
public |
|---|
stringThe directory to search through when looking for the file
string$file The file that was modified in that directory
phpFileUpload( $params)
| params |
File information to upload |
|---|---|
| todo |
figure out a point for this function. So do not use in the mean time. |
readFile(string $file, string $mode = 'r', string $encoding = '', boolean $stream = true) : string
| access |
public |
|---|
stringThe location of the file
stringThe mode to be used reading the file
stringThe encoding to convert the file to. Optional.
booleanThe option to stream a file byte by byte
string$contents The contents read from the file
removeAdapter( $class, string $method) : void
| access |
public |
|---|
stringThe associated method
removeClassAdapter( $class) : void
| access |
public |
|---|
rewriteNewFile(string $file, string $content, string $mode = 'w', string $encoding = '') : boolean
| access |
public |
|---|
stringThe path to the file that will be writteen out too
stringThe content to be written to the file
stringThe mode to be used when writing the file. Default is 'w'.
stringAn encoding to be used when writing the file. Optional.
boolean$written Returns true if the file was written, otherwise false
set(string $index, mixed $value) : void
| access |
public |
|---|
stringThe key or index to store the value at
mixedA mixed value that can be anytype
setAdapterTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace adatper.
setFilterTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace filter.
setObserverTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace observer.
writeFile(string $file, string $content, string $mode = 'w', string $encoding = '') : boolean
| access |
public |
|---|
stringThe path to the file that will be writteen out too
stringThe content to be written to the file
stringThe mode to be used when writing the file. Default is 'w'.
stringAn encoding to be used when writing the file. Optional.
boolean$written Returns true if the file was written, otherwise false
writeNewFile(string $file, string $content, string $mode = 'w', string $encoding = '') : boolean
| access |
public |
|---|---|
| todo |
Defaults for mode, content and encoding, Add a way for encoding file. |
stringThe path to the file that will be writteen out too
stringThe content to be written to the file
stringThe mode to be used when writing the file. Default is 'w'.
stringAn encoding to be used when writing the file. Optional.
boolean$written Returns true if the file was written, otherwise false
_collection :
_methods :
_adapters :
_observers :
_instances :
_filters :
_traceAdapters :
_traceFilters :
_traceObservers :