Initial commit: CloudOps infrastructure platform

This commit is contained in:
root
2026-04-09 19:58:57 +02:00
commit 1166a52f26
7762 changed files with 839452 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace Mautic\ApiBundle\Serializer\Exclusion;
use JMS\Serializer\Context;
use JMS\Serializer\Exclusion\ExclusionStrategyInterface;
use JMS\Serializer\Metadata\ClassMetadata;
use JMS\Serializer\Metadata\PropertyMetadata;
/**
* Exclude specific fields at a specific level.
*/
class FieldExclusionStrategy implements ExclusionStrategyInterface
{
private int $level;
/**
* @param int $level
* @param string|null $path
*/
public function __construct(
private array $fields,
$level = 3,
private $path = null,
) {
$this->level = (int) $level;
}
public function shouldSkipClass(ClassMetadata $metadata, Context $navigatorContext): bool
{
return false;
}
public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext): bool
{
if ($this->path) {
$path = implode('.', $navigatorContext->getCurrentPath());
if ($path !== $this->path) {
return false;
}
}
$name = $property->serializedName ?: $property->name;
if (!in_array($name, $this->fields)) {
return false;
}
// children of children or parents of chidlren will be more than 3 levels deep
if ($navigatorContext->getDepth() <= $this->level) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Mautic\ApiBundle\Serializer\Exclusion;
use JMS\Serializer\Context;
use JMS\Serializer\Exclusion\ExclusionStrategyInterface;
use JMS\Serializer\Metadata\ClassMetadata;
use JMS\Serializer\Metadata\PropertyMetadata;
/**
* Include specific fields at a specific level.
*/
class FieldInclusionStrategy implements ExclusionStrategyInterface
{
private int $level;
/**
* @param int $level
*/
public function __construct(
private array $fields,
$level = 3,
private $path = null,
) {
$this->level = (int) $level;
}
public function shouldSkipClass(ClassMetadata $metadata, Context $navigatorContext): bool
{
return false;
}
public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext): bool
{
if ($this->path) {
$path = implode('.', $navigatorContext->getCurrentPath());
if ($path !== $this->path) {
return false;
}
}
$name = $property->serializedName ?: $property->name;
if (in_array($name, $this->fields)) {
return false;
}
// children of children or parents of chidlren will be more than 3 levels deep
if ($navigatorContext->getDepth() <= $this->level) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Mautic\ApiBundle\Serializer\Exclusion;
/**
* Only include the first level of a children/parent of an entity that relates to itself.
*/
class ParentChildrenExclusionStrategy extends FieldExclusionStrategy
{
/**
* @param int $level
*/
public function __construct($level = 3)
{
parent::__construct(
[
'parent',
'children',
],
$level
);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Mautic\ApiBundle\Serializer\Exclusion;
/**
* Only include FormEntity properties for the top level entity and not the associated entities.
*/
class PublishDetailsExclusionStrategy extends FieldExclusionStrategy
{
public function __construct()
{
parent::__construct(
[
'isPublished',
'dateAdded',
'createdBy',
'dateModified',
'modifiedBy',
'checkedOut',
'checkedOutBy',
],
1
);
}
}