Files
Alexandre Gain dce849610c 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.
2026-11-16 13:48:13 +01:00

119 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
use Mautic\CoreBundle\Entity\FormEntity;
/**
* One call of a Smart Link: the short link was requested by a visitor and redirected them.
* One row is written per hit; the Smart Links list shows the derived counts.
*
* date_added and the other audit columns are inherited from FormEntity (mapped there).
*/
class SmartLinkHit extends FormEntity
{
public const TABLE_NAME = 'smart_link_hits';
private ?int $id = null;
private ?SmartLink $smartLink = null;
private ?string $ipAddress = null;
private ?string $referer = null;
private ?string $userAgent = null;
public static function loadMetadata(OrmClassMetadata $metadata): void
{
$builder = new ClassMetadataBuilder($metadata);
$builder->setTable(self::TABLE_NAME)
->setCustomRepositoryClass(SmartLinkHitRepository::class)
->addIndex(['smart_link_id'], 'smart_link_hit_link');
$builder->addId();
// Deleting the link deletes its hits.
$builder->createManyToOne('smartLink', SmartLink::class)
->addJoinColumn('smart_link_id', 'id', false, false, 'CASCADE')
->build();
$builder->createField('ipAddress', 'string')
->columnName('ip_address')
->length(45) // IPv6
->nullable()
->build();
$builder->createField('referer', 'text')
->nullable()
->build();
$builder->createField('userAgent', 'text')
->columnName('user_agent')
->nullable()
->build();
}
public function getId(): ?int
{
return $this->id;
}
public function getSmartLink(): ?SmartLink
{
return $this->smartLink;
}
public function setSmartLink(?SmartLink $smartLink): static
{
$this->isChanged('smartLink', $smartLink);
$this->smartLink = $smartLink;
return $this;
}
public function getIpAddress(): ?string
{
return $this->ipAddress;
}
public function setIpAddress(?string $ipAddress): static
{
$this->isChanged('ipAddress', $ipAddress);
$this->ipAddress = $ipAddress;
return $this;
}
public function getReferer(): ?string
{
return $this->referer;
}
public function setReferer(?string $referer): static
{
$this->isChanged('referer', $referer);
$this->referer = $referer;
return $this;
}
public function getUserAgent(): ?string
{
return $this->userAgent;
}
public function setUserAgent(?string $userAgent): static
{
$this->isChanged('userAgent', $userAgent);
$this->userAgent = $userAgent;
return $this;
}
}