Просмотр исходного кода

[Technique] Paramètres : nouveau système de settings #1175

feature/souke
Guillaume Bourgeois 1 год назад
Родитель
Сommit
4e65fc8597
25 измененных файлов: 756 добавлений и 10 удалений
  1. +3
    -1
      common/components/BusinessLogic.php
  2. +12
    -0
      common/components/BusinessLogicTrait.php
  3. +0
    -2
      common/logic/AbstractChecker.php
  4. +3
    -1
      common/logic/AbstractRepository.php
  5. +8
    -0
      common/logic/AbstractResolver.php
  6. +32
    -0
      common/logic/Feature/FeatureProducer/FeatureProducerModule.php
  7. +4
    -2
      common/logic/Order/Order/Service/TillerManager.php
  8. +4
    -4
      common/logic/ProducerContextTrait.php
  9. +105
    -0
      common/logic/Setting/Setting.php
  10. +22
    -0
      common/logic/Setting/SettingBag.php
  11. +77
    -0
      common/logic/Setting/SettingBuilder.php
  12. +47
    -0
      common/logic/Setting/SettingDefinition.php
  13. +123
    -0
      common/logic/Setting/SettingDetails/AbstractSettingDetail.php
  14. +37
    -0
      common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php
  15. +15
    -0
      common/logic/Setting/SettingDetails/Admin/General/AdministratorEmailAdminSetting.php
  16. +15
    -0
      common/logic/Setting/SettingDetails/Admin/General/AdministratorPhoneNumberAdminSetting.php
  17. +16
    -0
      common/logic/Setting/SettingDetails/Admin/General/IsTestAdminSetting.php
  18. +15
    -0
      common/logic/Setting/SettingDetails/Admin/General/SupportEmailAdminSetting.php
  19. +30
    -0
      common/logic/Setting/SettingDetails/Producer/ProducerSettingDefinition.php
  20. +43
    -0
      common/logic/Setting/SettingImporter.php
  21. +37
    -0
      common/logic/Setting/SettingModule.php
  22. +32
    -0
      common/logic/Setting/SettingRepository.php
  23. +21
    -0
      common/logic/Setting/SettingRepositoryQuery.php
  24. +18
    -0
      console/commands/SettingController.php
  25. +37
    -0
      console/migrations/m231114_085352_create_table_setting.php

+ 3
- 1
common/components/BusinessLogic.php Просмотреть файл

