PHP Class Jyxo\Webdav\Client

Author: Jaroslav Hanslík
Afficher le fichier Open project: jyxo/php Class Usage Examples

Protected Properties

Свойство Type Description
$createDirectoriesAutomatically boolean If disabled, commands will throw an error if target directory doesn't exist.
$logger Jyxo\Webdav\LoggerInterface Logger.
$parallelSending boolean If parallel request sending is enabled.
$requestOptions array Request options.
$servers array Servers list.

Méthodes publiques

Méthode Description
__construct ( array $servers ) Constructor.
copy ( string $pathFrom, string $pathTo ) Copies a file.
exists ( string $path ) : boolean Checks if a file exists.
get ( string $path ) : string Returns file contents.
getProperty ( string $path, string $property = null ) : mixed Returns a file property.
isDir ( string $dir ) : boolean Checks if a directory exists.
mkdir ( string $dir, boolean $recursive = true ) Creates a directory.
put ( string $path, string $data ) Saves data to a remote file.
putFile ( string $path, string $file ) Saves file contents to a remote file.
rename ( string $pathFrom, string $pathTo ) Renames a file.
rmdir ( string $dir ) Deletes a directory.
setCreateDirectoriesAutomatically ( boolean $createDirectoriesAutomatically ) : self Enables/disables automatic creation of target directories.
setLogger ( Jyxo\Webdav\LoggerInterface $logger ) : self Sets a logger.
setParallelSending ( boolean $parallelSending ) : self Enables/disables parallel request sending.
setRequestOption ( string $name, mixed $value ) : self Sets a request option.
unlink ( string $path ) Deletes a file.

Méthodes protégées

Méthode Description
createAllRequests ( string $path, string $method, array $headers = [], string | resource | null $body = null ) : array Creates a list of requests; one for each server.
createClient ( ) : Client
createRequest ( string $server, string $path, string $method, array $headers = [], string | resource | null $body = null ) : GuzzleHttp\Psr7\Request Creates a request.
getDirPath ( string $path ) : string Creates a directory path with the trailing slash.
getFilePath ( string $path ) : string Creates a file path without the trailing slash.
getProperties ( Response $response ) : array Fetches properties from the response.
getRandomServer ( ) : string
processPut ( string $path, string $data, boolean $isFile ) Processes a PUT request.
sendAllRequests ( array $requests ) : array Sends requests to all servers.
sendRequest ( string $path, string $method, array $headers = [] ) : Response Sends a request.

Method Details

__construct() public méthode

Constructor.
public __construct ( array $servers )
$servers array

copy() public méthode

Does not work on Lighttpd.
public copy ( string $pathFrom, string $pathTo )
$pathFrom string Source file path
$pathTo string Target file path

createAllRequests() protected méthode

Creates a list of requests; one for each server.
protected createAllRequests ( string $path, string $method, array $headers = [], string | resource | null $body = null ) : array
$path string Request path
$method string Request method
$headers array Array of headers
$body string | resource | null Request body
Résultat array

createClient() protected méthode

protected createClient ( ) : Client
Résultat GuzzleHttp\Client

createRequest() protected méthode

Creates a request.
protected createRequest ( string $server, string $path, string $method, array $headers = [], string | resource | null $body = null ) : GuzzleHttp\Psr7\Request
$server string Server
$path string Path
$method string Request method
$headers array Array of headers
$body string | resource | null Request body
Résultat GuzzleHttp\Psr7\Request

exists() public méthode

Checks if a file exists.
public exists ( string $path ) : boolean
$path string File path
Résultat boolean

get() public méthode

Returns file contents.
public get ( string $path ) : string
$path string File path
Résultat string

getDirPath() protected méthode

Creates a directory path with the trailing slash.
protected getDirPath ( string $path ) : string
$path string Directory path
Résultat string

getFilePath() protected méthode

Creates a file path without the trailing slash.
protected getFilePath ( string $path ) : string
$path string File path
Résultat string

getProperties() protected méthode

Fetches properties from the response.
protected getProperties ( Response $response ) : array
$response GuzzleHttp\Psr7\Response Response
Résultat array

getProperty() public méthode

If no particular property is set, all properties are returned.
public getProperty ( string $path, string $property = null ) : mixed
$path string File path
$property string Property name
Résultat mixed

getRandomServer() protected méthode

protected getRandomServer ( ) : string
Résultat string

isDir() public méthode

Checks if a directory exists.
public isDir ( string $dir ) : boolean
$dir string Directory path
Résultat boolean

mkdir() public méthode

Creates a directory.
public mkdir ( string $dir, boolean $recursive = true )
$dir string Directory path
$recursive boolean Create directories recursively?

processPut() protected méthode

Processes a PUT request.
protected processPut ( string $path, string $data, boolean $isFile )
$path string File path
$data string Data
$isFile boolean Determines if $data is a file name or actual data

put() public méthode

Saves data to a remote file.
public put ( string $path, string $data )
$path string File path
$data string Data

putFile() public méthode

Saves file contents to a remote file.
public putFile ( string $path, string $file )
$path string File path
$file string Local file path

rename() public méthode

Does not work on Lighttpd.
public rename ( string $pathFrom, string $pathTo )
$pathFrom string Original file name
$pathTo string New file name

rmdir() public méthode

Deletes a directory.
public rmdir ( string $dir )
$dir string Directory path

sendAllRequests() protected méthode

Sends requests to all servers.
protected sendAllRequests ( array $requests ) : array
$requests array Request list
Résultat array

sendRequest() protected méthode

Sends a request.
protected sendRequest ( string $path, string $method, array $headers = [] ) : Response
$path string Request path
$method string Request method
$headers array Array of headers
Résultat GuzzleHttp\Psr7\Response

setCreateDirectoriesAutomatically() public méthode

Enables/disables automatic creation of target directories.
public setCreateDirectoriesAutomatically ( boolean $createDirectoriesAutomatically ) : self
$createDirectoriesAutomatically boolean
Résultat self

setLogger() public méthode

Sets a logger.
public setLogger ( Jyxo\Webdav\LoggerInterface $logger ) : self
$logger Jyxo\Webdav\LoggerInterface Logger
Résultat self

setParallelSending() public méthode

Enables/disables parallel request sending.
public setParallelSending ( boolean $parallelSending ) : self
$parallelSending boolean
Résultat self

setRequestOption() public méthode

Sets a request option.
See also: GuzzleHttp\RequestOptions
public setRequestOption ( string $name, mixed $value ) : self
$name string Option name
$value mixed Option value
Résultat self

Property Details

$createDirectoriesAutomatically protected_oe property

If disabled, commands will throw an error if target directory doesn't exist.
protected bool $createDirectoriesAutomatically
Résultat boolean

$logger protected_oe property

Logger.
protected LoggerInterface,Jyxo\Webdav $logger
Résultat Jyxo\Webdav\LoggerInterface

$parallelSending protected_oe property

If parallel request sending is enabled.
protected bool $parallelSending
Résultat boolean

$requestOptions protected_oe property

Request options.
protected array $requestOptions
Résultat array

$servers protected_oe property

Servers list.
protected array $servers
Résultat array