本文整理汇总了PHP中Varien_Simplexml_Element::asXML方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Element::asXML方法的具体用法?PHP Varien_Simplexml_Element::asXML怎么用?PHP Varien_Simplexml_Element::asXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Simplexml_Element
的用法示例。
在下文中一共展示了Varien_Simplexml_Element::asXML方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
public function getData()
{
$xml = new \Varien_Simplexml_Element('<config></config>');
$defaultNode = $xml->addChild('global')->addChild('limesoda')->addChild('environments')->addChild('default');
foreach ($this->_collection as $item) {
/** @var $item \Mage_Core_Model_Config_Data */
$defaultNode->addChild($this->_getNodeName($item), $this->_getNodeValue($item));
}
return $xml->asXML();
}
示例2: savePackage
public function savePackage()
{
if ($this->getData('file_name') != '') {
$fileName = $this->getData('file_name');
$this->unsetData('file_name');
} else {
$fileName = $this->getName();
}
if (!preg_match('/^[a-z0-9]+[a-z0-9\\-\\_\\.]*([\\/\\\\]{1}[a-z0-9]+[a-z0-9\\-\\_\\.]*)*$/i', $fileName)) {
return false;
}
if (!$this->getPackageXml()) {
$this->generatePackageXml();
}
if (!$this->getPackageXml()) {
return false;
}
$pear = Varien_Pear::getInstance();
$dir = Mage::getBaseDir('var') . DS . 'pear';
if (!@file_put_contents($dir . DS . 'package.xml', $this->getPackageXml())) {
return false;
}
$pkgver = $this->getName() . '-' . $this->getReleaseVersion();
$this->unsPackageXml();
$this->unsRoles();
$xml = Mage::helper('core')->assocToXml($this->getData());
$xml = new Varien_Simplexml_Element($xml->asXML());
// prepare dir to save
$parts = explode(DS, $fileName);
array_pop($parts);
$newDir = implode(DS, $parts);
if (!empty($newDir) && !is_dir($dir . DS . $newDir)) {
if (!@mkdir($dir . DS . $newDir, 0777, true)) {
return false;
}
}
if (!@file_put_contents($dir . DS . $fileName . '.xml', $xml->asNiceXml())) {
return false;
}
return true;
}
示例3: savePackage
/**
* Save package file to var/connect.
*
* @return boolean
*/
public function savePackage()
{
if ($this->getData('file_name') != '') {
$fileName = $this->getData('file_name');
$this->unsetData('file_name');
} else {
$fileName = $this->getName();
}
if (!preg_match('/^[a-z0-9]+[a-z0-9\\-\\_\\.]*([\\/\\\\]{1}[a-z0-9]+[a-z0-9\\-\\_\\.]*)*$/i', $fileName)) {
return false;
}
if (!$this->getPackageXml()) {
$this->generatePackageXml();
}
if (!$this->getPackageXml()) {
return false;
}
$path = Mage::helper('connect')->getLocalPackagesPath();
if (!@file_put_contents($path . 'package.xml', $this->getPackageXml())) {
return false;
}
$this->unsPackageXml();
$this->unsTargets();
$xml = Mage::helper('core')->assocToXml($this->getData());
$xml = new Varien_Simplexml_Element($xml->asXML());
// prepare dir to save
$parts = explode(DS, $fileName);
array_pop($parts);
$newDir = implode(DS, $parts);
if (!empty($newDir) && !is_dir($path . $newDir)) {
if (!@mkdir($path . $newDir, 0777, true)) {
return false;
}
}
if (!@file_put_contents($path . $fileName . '.xml', $xml->asNiceXml())) {
return false;
}
return true;
}
示例4: enableModule
/**
* Enable a single module
*
* @param string $module
* @param OutputInterface $output
*
* @return int|void
*/
protected function enableModule($module, OutputInterface $output)
{
$decFile = $this->modulesDir . $module . '.xml';
if (!is_file($decFile)) {
$output->writeln('<error><comment>' . $module . ': </comment>Couldn\'t find declaration file</error>');
} elseif (!is_writable($decFile)) {
$output->writeln('<error><comment>' . $module . ': </comment>Can\'t write to declaration file</error>');
} else {
$xml = new \Varien_Simplexml_Element(file_get_contents($decFile));
$setTo = $this->commandName == 'enable' ? 'true' : 'false';
if ((string) $xml->modules->{$module}->active != $setTo) {
$xml->modules->{$module}->active = $setTo;
if (file_put_contents($decFile, $xml->asXML()) !== false) {
$output->writeln('<info><comment>' . $module . ': </comment>' . $this->commandName . 'd</info>');
} else {
$output->writeln('<error><comment>' . $module . ': </comment>Failed to update declaration file</error>');
}
} else {
$output->writeln('<info><comment>' . $module . ': already ' . $this->commandName . 'd</comment></info>');
}
}
}
示例5: savePackage
public function savePackage()
{
if ($this->getData('file_name') != '') {
$fileName = $this->getData('file_name');
$this->unsetData('file_name');
} else {
$fileName = $this->getName();
}
if (!preg_match('/^[a-z0-9]+[a-z0-9\\-\\_\\.]*([\\/\\\\]{1}[a-z0-9]+[a-z0-9\\-\\_\\.]*)*$/i', $fileName)) {
return false;
}
if (!$this->getPackageXml()) {
$this->generatePackageXml();
}
if (!$this->getPackageXml()) {
return false;
}
$pear = Varien_Pear::getInstance();
$dir = Mage::getBaseDir('var') . DS . 'pear';
try {
$this->_filesystem->write($dir . DS . 'package.xml', $this->getPackageXml());
} catch (Magento_Filesystem_Exception $e) {
return false;
}
$pkgver = $this->getName() . '-' . $this->getReleaseVersion();
$this->unsPackageXml();
$this->unsRoles();
$xml = Mage::helper('Mage_Core_Helper_Data')->assocToXml($this->getData());
$xml = new Varien_Simplexml_Element($xml->asXML());
try {
$this->_filesystem->write($dir . DS . $fileName . '.xml', $xml->asNiceXml());
} catch (Magento_Filesystem_Exception $e) {
return false;
}
return true;
}
示例6: savePackage
/**
* Save package file to var/connect.
*
* @return boolean
*/
public function savePackage()
{
if ($this->getData('file_name') != '') {
$fileName = $this->getData('file_name');
$this->unsetData('file_name');
} else {
$fileName = $this->getName();
}
if (!preg_match('/^[a-z0-9]+[a-z0-9\\-\\_\\.]*([\\/\\\\]{1}[a-z0-9]+[a-z0-9\\-\\_\\.]*)*$/i', $fileName)) {
return false;
}
if (!$this->getPackageXml()) {
$this->generatePackageXml();
}
if (!$this->getPackageXml()) {
return false;
}
try {
$path = Mage::helper('Mage_Connect_Helper_Data')->getLocalPackagesPath();
$this->_filesystem->write($path . 'package.xml', $this->getPackageXml());
$this->unsPackageXml();
$this->unsTargets();
$xml = Mage::helper('Mage_Core_Helper_Data')->assocToXml($this->getData());
$xml = new Varien_Simplexml_Element($xml->asXML());
// prepare dir to save
$parts = explode(DS, $fileName);
array_pop($parts);
$newDir = implode(DS, $parts);
if (!empty($newDir) && !$this->_filesystem->isDirectory($path . $newDir)) {
$this->_filesystem->ensureDirectoryExists($path, $newDir, 0777);
}
$this->_filesystem->write($path . $fileName . '.xml', $xml->asNiceXml());
} catch (Magento_Filesystem_Exception $e) {
return false;
}
return true;
}