@@ -15,7 +15,9 @@ class BusinessLogic
public function getModules()
{
return [
$this->getSettingModule(),
$this->getFeatureModule(),
$this->getFeatureProducerModule(),
$this->getUnitModule(),
$this->getTaxRateModule(),
$this->getUserUserGroupModule(),
@@ -53,7 +55,7 @@ class BusinessLogic
return $this->producerContext;
}

public function setProducerContext(Producer $producer)
public function setProducerContext(Producer $producer = null)
{
$this->producerContext = $producer;


+ 12
- 0
common/components/BusinessLogicTrait.php Просмотреть файл

@@ -12,6 +12,7 @@ use common\logic\Document\Document\Module\DocumentModule;
use common\logic\Document\Invoice\Module\InvoiceModule;
use common\logic\Document\Quotation\Module\QuotationModule;
use common\logic\Feature\Feature\FeatureModule;
use common\logic\Feature\FeatureProducer\FeatureProducerModule;
use common\logic\Opinion\Module\OpinionModule;
use common\logic\Order\Order\Module\OrderModule;
use common\logic\Order\ProductOrder\Module\ProductOrderModule;
@@ -24,6 +25,7 @@ use common\logic\Product\Product\Module\ProductModule;
use common\logic\Product\ProductCategory\Module\ProductCategoryModule;
use common\logic\Product\ProductPointSale\Module\ProductPointSaleModule;
use common\logic\Product\ProductPrice\Module\ProductPriceModule;
use common\logic\Setting\SettingModule;
use common\logic\Subscription\ProductSubscription\Module\ProductSubscriptionModule;
use common\logic\Subscription\Subscription\Module\SubscriptionModule;
use common\logic\Ticket\Ticket\Module\TicketModule;
@@ -190,4 +192,14 @@ trait BusinessLogicTrait
{
return FeatureModule::getInstance();
}

public function getFeatureProducerModule(): FeatureProducerModule
{
return FeatureProducerModule::getInstance();
}

public function getSettingModule(): SettingModule
{
return SettingModule::getInstance();
}
}

+ 0
- 2
common/logic/AbstractChecker.php Просмотреть файл

@@ -2,8 +2,6 @@

namespace common\logic;

use yii\db\ActiveRecord;

abstract class AbstractChecker extends AbstractService implements CheckerInterface
{


+ 3
- 1
common/logic/AbstractRepository.php Просмотреть файл

@@ -67,7 +67,9 @@ abstract class AbstractRepository extends AbstractService implements RepositoryI
public function defaultFilterProducerContext(): void
{
$defaultOptions = $this->getDefaultOptionsSearch();
if(isset($defaultOptions['attribute_id_producer']) && $defaultOptions['attribute_id_producer']) {
if(isset($defaultOptions['attribute_id_producer'])
&& $defaultOptions['attribute_id_producer']
&& $this->getProducerContext(false)) {
$this->query->andWhere([$defaultOptions['attribute_id_producer'] => $this->getProducerContextId()]);
}
}

+ 8
- 0
common/logic/AbstractResolver.php Просмотреть файл

@@ -0,0 +1,8 @@
<?php

namespace common\logic;

abstract class AbstractResolver extends AbstractService implements ResolverInterface
{

}

+ 32
- 0
common/logic/Feature/FeatureProducer/FeatureProducerModule.php Просмотреть файл

@@ -0,0 +1,32 @@
<?php

namespace common\logic\Feature\FeatureProducer;

use common\logic\AbstractModule;

class FeatureProducerModule extends AbstractModule
{
public function getServices(): array
{
return [
FeatureProducerDefinition::class,
FeatureProducerRepository::class,
FeatureProducerBuilder::class,
];
}

public function getDefinition(): FeatureProducerDefinition
{
return FeatureProducerDefinition::getInstance();
}

public function getRepository(): FeatureProducerRepository
{
return FeatureProducerRepository::getInstance();
}

public function getBuilder(): FeatureProducerBuilder
{
return FeatureProducerBuilder::getInstance();
}
}

+ 4
- 2
common/logic/Order/Order/Service/TillerManager.php Просмотреть файл

@@ -21,8 +21,10 @@ class TillerManager extends AbstractManager
public function loadDependencies(): void
{
$this->producerSolver = $this->loadService(ProducerSolver::class);
$this->tillerActivated = $this->producerSolver->getConfig('tiller');
$this->tillerClient = $this->getClient();
if($this->producerSolver->getProducerContext(false)) {
$this->tillerActivated = $this->producerSolver->getConfig('tiller');
$this->tillerClient = $this->getClient();
}
$this->orderSolver = $this->loadService(OrderSolver::class);
$this->orderBuilder = $this->loadService(OrderBuilder::class);
$this->productOrderSolver = $this->loadService(ProductOrderSolver::class);

+ 4
- 4
common/logic/ProducerContextTrait.php Просмотреть файл

@@ -7,18 +7,18 @@ use yii\base\ErrorException;

trait ProducerContextTrait
{
protected ?Producer $producerContext = null;
protected ?Producer $producerContext;

public function setProducerContext(Producer $producer): self
public function setProducerContext(Producer $producer = null): self
{
$this->producerContext = $producer;

return $this;
}

public function getProducerContext(): Producer
public function getProducerContext(bool $throwExceptionIfNull = true): ?Producer
{
if(is_null($this->producerContext)) {
if($throwExceptionIfNull && is_null($this->producerContext)) {
throw new ErrorException("Le contexte producteur n'est pas défini.");
}


+ 105
- 0
common/logic/Setting/Setting.php Просмотреть файл

@@ -0,0 +1,105 @@
<?php

/**
* Copyright distrib (2018)
*
* contact@opendistrib.net
*
* Ce logiciel est un programme informatique servant à aider les producteurs
* à distribuer leur production en circuits courts.
*
* Ce logiciel est régi par la licence CeCILL soumise au droit français et
* respectant les principes de diffusion des logiciels libres. Vous pouvez
* utiliser, modifier et/ou redistribuer ce programme sous les conditions
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
* sur le site "http://www.cecill.info".
*
* En contrepartie de l'accessibilité au code source et des droits de copie,
* de modification et de redistribution accordés par cette licence, il n'est
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
* seule une responsabilité restreinte pèse sur l'auteur du programme, le
* titulaire des droits patrimoniaux et les concédants successifs.
*
* A cet égard l'attention de l'utilisateur est attirée sur les risques
* associés au chargement, à l'utilisation, à la modification et/ou au
* développement et à la reproduction du logiciel par l'utilisateur étant
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à
* manipuler et qui le réserve donc à des développeurs et des professionnels
* avertis possédant des connaissances informatiques approfondies. Les
* utilisateurs sont donc invités à charger et tester l'adéquation du
* logiciel à leurs besoins dans des conditions permettant d'assurer la
* sécurité de leurs systèmes et ou de leurs données et, plus généralement,
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
*
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
* pris connaissance de la licence CeCILL, et que vous en avez accepté les
* termes.
*/

namespace common\logic\Setting;

use common\components\ActiveRecordCommon;
use common\logic\Producer\Producer\Model\Producer;

class Setting extends ActiveRecordCommon
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'setting';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['id_producer'], 'integer'],
[['id_producer'], 'exist', 'skipOnError' => true, 'targetClass' => Producer::class, 'targetAttribute' => ['id_producer' => 'id']],
[['name', 'string', 'text'], 'string'],
[['name','string'], 'string', 'max' => 255],
[['date'], 'date', 'format' => 'php:Y-m-d'],
[['integer'], 'integer'],
[['float', 'double'], 'number'],
[['boolean'], 'boolean'],
[['name'], 'unique'],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'id_producer' => 'Producteur',
'name' => 'Nom',
];
}

/*
* Relations
*/

public function getSettingDetail()
{
return SettingDefinition::getInstance()->getSettingDetailByName($this->name);
}

public function getProducer()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

public function populateProducer(Producer $producer = null): void
{
if($producer) {
$this->populateFieldObject('id_producer', 'producer', $producer);
}
}
}

+ 22
- 0
common/logic/Setting/SettingBag.php Просмотреть файл

@@ -0,0 +1,22 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractChecker;

class SettingBag extends AbstractChecker
{
// $settingModule->getSettingBag()->getSetting(AdminSettingDefinition::SETTING_ADMINISTRATOR_EMAIL);
// $settingModule->getSettingBag()->get('administratorEmail');
// $settingModule->getProducerSettingBag()->get('isTest');

public function getSetting(string $name)
{

}

public function setSetting(string $name, $values)
{

}
}

+ 77
- 0
common/logic/Setting/SettingBuilder.php Просмотреть файл

@@ -0,0 +1,77 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractBuilder;
use yii\base\ErrorException;

class SettingBuilder extends AbstractBuilder
{
protected SettingDefinition $settingDefinition;
protected SettingRepository $settingRepository;

public function loadDependencies(): void
{
$this->settingDefinition = $this->loadService(SettingDefinition::class);
$this->settingRepository = $this->loadService(SettingRepository::class);
}

public function instanciateSetting(
string $name
): Setting
{
$setting = new Setting();
$setting->name = $name;
$setting->populateProducer($this->getProducerContext(false));
$this->initDefaultValue($setting);

return $setting;
}

public function createSetting(
string $name
): Setting
{
$setting = $this->settingRepository->findOneSettingByName($name);
if(!$setting) {
$setting = $this->instanciateSetting($name);
$this->create($setting);
}

return $setting;
}

public function initValue(Setting $setting, $value)
{
$settingDetail = $this->settingDefinition->getSettingDetailByName($setting->name);
$type = $settingDetail->getType();
if(in_array($type, ['string', 'text', 'date', 'integer', 'float', 'double', 'boolean'])) {
$setting->$type = $value;
}
else {
throw new ErrorException("Le type de donnée n'est pas reconnu.");
}
}

public function initDefaultValue(Setting $setting)
{
$settingDetail = $this->settingDefinition->getSettingDetailByName($setting->name);
if($settingDetail->getDefaultValue()) {
$this->initValue($setting, $settingDetail->getDefaultValue());
}
}

public function updateValueByName(string $name, $value): void
{
$setting = $this->createSetting($name);
$this->initValue($setting, $value);
$this->update($setting);
}

public function updateDefaultValueByName(string $name)
{
$setting = $this->createSetting($name);
$this->initDefaultValue($setting);
$this->update($setting);
}
}

+ 47
- 0
common/logic/Setting/SettingDefinition.php Просмотреть файл

@@ -0,0 +1,47 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractDefinition;
use common\logic\Setting\SettingDetails\Admin\AdminSettingDefinition;
use common\logic\Setting\SettingDetails\Producer\ProducerSettingDefinition;

class SettingDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return Setting::class;
}

public function getSettingDetailByName(string $name)
{
$adminSettingDefinition = AdminSettingDefinition::getInstance();
$producerSettingDefinition = ProducerSettingDefinition::getInstance();

$settingDetail = $this->findSettingDetailInArray($name, $adminSettingDefinition->getSettingDetails());
if(!$settingDetail) {
$this->findSettingDetailInArray($name, $producerSettingDefinition->getSettingDetails());
}

if(!$settingDetail) {
throw new \Exception('SettingDetail non trouvé');
}

return $settingDetail;
}

public function findSettingDetailInArray(string $name, array $settingDetailsArray)
{
foreach($settingDetailsArray as $section => $subsectionsArray) {
foreach($subsectionsArray as $subsection => $settingDetailsArray) {
foreach($settingDetailsArray as $settingDetail) {
if($name == $settingDetail->getName()) {
return $settingDetail;
}
}
}
}

return null;
}
}

+ 123
- 0
common/logic/Setting/SettingDetails/AbstractSettingDetail.php Просмотреть файл

@@ -0,0 +1,123 @@
<?php

namespace common\logic\Setting\SettingDetails;

class AbstractSettingDetail
{
const TYPE_STRING = 'string';
const TYPE_TEXT = 'text';
const TYPE_BOOLEAN = 'boolean';
const TYPE_DATE = 'date';
const TYPE_INTEGER = 'integer';
const TYPE_FLOAT = 'float';
const TYPE_DOUBLE = 'double';

public string $name;
public string $type;
public string $section;
public $defaultValue = null;
public ?string $subSection = null;
public ?string $helpMessage = null;

public function setName(string $name): self
{
$this->name = $name;
return $this;
}

public function getName(): string
{
return $this->name;
}

public function setSection(string $section): self
{
$this->section = $section;
return $this;
}

public function getSection(): string
{
return $this->section;
}

public function setSubSection(string $subSection): self
{
$this->subSection = $subSection;
return $this;
}

public function getSubSection(): ?string
{
return $this->subSection;
}

public function setHelpMessage(string $helpMessage): self
{
$this->helpMessage = $helpMessage;
return $this;
}

public function getHelpMessage(): ?string
{
return $this->helpMessage;
}

public function setDefaultValue($defaultValue): self
{
$this->defaultValue = $defaultValue;
return $this;
}

public function getDefaultValue()
{
return $this->defaultValue;
}

public function setTypeString(): self
{
$this->type = self::TYPE_STRING;
return $this;
}

public function setTypeText(): self
{
$this->type = self::TYPE_TEXT;
return $this;
}

public function setTypeBoolean(): self
{
$this->type = self::TYPE_BOOLEAN;
return $this;
}

public function setTypeDate(): self
{
$this->type = self::TYPE_DATE;
return $this;
}

public function setTypeInteger(): self
{
$this->type = self::TYPE_INTEGER;
return $this;
}

public function setTypeFloat(): self
{
$this->type = self::TYPE_FLOAT;
return $this;
}

public function setTypeDouble(): self
{
$this->type = self::TYPE_DOUBLE;
return $this;
}

public function getType(): string
{
return $this->type;
}
}

+ 37
- 0
common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php Просмотреть файл

@@ -0,0 +1,37 @@
<?php

namespace common\logic\Setting\SettingDetails\Admin;

use common\logic\Setting\SettingDefinition;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\IsTestAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\SupportEmailAdminSetting;

class AdminSettingDefinition extends SettingDefinition
{
const SECTION_GENERAL = 'general';
const SUBSECTION_GENERAL = 'general.main';

public function getSettingDetails(): array
{
return [
self::SECTION_GENERAL => [
self::SUBSECTION_GENERAL => [
new AdministratorEmailAdminSetting,
new SupportEmailAdminSetting,
new AdministratorPhoneNumberAdminSetting,
new IsTestAdminSetting,
]
]
];
}

public function getSectionLabels(): array
{
return [
self::SECTION_GENERAL => 'General',
self::SUBSECTION_GENERAL => 'General',
];
}
}

+ 15
- 0
common/logic/Setting/SettingDetails/Admin/General/AdministratorEmailAdminSetting.php Просмотреть файл

@@ -0,0 +1,15 @@
<?php

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class AdministratorEmailAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('administratorEmail')
->setTypeString();
}
}

