Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.

Creating a Service

Johan Strydom edited this page May 31, 2013 · 5 revisions

For the Service, first create a new folder under /services. The new folder's name should be the service name. Example:

/services/myservice

Within the folder two files need to be created. A Service info file and the actual service itself.

Service info file

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

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

}

}

?>

Table of contents

Introduction

Installation and Configuration

Predefined Constants and Globals

Creating a Layout

Creating a Theme

Creating a Service

Configuring a Service

Clone this wiki locally