Initial commit: CloudOps infrastructure platform
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Mautic\AssetBundle\Helper;
|
||||
|
||||
class PointActionHelper
|
||||
{
|
||||
public static function validateAssetDownload($eventDetails, $action): bool
|
||||
{
|
||||
$assetId = $eventDetails->getId();
|
||||
$limitToAssets = $action['properties']['assets'];
|
||||
|
||||
if (!empty($limitToAssets) && !in_array($assetId, $limitToAssets)) {
|
||||
// no points change
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Mautic\AssetBundle\Helper;
|
||||
|
||||
use Mautic\AssetBundle\Model\AssetModel;
|
||||
|
||||
class TokenHelper
|
||||
{
|
||||
public const REGEX = '/{assetlink=(.*?)}/';
|
||||
|
||||
public function __construct(
|
||||
protected AssetModel $model,
|
||||
) {
|
||||
}
|
||||
|
||||
public function findAssetTokens($content, $clickthrough = []): array
|
||||
{
|
||||
$tokens = [];
|
||||
|
||||
preg_match_all(self::REGEX, $content, $matches);
|
||||
foreach ($matches[1] as $key => $assetId) {
|
||||
$token = $matches[0][$key];
|
||||
|
||||
if (isset($tokens[$token])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$asset = $this->model->getEntity($assetId);
|
||||
$tokens[$token] = (null !== $asset) ? $this->model->generateUrl($asset, true, $clickthrough) : '';
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user