本文整理汇总了PHP中Zend_Config_Writer_Xml::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Config_Writer_Xml::setConfig方法的具体用法?PHP Zend_Config_Writer_Xml::setConfig怎么用?PHP Zend_Config_Writer_Xml::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Config_Writer_Xml
的用法示例。
在下文中一共展示了Zend_Config_Writer_Xml::setConfig方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editCatalogAction
public function editCatalogAction()
{
$catalogForm = Model_Static_Loader::loadForm("catalog");
$catalogForm->preview->setDestination(APPLICATION_ROOT . "/public/files/catalogs");
$catalogForm->file->setDestination(APPLICATION_ROOT . "/public/files/catalogs");
$catalogs = new Zend_Config_Xml(APPLICATION_PATH . "/config/catalogs.xml");
$id = $this->getRequest()->getParam('guid');
if ($id && !isset($catalogs->{$id})) {
throw new Zend_Exception("Not found", 404);
} elseif ($id) {
$catalogForm->setDefaults($catalogs->{$id}->toArray());
}
if ($this->getRequest()->isPost() && $catalogForm->isValid($_POST)) {
$data = $catalogForm->getValues();
$data["preview"] = "/files/catalogs/" . $data["preview"];
$data["file"] = "/files/catalogs/" . $data["file"];
$catalogs = $catalogs->toArray();
if ($id) {
$catalogs[$id] = $data;
} else {
$catalogs['cat' . date("ymdhis")] = $data;
}
$xml = new Zend_Config_Writer_Xml();
$xml->setConfig(new Zend_Config($catalogs));
$xml->setFilename(APPLICATION_PATH . "/config/catalogs.xml");
$xml->write();
}
$this->view->form = $catalogForm;
}
示例2: serialize
/**
*
* @param array $array
* @return string
*/
public static function serialize($array)
{
$config = new Zend_Config_Writer_Xml();
ZendT_Xml::encodeXml($array);
$config->setConfig(new Zend_Config($array));
$xml = $config->render();
return $xml;
/*$serializer = new XML_Serializer(array(XML_SERIALIZER_OPTION_ROOT_NAME=>'config'));
$result = $serializer->serialize($array);
if ($result){
$xml = $serializer->getSerializedData();
}
return $xml;*/
}
示例3: testRender
/**
* @group ZF-8234
*/
public function testRender()
{
$config = new Zend_Config(array('test' => 'foo', 'bar' => array(0 => 'baz', 1 => 'foo')));
$writer = new Zend_Config_Writer_Xml();
$configString = $writer->setConfig($config)->render();
$expected = <<<ECS
<?xml version="1.0"?>
<zend-config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
<test>foo</test>
<bar>baz</bar>
<bar>foo</bar>
</zend-config>
ECS;
$this->assertEquals($expected, $configString);
}
示例4: uninstall
/**
* Uninstall plugin
*
* Sets config file parameter "installed" to 0 (if config file exists)
*
* @return string uninstall success|failure message
*/
public static function uninstall()
{
if (file_exists(self::getConfigName())) {
$config = new \Zend_Config_Xml(self::getConfigName(), null, array('allowModifications' => true));
$config->librato->installed = 0;
$configWriter = new \Zend_Config_Writer_Xml();
$configWriter->setConfig($config);
$configWriter->write(self::getConfigName());
}
if (!self::isInstalled()) {
return "Successfully uninstalled.";
} else {
return "Could not be uninstalled";
}
}
示例5: removePluginRoute
public static function removePluginRoute($pluginName)
{
$routesData = self::_initValues();
$pluginConfigPath = $routesData['pluginsDirPath'] . $pluginName . '/config/config.ini';
$routes = $routesData['routes'];
if (!file_exists($pluginConfigPath)) {
return;
}
try {
$configIni = new Zend_Config_Ini($pluginConfigPath);
if (!isset($configIni->route)) {
return;
}
$pluginRoute = self::_formatPluginRoute($configIni->route->toArray(), $pluginName);
if (!empty($routes)) {
if (array_key_exists($pluginRoute['name'], $routes['routes'])) {
unset($routes['routes'][$pluginRoute['name']]);
$writer = new Zend_Config_Writer_Xml();
$writer->setConfig(new Zend_Config($routes));
$writer->write($routesData['routesPath']);
}
}
} catch (Zend_Config_Exception $zce) {
return;
}
}