abstract class Plex_Client_ControllerAbstract extends Plex_Client

Represents a Plex client on the network.

Constants

DEFAULT_PORT

The default port on which a Plex client listens.

TYPE_NAVIGATION

String representing the navigation controller type.

TYPE_PLAYBACK

String representing the playback controller type.

TYPE_APPLICATION

String representing the application controller type.

Properties

protected string $name The name of the Plex machine on the network. from Plex_MachineAbstract
protected string $address The IP address of the Plex machine on the network. from Plex_MachineAbstract
protected integer $port The port on which the Plex machine is listening. Typically 32400 for servers and 3000 for clients. from Plex_MachineAbstract
protected string $token The token of the Plex machine on the network. from Plex_MachineAbstract

Methods

string
getBaseUrl()

Returns the base URL, which will be standard for all requests made to the Plex machine.

array
xmlAttributesToArray(SimpleXMLElement $xml, integer $pass = 0)

Typically the useful data returned by a Plex machine will containted in XML attributes. This allows a set of XML nodes to be passed and all the attribues extracted and returned as an associated array.

array
makeCall(string $url)

Utilizes php-curl to send a request to the passed URL and returns an XML document reprentation of the returned content.

string
getCallingFunction(integer $depth = 2)

Universal function so any method belonging to a child class of a Plex machine can discover which function called it. This is used mainly for some of our polymorphic requests as the calling function can tell us what type of item is being requested.

void
__construct(string $name, string $address, integer $port, string $token)

Sets up our Plex client using the minimum amount of data required to interact.

getNavigationController()

Returns the navigation controller.

getPlaybackController()

Returns the playback controller.

getApplicationController()

Returns the application controller.

string
getName()

Returns the Plex client's name.

string
getAddress()

Returns the Plex client's IP address.

integer
getPort()

Returns the port on which the Plex client listens.

string
getToken()

Returns the token on which the Plex machine listens.

string
getHost()

Returns the hostname of the Plex client.

void
setHost(string $host)

Sets the hostname of the Plex client.

string
getMachineIdentifier()

Returns the mac address of the Plex client.

void
setMachineIdentifier(string $machineIdentifier)

Sets the mac address of the Plex client.

string
getVersion()

Returns the version of the Plex software the Plex client is running.

void
setVersion(string $version)

Sets the version of the Plex software the Plex client is running.

getServer()

Returns the server that registered the client.

void
setServer(Plex_Server $server)

Sets the server that registered the client.

void
executeCommand(array $params = array())

Using the calling class and function builds and calls the URL for the Plex client controller command.

factory(string $type, string $name, string $address, integer $port, string $token, Plex_Server $server)

Static factory method for instantiating and returning a child controller class.

Details

in Plex_MachineAbstract at line 78
protected string getBaseUrl()

Returns the base URL, which will be standard for all requests made to the Plex machine.

Return Value

string The base URL, which will be standard for all requests made to the Plex machine.

in Plex_MachineAbstract at line 102
protected array xmlAttributesToArray(SimpleXMLElement $xml, integer $pass = 0)

Typically the useful data returned by a Plex machine will containted in XML attributes. This allows a set of XML nodes to be passed and all the attribues extracted and returned as an associated array.

Parameters

SimpleXMLElement $xml An XML node to have its attributes converted to a useful PHP array.
integer $pass The number of recursive levels down the method has run. This is mainly used for determining if we are on our first pass or not because the data is picked up slightly differently on the first pass.

Return Value

array An associated array of XML attributes.

in Plex_MachineAbstract at line 149
protected array makeCall(string $url)

Utilizes php-curl to send a request to the passed URL and returns an XML document reprentation of the returned content.

Parameters

string $url The URL to which the request is to be made.

Return Value

array An XML document from a Plex machine converted in array.

Exceptions

Plex_Exception_Machine

in Plex_MachineAbstract at line 196
protected string getCallingFunction(integer $depth = 2)

