本文整理汇总了PHP中Parameter::setFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::setFormat方法的具体用法?PHP Parameter::setFormat怎么用?PHP Parameter::setFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameter
的用法示例。
在下文中一共展示了Parameter::setFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadForSource
public function loadForSource($url)
{
$datasrc = dirname(dirname(__FILE__)) . '/Resources/data/databases/DataSources.xml';
if (extension_loaded('apc') && ini_get('apc.enabled')) {
$xml = $this->loadFileFromCache($url);
$simulator = new \SimpleXMLElement($xml, LIBXML_NOWARNING, false);
$xml = $this->loadFileFromCache($datasrc);
$datasources = new \SimpleXMLElement($xml, LIBXML_NOWARNING, false);
} else {
$simulator = new \SimpleXMLElement($url, LIBXML_NOWARNING, true);
$datasources = new \SimpleXMLElement($datasrc, LIBXML_NOWARNING, true);
}
foreach ($datasources->DataSource as $datasource) {
$datasourceObj = new DataSource($this, (int) $datasource['id'], (string) $datasource['name'], (string) $datasource['type']);
$datasourceObj->setUri((string) $datasource['uri']);
$datasourceObj->setMethod((string) $datasource['method']);
$datasourceObj->setDatabase((int) $datasource['database']);
$datasourceObj->setDescription((string) $datasource->Description);
$this->datasources[] = $datasourceObj;
}
if ($datasources->Databases) {
foreach ($datasources->Databases->Database as $database) {
$databaseObj = new Database($this, (int) $database['id'], (string) $database['type'], (string) $database['name']);
$databaseObj->setLabel((string) $database['label']);
$databaseObj->setHost((string) $database['host']);
$databaseObj->setPort((int) $database['port']);
$databaseObj->setUser((string) $database['user']);
if ((string) $database['password'] != '') {
$databaseObj->setPassword((string) $database['password']);
} elseif ((string) $database['user'] != '') {
try {
$user = $this->controller->get('kernel')->getContainer()->getParameter('database_user');
if ((string) $database['user'] == $user) {
$databaseObj->setPassword($this->controller->get('kernel')->getContainer()->getParameter('database_password'));
}
} catch (\Exception $e) {
}
}
$this->databases[] = $databaseObj;
}
}
if ($simulator->DataSet) {
foreach ($simulator->DataSet->children() as $child) {
if ($child->getName() == "DataGroup") {
foreach ($child->Data as $data) {
$dataObj = new Data($this, (int) $data['id'], (string) $data['name']);
$dataObj->setLabel((string) $data['label']);
$dataObj->setType((string) $data['type']);
$this->datas[] = $dataObj;
}
} elseif ($child->getName() == "Data") {
$dataObj = new Data($this, (int) $child['id'], (string) $child['name']);
$dataObj->setLabel((string) $child['label']);
$dataObj->setType((string) $child['type']);
$this->datas[] = $dataObj;
}
}
}
if ($simulator->Sources) {
foreach ($simulator->Sources->Source as $source) {
$sourceObj = new Source($this, (int) $source['id'], (string) $source['datasource'], (string) $source['returnType']);
$sourceObj->setRequest((string) $source['request']);
$sourceObj->setSeparator((string) $source['separator']);
$sourceObj->setDelimiter((string) $source['delimiter']);
$sourceObj->setReturnPath((string) $source['returnPath']);
foreach ($source->Parameter as $parameter) {
$parameterObj = new Parameter($sourceObj, (string) $parameter['type']);
$parameterObj->setName((string) $parameter['name']);
$parameterObj->setFormat((string) $parameter['format']);
$parameterObj->setData((int) $parameter['data']);
$sourceObj->addParameter($parameterObj);
}
$this->sources[] = $sourceObj;
}
}
}