+ 15
- 0
common/logic/Setting/SettingDetails/Admin/General/AdministratorPhoneNumberAdminSetting.php Просмотреть файл

@@ -0,0 +1,15 @@
<?php

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class AdministratorPhoneNumberAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('administratorPhoneNumber')
->setTypeString();
}
}

+ 16
- 0
common/logic/Setting/SettingDetails/Admin/General/IsTestAdminSetting.php Просмотреть файл

@@ -0,0 +1,16 @@
<?php

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class IsTestAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('isTest')
->setTypeBoolean()
->setDefaultValue(true);
}
}

+ 15
- 0
common/logic/Setting/SettingDetails/Admin/General/SupportEmailAdminSetting.php Просмотреть файл

@@ -0,0 +1,15 @@
<?php

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class SupportEmailAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('supportEmail')
->setTypeString();
}
}

+ 30
- 0
common/logic/Setting/SettingDetails/Producer/ProducerSettingDefinition.php Просмотреть файл

@@ -0,0 +1,30 @@
<?php

namespace common\logic\Setting\SettingDetails\Producer;

use common\logic\Setting\SettingDefinition;

class ProducerSettingDefinition extends SettingDefinition
{
const SECTION_GENERAL = 'general';
const SUBSECTION_GENERAL = 'general.main';

public function getSettings(): array
{
return [
self::SECTION_GENERAL => [
self::SUBSECTION_GENERAL => [
// ...
]
]
];
}

public function getSectionLabels(): array
{
return [
self::SECTION_GENERAL => 'General',
self::SUBSECTION_GENERAL => 'General',
];
}
}

