Merge the Smartlinks plugin (SmartlinksBundle 0.6.0) into the bundle as the Smart Links domain (0.18.0)
Two domains, one MT3S bundle: Marketing Programs (unchanged) and the
imported Smart Links (smart links + UTM taxonomies), each keeping its
own menu, tables, routes and translations.
- Code moved from MauticPlugin\SmartlinksBundle\ to
MauticPlugin\MT3SMarketingProgramBundle\; template namespace
@Smartlinks/ -> @MT3SMarketingProgram/; smartlinks.js ->
Assets/js/mt3s-mp-smartlinks.js; icon -> Assets/img/smartlinks-icon.svg.
- Incoming migrations renamed Version_0_X_0_SmartLinks.php to avoid
the class-name collision; schema untouched, data intact.
- Permissions folded into MT3SMarketingProgramPermissions:
smart_links + taxonomies under the mt3smarketingprogram: base
(roles that had the old smartlinks: grants must be re-granted).
- config.php: Smart Links routes + menu group, public /l/{slug},
SmartlinksIntegration services, smartlinks_* parameters (legacy
utm_manager_* keys still readable), version 0.18.0. The 0.17.0
placeholder /s/marketing-program-utm-taxonomies is replaced by the
real /s/utm-taxonomies.
- Translations merged (en_US) and added (fr_FR); Tests/ + phpunit moved
in; readme documents both domains and the 0.18.0 merge history.
Verified live: menus, both config tabs, both lists + forms, program
pages, public redirect with taxonomy UTM values, host + unknown-slug
404s, 90/90 unit tests, full php -l, all ini catalogs parse.
This commit is contained in:
1 parent
debce4ba4a
commit
dce849610c
69 files changed
+8225
-43
No files matched your search
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
|
||||
|
||||
/**
|
||||
* The 0.6.0 UTM Taxonomies feature: the `utm_taxonomies` table, and the taxonomy of each
|
||||
* Smart Link (`utm_taxonomy_id`, ON DELETE SET NULL: deleting a taxonomy keeps its links,
|
||||
* they redirect with the values they already carry).
|
||||
*
|
||||
* Idempotent: runs on plugin update (core's migration engine) and right after a fresh install
|
||||
* (PluginInstallSubscriber), and stops when everything is already in place.
|
||||
*/
|
||||
class Version_0_6_0_SmartLinks extends AbstractMigration
|
||||
{
|
||||
protected function isApplicable(Schema $schema): bool
|
||||
{
|
||||
return !$schema->hasTable($this->concatPrefix(UtmTaxonomy::TABLE_NAME))
|
||||
|| !$this->hasTaxonomyColumn($schema)
|
||||
|| [] !== $this->getMissingForeignKeys($schema);
|
||||
}
|
||||
|
||||
protected function up(): void
|
||||
{
|
||||
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||
|
||||
if (!$schema->hasTable($this->concatPrefix(UtmTaxonomy::TABLE_NAME))) {
|
||||
$table = $this->concatPrefix(UtmTaxonomy::TABLE_NAME);
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TABLE {$table} (
|
||||
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
is_published TINYINT(1) NOT NULL,
|
||||
date_added DATETIME DEFAULT NULL,
|
||||
created_by INT DEFAULT NULL,
|
||||
created_by_user VARCHAR(191) DEFAULT NULL,
|
||||
date_modified DATETIME DEFAULT NULL,
|
||||
modified_by INT DEFAULT NULL,
|
||||
modified_by_user VARCHAR(191) DEFAULT NULL,
|
||||
checked_out DATETIME DEFAULT NULL,
|
||||
checked_out_by INT DEFAULT NULL,
|
||||
checked_out_by_user VARCHAR(191) DEFAULT NULL,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
description LONGTEXT DEFAULT NULL,
|
||||
parameters JSON NOT NULL,
|
||||
UNIQUE INDEX UNIQ_TAXONOMY_NAME (name),
|
||||
INDEX utm_taxonomy_name (name),
|
||||
PRIMARY KEY(id)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
|
||||
SQL);
|
||||
}
|
||||
|
||||
if (!$this->hasTaxonomyColumn($schema)) {
|
||||
$this->addSql(sprintf(
|
||||
'ALTER TABLE %s ADD utm_taxonomy_id INT UNSIGNED DEFAULT NULL',
|
||||
$this->concatPrefix(SmartLink::TABLE_NAME)
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($this->getMissingForeignKeys($schema) as $foreignKey) {
|
||||
$this->addSql($this->generateAlterTableForeignKeyStatement(
|
||||
SmartLink::TABLE_NAME,
|
||||
['utm_taxonomy_id'],
|
||||
UtmTaxonomy::TABLE_NAME,
|
||||
['id'],
|
||||
'ON DELETE SET NULL'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function hasTaxonomyColumn(Schema $schema): bool
|
||||
{
|
||||
$links = $this->concatPrefix(SmartLink::TABLE_NAME);
|
||||
|
||||
return $schema->hasTable($links) && $schema->getTable($links)->hasColumn('utm_taxonomy_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function getMissingForeignKeys(Schema $schema): array
|
||||
{
|
||||
$links = $this->concatPrefix(SmartLink::TABLE_NAME);
|
||||
$missing = ['utm_taxonomy_id'];
|
||||
|
||||
if ($schema->hasTable($links)) {
|
||||
foreach ($schema->getTable($links)->getForeignKeys() as $foreignKey) {
|
||||
$missing = array_diff($missing, $foreignKey->getLocalColumns());
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($missing);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user