Request.php

Show: inherited
Table of Contents
RouterOS API client implementation.

RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts.

PHP version 5

Author
Vasil Rangelov  
Category
Net  
Copyright
2011 Vasil Rangelov  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  
Package
PEAR2_Net_RouterOS  
Version
1.0.0b3  

\PEAR2\Net\RouterOS\Request

Package: PEAR2\Net\RouterOS
Represents a RouterOS request.
Parent(s)
\PEAR2\Net\RouterOS\Message
Author
Vasil Rangelov  
Category
Net  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  

Properties

Propertyprivatestring $_command

The command to be executed.

Details
Type
string
Propertyprivate\PEAR2\Net\RouterOS\Query $_query

A query for the command.

Propertyprivatestring $_tag = null
inherited

An optional tag to associate the message with.

Inherited from: \PEAR2\Net\RouterOS\Message::$$_tag
Default valuenullDetails
Type
string
Inherited_from
\PEAR2\Net\RouterOS\Message::$$_tag  
Propertyprotectedarray $arguments = array()
inherited

An array with message arguments. Keys are the names of the arguments, array values are values for the corresponding argument.

Inherited from: \PEAR2\Net\RouterOS\Message::$$arguments
Default valuearray()Details
Type
array
Inherited_from
\PEAR2\Net\RouterOS\Message::$$arguments  

Methods

methodpublic__construct(string $command, \PEAR2\Net\RouterOS\Query $query = null, string $tag = null) : void

Creates a request to send to RouterOS.

Parameters
Name Type Description
$command string

The command to send. Can also contain arguments expressed in a shell-like syntax.

$query \PEAR2\Net\RouterOS\Query

A query to associate with the request.

$tag string

The tag for the request.

Details
See
\PEAR2\Net\RouterOS\setCommand()  
See
\PEAR2\Net\RouterOS\setArgument()  
See
\PEAR2\Net\RouterOS\setTag()  
See
\PEAR2\Net\RouterOS\setQuery()  
methodpublic__invoke(mixed $arg = null) : mixed

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
Name Type Description
$arg mixed

A {@link Query} to associate the request with, a {@link Communicator} to send the request over, an argument to get the value of, or NULL to get all arguments as an array. 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
Type Description
mixed Whatever the long form function would have returned.
methodprivate_send(\PEAR2\Net\RouterOS\Communicator $com) : int

Sends a request over a communicator.

The only difference with the non private equivalent is that this one does not do locking.

Parameters
Name Type Description
$com \PEAR2\Net\RouterOS\Communicator

The communicator to send the request over.

Returns
Type Description
int The number of bytes sent.
Details
See
\PEAR2\Net\RouterOS\Client::sendSync()  
See
\PEAR2\Net\RouterOS\Client::sendAsync()  
methodpublicgetAllArguments() : array
inherited

Gets all arguments in an array.

Inherited from: \PEAR2\Net\RouterOS\Message::getAllArguments()
Returns
Type Description
array An array with the keys as argument names, and the array values as argument values.
Details
See
\PEAR2\Net\RouterOS\getArgument()  
See
\PEAR2\Net\RouterOS\setArgument()  
methodpublicgetArgument(string $name) : string | resource
inherited

Gets the value of an argument.

Inherited from: \PEAR2\Net\RouterOS\Message::getArgument()
Parameters
Name Type Description
$name string

The name of the argument.

Returns
Type Description
string | resource The value of the specified argument. Returns NULL if such an argument is not set.
Details
See
\PEAR2\Net\RouterOS\setArgument()  
methodpublicgetCommand() : string

Gets the command that will be send to RouterOS.

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

Returns
Type Description
string The command to send.
Details
See
\PEAR2\Net\RouterOS\setCommand()  
methodpublicgetQuery() : \PEAR2\Net\RouterOS\Query

Gets the currently associated query

Returns
Type Description
\PEAR2\Net\RouterOS\Query The currently associated query.
Details
See
\PEAR2\Net\RouterOS\setQuery()  
methodpublicgetTag() : string
inherited

Gets the tag that the message is associated with.

Inherited from: \PEAR2\Net\RouterOS\Message::getTag()
Returns
Type Description
string The current tag or NULL if there isn't a tag.
Details
See
\PEAR2\Net\RouterOS\setTag()  
methodprotectedparseArgumentString(string $string) : void

Parses the arguments of a command.

Parameters
Name Type Description
$string string

The argument string to parse.

methodpublicremoveAllArguments() : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request

Removes all arguments from the request.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request The request object.
methodpublicsanitizeArgumentName(mixed $name) : string
staticinherited

Sanitizes a name of an argument (message or query one).

Inherited from: \PEAR2\Net\RouterOS\Message::sanitizeArgumentName()
Parameters
Name Type Description
$name mixed

The name to sanitize.

Returns
Type Description
string The sanitized name.
methodpublicsanitizeArgumentValue(mixed $value) : string
staticinherited

Sanitizes a value of an argument (message or query one).

Inherited from: \PEAR2\Net\RouterOS\Message::sanitizeArgumentValue()
Parameters
Name Type Description
$value mixed

The value to sanitize.

Returns
Type Description
string The sanitized value.
methodpublicsend(\PEAR2\Net\RouterOS\Communicator $com, \PEAR2\Net\RouterOS\Registry $reg = null) : int

Sends a request over a communicator.

Parameters
Name Type Description
$com \PEAR2\Net\RouterOS\Communicator

The communicator to send the request over.

$reg \PEAR2\Net\RouterOS\Registry

An optional registry to sync the request with.

Returns
Type Description
int The number of bytes sent.
Details
See
\PEAR2\Net\RouterOS\Client::sendSync()  
See
\PEAR2\Net\RouterOS\Client::sendAsync()  
methodpublicsetArgument(string $name, string $value = '') : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request

Sets an argument for the request.

Parameters
Name Type Description
$name string

Name of the argument.

$value string

Value of the argument. Setting the value to NULL removes an argument of this name.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request The request object.
Details
See
\PEAR2\Net\RouterOS\getArgument()  
methodpublicsetCommand(string $command) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request

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
Name Type Description
$command string

The command to send.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request The request object.
Details
See
\PEAR2\Net\RouterOS\getCommand()  
See
\PEAR2\Net\RouterOS\setArgument()  
methodpublicsetQuery(\PEAR2\Net\RouterOS\Query $query = null) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request

Sets the query to send with the command.

Parameters
Name Type Description
$query \PEAR2\Net\RouterOS\Query

The query to be set. Setting NULL will remove the currently associated query.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request The request object.
Details
See
\PEAR2\Net\RouterOS\getQuery()  
methodpublicsetTag(string $tag) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request

Sets the tag to associate the request with.

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

Parameters
Name Type Description
$tag string

The tag to set.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Request The request object.
Details
See
\PEAR2\Net\RouterOS\getTag()  
Documentation was generated by phpDocumentor 2.0.0a8.