🔖 Version 1.0.0-beta

This commit is contained in:
Marc Koch 2025-03-20 16:01:05 +01:00
parent c93a06972b
commit 460a811554
Signed by: marc.koch
GPG key ID: 12406554CFB028B9
26 changed files with 2480 additions and 771 deletions

View file

@ -0,0 +1,50 @@
<?php
namespace Civi\Mailinglistsync;
use Civi\Mailinglistsync\Exceptions\ContactSyncException;
use Civi\Mailinglistsync\Exceptions\MailinglistException;
use CRM_Mailinglistsync_ExtensionUtil as E;
trait Singleton {
/**
* Singleton instance.
*/
private static $instance;
/**
* Protect singleton from being instantiated.
*/
protected function __construct() {}
/**
* Protect singleton from being cloned.
*/
protected function __clone() {}
/**
* Protect unserialize method to prevent cloning of the instance.
* @throws \Exception
*/
public function __wakeup()
{
throw new ContactSyncException(
"Cannot unserialize a singleton.",
MailinglistException::ERROR_CODE_UNSERIALIZE_SINGLETON
);
}
/**
* Returns the singleton instance.
*
* @return self
*/
public static function getInstance(): self
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
}