This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,83 @@
<?php
namespace WeltPixel\Backend\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
class GenerateCronExpression implements DataPatchInterface, PatchVersionInterface
{
const UPDATE_CRON_STRING_PATH = "weltpixel/crontab/license";
/** @var WriterInterface */
private $configWriter;
/**
* @var ModuleDataSetupInterface $moduleDataSetup
*/
private $moduleDataSetup;
/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param WriterInterface $configWriter
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
WriterInterface $configWriter)
{
$this->moduleDataSetup = $moduleDataSetup;
$this->configWriter = $configWriter;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$this->moduleDataSetup->startSetup();
$cronExpression = $this->_generateCronExpression();
$this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $cronExpression);
$this->moduleDataSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.1.1';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
/**
* @return string
*/
protected function _generateCronExpression()
{
$minute = rand(0, 59);
$hour = rand(-2, 6);
$dayOfWeek = rand(0, 6);
if ($hour < 0) {
$hour += 24;
}
return $minute . ' ' . $hour . ' * * ' . $dayOfWeek;
}
}
@@ -0,0 +1,85 @@
<?php
namespace WeltPixel\Backend\Setup\Patch\Schema;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
class AddLicenseTable implements SchemaPatchInterface, PatchVersionInterface
{
/**
* @var SchemaSetupInterface $schemaSetup
*/
private $schemaSetup;
/**
* @param SchemaSetupInterface $schemaSetup
*/
public function __construct(SchemaSetupInterface $schemaSetup)
{
$this->schemaSetup = $schemaSetup;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$installer = $this->schemaSetup;
$this->schemaSetup->startSetup();
/**
* Create table 'weltpixel_license'
*/
$table = $installer->getConnection()->newTable(
$installer->getTable('weltpixel_license')
)->addColumn(
'id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Id'
)->addColumn(
'module_name',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
[],
'Module Name'
)->addColumn(
'license_key',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
1024,
[],
'License Key'
)->setComment(
'WeltPixel License'
);
$installer->getConnection()->createTable($table);
$this->schemaSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '1.1.1';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
}