<?php if (!function_exists('cast')) { function cast($sourceObject, $destination) { if (is_string($destination)) { $destination = new $destination(); } $sourceReflection = new ReflectionObject($sourceObject); $destinationReflection = new ReflectionObject($destination); $sourceProperties = $sourceReflection->getProperties(); foreach ($sourceProperties as $sourceProperty) { $sourceProperty->setAccessible(true); $name = $sourceProperty->getName(); $value = $sourceProperty->getValue($sourceObject); if ($destinationReflection->hasProperty($name)) { $propDest = $destinationReflection->getProperty($name); $propDest->setAccessible(true); $propDest->setValue($destination, $value); } else { $destination->{$name} = $value; } } return $destination; } } $sql = 'UPDATE cmd SET eqType=:eqType WHERE id=:id'; foreach (cmd::all() as $cmd) { $values = array('id' => $cmd->getId(), 'eqType' => $cmd->getEqLogic()->getEqType_name()); DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW); }
$info_cmd = utils::o2a($cmd); if ($cmd->getType() == 'info') { $info_cmd['value'] = $cmd->execCmd(); $info_cmd['collectDate'] = $cmd->getCollectDate(); } $info_cmds[] = $info_cmd; } $info_eqLogic = utils::o2a($eqLogic); $info_eqLogic['cmds'] = $info_cmds; $return[$id] = $info_eqLogic; } $jsonrpc->makeSuccess($return); } /* * ************************Commande*************************** */ if ($jsonrpc->getMethod() == 'cmd::all') { $jsonrpc->makeSuccess(utils::o2a(cmd::all())); } if ($jsonrpc->getMethod() == 'cmd::byEqLogicId') { $jsonrpc->makeSuccess(utils::o2a(cmd::byEqLogicId($params['eqLogic_id']))); } if ($jsonrpc->getMethod() == 'cmd::byId') { $cmd = cmd::byId($params['id']); if (!is_object($cmd)) { throw new Exception('Cmd introuvable : ' . $params['id'], -32701); } $jsonrpc->makeSuccess(utils::o2a($cmd)); } if ($jsonrpc->getMethod() == 'cmd::execCmd') { if (is_array($params['id'])) { $return = array(); foreach ($params['id'] as $id) {