Skip to content

Instantly share code, notes, and snippets.

@webarchitect609
Last active March 19, 2019 07:27
Show Gist options
  • Save webarchitect609/6208ab99c0c2b4645c38ee315ab729c8 to your computer and use it in GitHub Desktop.
Save webarchitect609/6208ab99c0c2b4645c38ee315ab729c8 to your computer and use it in GitHub Desktop.
SprintMigrationBase temporary stub

Быстрый переход на adv/bitrix-tools 2.0

(Инструкция подходит в случае, когда миграции зависят от Adv\Bitrixtools\Migration\SprintMigrationBase.php)

1 Создать в подходящем месте класс SprintMigrationBase на основе шаблона SprintMigrationBase.php . Например, его FQN = Acme\AcmeBundle\Migrations\SprintMigrationBase

2 Заменить во всех файлах Adv\Bitrixtools\Migration\SprintMigrationBase на Acme\AcmeBundle\Migrations\SprintMigrationBase (FQN SprintMigrationBase в конкретной библиотеке, бандле)

3 Проконтролировать, чтобы в конфиге миграций опция migration_extend_class также указывала на Acme\AcmeBundle\Migrations\SprintMigrationBase

! - Это временное, быстрое решение. Далее следует в конкретной библиотеке, бандле изменить код миграций так, чтобы они наследовались от \Sprint\Migration\Version и не использовали SprintMigrationBase.

<?php
namespace Acme\AcmeBundle\Migrations;
use Exception;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Sprint\Migration\HelperManager;
use Sprint\Migration\Version;
/**
* Class SprintMigrationBase
* @package Acme\AcmeBundle\Migrations
*
* @deprecated Since adv/bitrix-tools 2.0 is issued. So please, inherit all your migrations from
* \Sprint\Migration\Version and avoid using SprintMigrationBase
*
* @see Version
*/
class SprintMigrationBase extends Version implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* @var HelperManager
*/
private $helperManager;
/**
* SprintMigrationBase constructor.
* @throws Exception
*/
public function __construct()
{
$this->setLogger(new Logger('Migration', [new StreamHandler(STDOUT, Logger::DEBUG)]));
/**
* ВНИМАНИЕ! Ни в коем случае не вызывать тут CUser::Authorize(1) !!!
* И вообще нигде не вызывать его!
*/
/**
* Разрешение менять чужие настройки, чтобы нормально отработал \CUserOptions::SetOptionsFromArray
*/
$_SESSION["SESS_OPERATIONS"]["edit_other_settings"] = true;
}
/**
* @return LoggerInterface
*/
protected function log()
{
return $this->logger;
}
/**
* Хелпер от пакета Sprint\Migration
*
* @return HelperManager
*/
protected function getHelper()
{
if (is_null($this->helperManager)) {
$this->helperManager = new HelperManager();
}
return $this->helperManager;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment