Morning Guys,
I have built a Component for my needs and i get an error---->
Parse error: syntax error, unexpected T_CLASS, expecting T_VARIABLE in
C:\Program Files\xampp\htdocs\voyage~voyage-source\app\controllers
\components\service_composition_engine.php on line 18
I can't figure out what cause this problem.Maybe it's a bug?If any1
can help me i ' d appreciated so much!
Here is my component's code:
<?php
class ServiceCompositionEngineComponent extends Object {
function startup(&$controller) {
$this->controller =& $controller;
}
function getRespType($responseType,$text,$model,$mappings = array(),
$limit){
if ($responseType == 'XML'){
$obj=new XmlParser;
$obj->modelParse($text,$model,$mappings =
array(),$limit);
} else if($responseType == 'JSON'){
$obj=new JsonParser;
$obj->modelParse($text,$model,$mappings =
array(),$limit);
}
}
abstract class ResponseParser{
abstract public function modelParse($text,$model,$mappings = array(),
$limit) {
}
}
//Using X-Path to implement XML parsing
class XmlParser extends ResponseParser {
var modelFields = array(array());
public function modelParse($text,$model,$mappings = array(),$limit){
$xml = new SimpleXMLElement($text);
switch($model){
case($model == "Location"):
$modelField[0][0] = $xml->xpath(''.$mappings[0].'');
//Saves
total results
if (empty($modelField[0][0])){
//Checks if total results field
is empty
break;
} else{
for ($j = 1; $j <= $limit; $j += 1) { // Loop to
access all
children
for ($i = 0; $i <= sizeof($mappings); $i += 1)
{ // Loop to map
each child
$test = $mappings[$i+1];
$mapper = $xml->xpath(''.$test.'');
if (!empty($mapper)){
$modelField[$j][$i] = $mapper;
}else {
$modelField[$j][$i] =
'not_available';
}
}
}
return($modelField);
}
break;
default:
for ($i = 0; $i < sizeof($mappings); $i += 1) {
$test = $xml->xpath(''.$mappings[$i].'');
if (!empty($test)){
$modelField[0][$i] = $test;
}else {
$modelField[0][$i] =
'not_available';
}
}
return($modelField);
break;
}
}
}
//Using J-Path to implement JSON parsing
class JsonParser extends ResponseParser{
var modelFields = array(array());
public function modelParse($text,$model,$mappings = array(),$limit){
$parser = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
$o = $parser->decode($text);
switch($model){
case($model == "Location"):
$modelField[0][0] = jsonPath($o, "$.'.$mappings[0].'");
if (empty($modelField[0][0])){
break;
} else{
for ($j = 1; $j <= $limit; $j += 1) { // Loop to
access all
children
for ($i = 0; $i <= sizeof($mappings); $i += 1) {
$test = $mappings[$i+1];
$mapper = jsonPath($o, "$.'.$test.'");
if (!empty($mapper)){
$modelField[$j][$i] = $mapper;
}else {
$modelField[$j][$i] =
'not_available';
}
}
}
return($modelField);
}
break;
default:
for ($i = 0; $i < sizeof($mappings); $i += 1) {
$test = jsonPath($o, "$.'.$mappings[$i].'");
if (!empty($test)){
$modelField[0][$i] = $test;
}else {
$modelField[0][$i] =
'not_available';
}
}
return($modelField);
break;
}
}
}
}
?>
--
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=.