+ 43
- 0
common/logic/Setting/SettingImporter.php Просмотреть файл

@@ -0,0 +1,43 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractManager;
use common\logic\Setting\SettingDetails\Admin\AdminSettingDefinition;

class SettingImporter extends AbstractManager
{
protected AdminSettingDefinition $adminSettingDefinition;
protected SettingBuilder $settingBuilder;

public function loadDependencies(): void
{
$this->adminSettingDefinition = $this->loadService(AdminSettingDefinition::class);
$this->settingBuilder = $this->loadService(SettingBuilder::class);
}

public function importFromDefinitions()
{
$this->importFromAdminSettingDefinition();
$this->importFromProducerSettingDefinition();
}

public function importFromAdminSettingDefinition(): void
{
\Yii::$app->logic->setProducerContext(null);
$settingDetails = $this->adminSettingDefinition->getSettingDetails();

foreach($settingDetails as $subsectionsArray) {
foreach($subsectionsArray as $settingDetailsArray) {
foreach($settingDetailsArray as $settingDetail) {
$this->settingBuilder->createSetting($settingDetail->getName());
}
}
}
}

public function importFromProducerSettingDefinition(): void
{
// /!\ bien définir le contexte producteur
}
}

+ 37
- 0
common/logic/Setting/SettingModule.php Просмотреть файл

