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(); }
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; }
/** * 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; }
/** * 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>'); } } }
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; }
/** * 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; }