Universal function so any method belonging to a child class of a Plex machine can discover which function called it. This is used mainly for some of our polymorphic requests as the calling function can tell us what type of item is being requested.

Parameters

integer $depth Depth defaults to 2 because 0 is this function and 1 will be the function that asked for the calling function. This can be changed by the calling function in case a specific calling function needs to be identified. This can be handy if the original calling function goes through a number of hops on its way to identification.

Return Value

string The name of the function that called the function that issued the getCallingFunction request.

in Plex_Client at line 90
void __construct(string $name, string $address, integer $port, string $token)

Sets up our Plex client using the minimum amount of data required to interact.

Parameters

string $name The name of the Plex client.
string $address The IP address of the Plex client.
integer $port The port on which the Plex client is listening.
string $token The token of the Plex client.

Return Value

void

in Plex_Client at line 131
Plex_Client_Controller_Navigation getNavigationController()

Returns the navigation controller.

Return Value

Plex_Client_Controller_Navigation The navigation controller.

in Plex_Client at line 146
Plex_Client_Controller_Playback getPlaybackController()

Returns the playback controller.

Return Value

Plex_Client_Controller_Playback The playback controller.

in Plex_Client at line 161
Plex_Client_Controller_Application getApplicationController()

Returns the application controller.

Return Value

Plex_Client_Controller_Application The application controller.

in Plex_Client at line 175
string getName()

Returns the Plex client's name.

Return Value

string The name of the Plex machine.

in Plex_Client at line 187
string getAddress()

Returns the Plex client's IP address.

Return Value

string The IP address of the Plex machine.

in Plex_Client at line 199
integer getPort()

Returns the port on which the Plex client listens.

Return Value

integer The port on which the Plex machine listens.

in Plex_Client at line 209
string getToken()

Returns the token on which the Plex machine listens.

Return Value

string The token on which the Plex machine listens.

in Plex_Client at line 221
string getHost()

Returns the hostname of the Plex client.

Return Value

string The hostname of the Plex client.

in Plex_Client at line 235
void setHost(string $host)

Sets the hostname of the Plex client.

Parameters

string $host The hostname of the Plex client.

Return Value

void

in Plex_Client at line 247
string getMachineIdentifier()

Returns the mac address of the Plex client.

Return Value

string The mac address of the Plex client.

in Plex_Client at line 261
void setMachineIdentifier(string $machineIdentifier)

Sets the mac address of the Plex client.

Parameters

string $machineIdentifier The mac address of the Plex client.

Return Value

void

in Plex_Client at line 274
string getVersion()

Returns the version of the Plex software the Plex client is running.

Return Value

string The version of the Plex software the Plex client is running.

in Plex_Client at line 289
void setVersion(string $version)

Sets the version of the Plex software the Plex client is running.

Parameters

string $version The version of the Plex software teh Plex client is running.

Return Value

void

in Plex_Client at line 301
protected Plex_Server getServer()

Returns the server that registered the client.

Return Value

Plex_Server The server that registered the client.

in Plex_Client at line 315
void setServer(Plex_Server $server)

Sets the server that registered the client.

Parameters

Plex_Server $server The server that registered the client.

Return Value

void

at line 96
protected void executeCommand(array $params = array())

Using the calling class and function builds and calls the URL for the Plex client controller command.

Parameters

array $params An array of parameters that will be used to build an http query string.

Return Value

void

at line 126
static Plex_Client_ControllerAbstract factory(string $type, string $name, string $address, integer $port, string $token, Plex_Server $server)

Static factory method for instantiating and returning a child controller class.

Parameters

string $type The type of the controller to be returned.
string $name The name of the Plex client.
string $address The IP address of the Plex client.
integer $port The port on which the Plex client is listening.
string $token The token of the Plex client.
Plex_Server $server The server that registered teh client.

Return Value

Plex_Client_ControllerAbstract The requested controller object.