@@ -0,0 +1,37 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractModule;
use common\logic\Setting\SettingDetails\Admin\AdminSettingDefinition;
use common\logic\Setting\SettingDetails\Producer\ProducerSettingDefinition;

class SettingModule extends AbstractModule
{
public function getServices(): array
{
return [
SettingDefinition::class,
AdminSettingDefinition::class,
ProducerSettingDefinition::class,
SettingRepository::class,
SettingBuilder::class,
SettingImporter::class
];
}

public function getDefinition(): SettingDefinition
{
return SettingDefinition::getInstance();
}

public function getRepository(): SettingRepository
{
return SettingRepository::getInstance();
}

public function getImporter(): SettingImporter
{
return SettingImporter::getInstance();
}
}

+ 32
- 0
common/logic/Setting/SettingRepository.php Просмотреть файл

@@ -0,0 +1,32 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractRepository;

class SettingRepository extends AbstractRepository
{
protected SettingRepositoryQuery $query;

public function loadDependencies(): void
{
$this->loadQuery(SettingRepositoryQuery::class);
}
public function getDefaultOptionsSearch(): array
{
return [
self::WITH => ['producer'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => 'setting.id_producer'
];
}

public function findOneSettingByName(string $name)
{
return $this->createDefaultQuery()
->filterByName($name)
->findOne();
}
}

+ 21
- 0
common/logic/Setting/SettingRepositoryQuery.php Просмотреть файл

@@ -0,0 +1,21 @@
<?php

namespace common\logic\Setting;

use common\logic\AbstractRepositoryQuery;

class SettingRepositoryQuery extends AbstractRepositoryQuery
{
protected SettingDefinition $definition;

public function loadDependencies(): void
{
$this->loadDefinition(SettingDefinition::class);
}

public function filterByName(string $name): self
{
$this->andWhere(['name' => $name]);
return $this;
}
}

+ 18
- 0
console/commands/SettingController.php Просмотреть файл

@@ -0,0 +1,18 @@
<?php

namespace console\commands;

use common\logic\Setting\SettingModule;
use yii\console\Controller;

class SettingController extends Controller
{
// ./yii setting/import
public function actionImport()
{
$settingModule = SettingModule::getInstance();
$settingModule->getImporter()->importFromDefinitions();
}
}

?>

+ 37
- 0
console/migrations/m231114_085352_create_table_setting.php Просмотреть файл

@@ -0,0 +1,37 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m231114_085352_create_table_setting
*/
class m231114_085352_create_table_setting extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('setting', [
'id' => 'pk',
'name' => Schema::TYPE_STRING.' NOT NULL',
'id_producer' => Schema::TYPE_INTEGER,
'string' => Schema::TYPE_STRING,
'text' => Schema::TYPE_TEXT,
'date' => Schema::TYPE_DATE,
'integer' => Schema::TYPE_INTEGER,
'float' => Schema::TYPE_FLOAT,
'double' => Schema::TYPE_DOUBLE,
'boolean' => Schema::TYPE_BOOLEAN,
]);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('setting');
}
}

Загрузка…
Отмена
Сохранить