PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/core/Mage/Dataflow/Model/Convert/Parser/Abstract.php

https://github.com/FiveDigital/magento2
PHP | 120 lines | 43 code | 11 blank | 66 comment | 4 complexity | 98eeb7417986282ad2c2c5cfb18f133b MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Dataflow
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Convert parser abstract
  28. *
  29. * @category Mage
  30. * @package Mage_Dataflow
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. abstract class Mage_Dataflow_Model_Convert_Parser_Abstract
  34. extends Mage_Dataflow_Model_Convert_Container_Abstract
  35. implements Mage_Dataflow_Model_Convert_Parser_Interface
  36. {
  37. /**
  38. * Dataflow batch model
  39. *
  40. * @var Mage_Dataflow_Model_Batch
  41. */
  42. protected $_batch;
  43. /**
  44. * Dataflow batch export model
  45. *
  46. * @var Mage_Dataflow_Model_Batch_Export
  47. */
  48. protected $_batchExport;
  49. /**
  50. * Dataflow batch import model
  51. *
  52. * @var Mage_Dataflow_Model_Batch_Import
  53. */
  54. protected $_batchImport;
  55. /**
  56. * Count parse rows
  57. *
  58. * @var int
  59. */
  60. protected $_countRows = 0;
  61. /**
  62. * Retrieve Batch model singleton
  63. *
  64. * @return Mage_Dataflow_Model_Batch
  65. */
  66. public function getBatchModel()
  67. {
  68. if (is_null($this->_batch)) {
  69. $this->_batch = Mage::getSingleton('Mage_Dataflow_Model_Batch');
  70. }
  71. return $this->_batch;
  72. }
  73. /**
  74. * Retrieve Batch export model
  75. *
  76. * @return Mage_Dataflow_Model_Batch_Export
  77. */
  78. public function getBatchExportModel()
  79. {
  80. if (is_null($this->_batchExport)) {
  81. $object = Mage::getModel('Mage_Dataflow_Model_Batch_Export');
  82. $this->_batchExport = Varien_Object_Cache::singleton()->save($object);
  83. }
  84. return Varien_Object_Cache::singleton()->load($this->_batchExport);
  85. }
  86. /**
  87. * Retrieve Batch import model
  88. *
  89. * @return Mage_Dataflow_Model_Import_Export
  90. */
  91. public function getBatchImportModel()
  92. {
  93. if (is_null($this->_batchImport)) {
  94. $object = Mage::getModel('Mage_Dataflow_Model_Batch_Import');
  95. $this->_batchImport = Varien_Object_Cache::singleton()->save($object);
  96. }
  97. return Varien_Object_Cache::singleton()->load($this->_batchImport);
  98. }
  99. protected function _copy($file)
  100. {
  101. $ioAdapter = new Varien_Io_File();
  102. if (!$ioAdapter->fileExists($file)) {
  103. Mage::throwException(Mage::helper('Mage_Dataflow_Helper_Data')->__('File "%s" does not exist.', $file));
  104. }
  105. $ioAdapter->setAllowCreateFolders(true);
  106. $ioAdapter->createDestinationDir($this->getBatchModel()->getIoAdapter()->getPath());
  107. return $ioAdapter->cp($file, $this->getBatchModel()->getIoAdapter()->getFile(true));
  108. }
  109. }