| Current Path : /var/www/homesaver/www/bitrix/modules/sprint.migration/templates/ |
| Current File : /var/www/homesaver/www/bitrix/modules/sprint.migration/templates/HlblockElementsExport.php |
<?php
/**
* @var $version
* @var $description
* @var $extendUse
* @var $extendClass
* @var $moduleVersion
* @var $updateMode
* @var $author
* @formatter:off
*/
use Sprint\Migration\Exchange\HlblockElementsExport;
?><?php echo "<?php\n" ?>
namespace Sprint\Migration;
<?php echo $extendUse ?>
class <?php echo $version ?> extends <?php echo $extendClass ?>
{
protected $author = "<?php echo $author ?>";
protected $description = "<?php echo $description ?>";
protected $moduleVersion = "<?php echo $moduleVersion ?>";
/**
* @throws Exceptions\MigrationException
* @throws Exceptions\RestartException
* @throws Exceptions\HelperException
* @return bool|void
*/
public function up()
{
$this->getExchangeManager()
->HlblockElementsImport()
->setExchangeResource('hlblock_elements.xml')
->setLimit(20)
->execute(function ($item) {
<?php if ($updateMode == HlblockElementsExport::UPDATE_MODE_XML_ID) { ?>
$this->getHelperManager()
->Hlblock()
->saveElementByXmlId(
$item['hlblock_id'],
$item['fields']
);
<?php } else { ?>
$this->getHelperManager()
->Hlblock()
->addElement(
$item['hlblock_id'],
$item['fields']
);
<?php } ?>
});
}
/**
* @throws Exceptions\MigrationException
* @throws Exceptions\RestartException
* @throws Exceptions\HelperException
* @return bool|void
*/
public function down()
{
<?php if ($updateMode == HlblockElementsExport::UPDATE_MODE_XML_ID) { ?>
$this->getExchangeManager()
->HlblockElementsImport()
->setExchangeResource('hlblock_elements.xml')
->setLimit(20)
->execute(function ($item) {
$this->getHelperManager()
->Hlblock()
->deleteElementByXmlId(
$item['hlblock_id'],
$item['fields']['UF_XML_ID']
);
});
<?php } ?>
}
}