PEAR2_Net_RouterOS  1.0.0b5
A MikroTik RouterOS client
 All Data Structures Namespaces Files Functions Variables Pages
Request Class Reference
+ Inheritance diagram for Request:
+ Collaboration diagram for Request:

Public Member Functions

 __construct ($command, Query $query=null, $tag=null)
 Creates a request to send to RouterOS. More...
 
 __invoke ($arg=null)
 A shorthand gateway. More...
 
 setCommand ($command)
 Sets the command to send to RouterOS. More...
 
 getCommand ()
 Gets the command that will be send to RouterOS. More...
 
 setQuery (Query $query=null)
 Sets the query to send with the command. More...
 
 getQuery ()
 Gets the currently associated query. More...
 
 setTag ($tag)
 Sets the tag to associate the request with. More...
 
 setArgument ($name, $value= '')
 Sets an argument for the request. More...
 
 getArgument ($name)
 Gets the value of an argument. More...
 
 removeAllArguments ()
 Removes all arguments from the request. More...
 
 send (Communicator $com, Registry $reg=null)
 Sends a request over a communicator. More...
 
- Public Member Functions inherited from Message
 __invoke ($name=null)
 A shorthand gateway. More...
 
 getTag ()
 Gets the tag that the message is associated with. More...
 
 getIterator ()
 Gets all arguments in an array. More...
 
 count ($mode=COUNT_NORMAL)
 Counts the number of arguments. More...
 

Protected Member Functions

 parseArgumentString ($string)
 Parses the arguments of a command. More...
 
- Protected Member Functions inherited from Message
 setTag ($tag)
 Sets the tag to associate the request with. More...
 
 getAttribute ($name)
 Gets the value of an attribute. More...
 
 setAttribute ($name, $value= '')
 Sets an attribute for the message. More...
 
 removeAllAttributes ()
 Removes all attributes from the message. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Message
static sanitizeAttributeName ($name)
 Sanitizes a name of an attribute (message or query one). More...
 
static sanitizeAttributeValue ($value)
 Sanitizes a value of an attribute (message or query one). More...
 
- Protected Attributes inherited from Message
 $attributes = array()
 

Detailed Description

Definition at line 37 of file Request.php.

Constructor & Destructor Documentation

__construct (   $command,
Query  $query = null,
  $tag = null 
)

Creates a request to send to RouterOS.

Parameters
string$commandThe command to send. Can also contain arguments expressed in a shell-like syntax.
Query$queryA query to associate with the request.
string$tagThe tag for the request.
See also
setCommand()
setArgument()
setTag()
setQuery()

Definition at line 63 of file Request.php.

Member Function Documentation

__invoke (   $arg = null)

A shorthand gateway.

This is a magic PHP method that allows you to call the object as a function. Depending on the argument given, one of the other functions in the class is invoked and its returned value is returned by this function.

Parameters
Query | Communicator | string | null$argA Query to associate the request with, a Communicator to send the request over, an argument to get the value of, or NULL to get the tag. If a second argument is provided, this becomes the name of the argument to set the value of, and the second argument is the value to set.
Returns
string|resource|int|$this Whatever the long form function returns.

Definition at line 95 of file Request.php.

getArgument (   $name)

Gets the value of an argument.

Parameters
string$nameThe name of the argument.
Returns
string|resource|null The value of the specified argument. Returns NULL if such an argument is not set.
See also
setAttribute()

Definition at line 247 of file Request.php.

getCommand ( )

Gets the command that will be send to RouterOS.

Gets the command that will be send to RouterOS in its API syntax.

Returns
string The command to send.
See also
setCommand()

Definition at line 170 of file Request.php.

getQuery ( )

Gets the currently associated query.

Returns
Query The currently associated query.
See also
setQuery()

Definition at line 196 of file Request.php.

parseArgumentString (   $string)
protected

Parses the arguments of a command.

Parameters
string$stringThe argument string to parse.
Returns
void

Definition at line 340 of file Request.php.

removeAllArguments ( )

Removes all arguments from the request.

Returns
$this The request object.

Definition at line 257 of file Request.php.

send ( Communicator  $com,
Registry  $reg = null 
)

Sends a request over a communicator.

Parameters
Communicator$comThe communicator to send the request over.
Registry$regAn optional registry to sync the request with.
Returns
int The number of bytes sent.
See also
Client::sendSync()
Client::sendAsync()

Definition at line 272 of file Request.php.

setArgument (   $name,
  $value = '' 
)

Sets an argument for the request.

Parameters
string$nameName of the argument.
string | resource | null$valueValue of the argument as a string or seekable stream. Setting the value to NULL removes an argument of this name. If a seekable stream is provided, it is sent from its current posistion to its end, and the pointer is seeked back to its current position after sending. Non seekable streams, as well as all other types, are casted to a string.
Returns
$this The request object.
See also
getArgument()

Definition at line 233 of file Request.php.

setCommand (   $command)

Sets the command to send to RouterOS.

Sets the command to send to RouterOS. The command can use the API or CLI syntax of RouterOS, but either way, it must be absolute (begin with a "/") and without arguments.

Parameters
string$commandThe command to send.
Returns
$this The request object.
See also
getCommand()
setArgument()

Definition at line 122 of file Request.php.

setQuery ( Query  $query = null)

Sets the query to send with the command.

Parameters
Query$queryThe query to be set. Setting NULL will remove the currently associated query.
Returns
$this The request object.
See also
getQuery()

Definition at line 184 of file Request.php.

setTag (   $tag)

Sets the tag to associate the request with.

Sets the tag to associate the request with. Setting NULL erases the currently set tag.

Parameters
string$tagThe tag to set.
Returns
$this The request object.
See also
getTag()

Definition at line 212 of file Request.php.


The documentation for this class was generated from the following file: