-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a Service
For the Service, first create a new folder under /services. The new folder's name should be the service name. Within the folder two files need to be created. A Service info file and the actual service itself.
The Service info file have to be named as follows:
service_name.nfo.xml
E.g. If the service name is print then the file name will be print.nfo.xml
The content of the file should be as follows:
<?xml version="1.0" encoding="UTF-8"?>
<service name="print" title="Print">
<author>Author Name</author>
<license>Service License</license>
<description>Service Description</description>
<copyright>Service Copyright</copyright>
<aliases><alias name="alias_name" /></aliases>
<commands><command default="true" name="set" /></commands>
<queries><query default="true" name="get" /></queries>
</service>
The service file should be named as follows:
service_name.inc.php
E.g. If the service name is print then the file name will be print.inc.php
The content of the file should be as follows:
<?php if(!defined('TSAMA'))exit;
class ServicePrint extends TsamaObject{
private $m_node = NULL; \\*Required* All services are executed within a TsamaNode
public function __construct(&$parentNode){ \\*Required* Constructor
parent::__construct();
$this->m_node = $parentNode;
}
public function set(){
\\Command code here
}
public function get($params){ \\Called by default as per nfo file
if(is_object($this->m_node)){ \\Make sure the node exist. Layouts will differ from dev to dev.
$h1 = $this->m_node->AddChild('h1'); //Add a h1 tag
$h1->SetValue('Hello World!'); \\Set value of tag
}
Tsama::Debug('ServicePrint->get(\$params) Called'); \\Log a Debug Message
Tsama::Debug(print_r($params,true)); \\See what is in $params
}
}
?>
Installation and Configuration
Predefined Constants and Globals
Creating a Service