Initial commit: CloudOps infrastructure platform
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\FormBundle\Crate;
|
||||
|
||||
use Mautic\LeadBundle\Helper\FormFieldHelper;
|
||||
|
||||
final class FieldCrate
|
||||
{
|
||||
/**
|
||||
* @param mixed[] $properties
|
||||
*/
|
||||
public function __construct(
|
||||
private string $key,
|
||||
private string $name,
|
||||
private string $type,
|
||||
private array $properties,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getProperties(): array
|
||||
{
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
public function isListType(): bool
|
||||
{
|
||||
$isListType = in_array($this->getType(), FormFieldHelper::getListTypes());
|
||||
$hasList = !empty($this->getProperties()['list']);
|
||||
$hasOptionList = !empty($this->getProperties()['optionlist']);
|
||||
|
||||
return $isListType || $hasList || $hasOptionList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Mautic\FormBundle\Crate;
|
||||
|
||||
use Mautic\FormBundle\Entity\Field;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class FileFieldCrate
|
||||
{
|
||||
public function __construct(
|
||||
private UploadedFile $uploadedFile,
|
||||
private Field $field,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UploadedFile
|
||||
*/
|
||||
public function getUploadedFile()
|
||||
{
|
||||
return $this->uploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Field
|
||||
*/
|
||||
public function getField()
|
||||
{
|
||||
return $this->field;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\FormBundle\Crate;
|
||||
|
||||
final class ObjectCrate
|
||||
{
|
||||
public function __construct(
|
||||
private string $key,
|
||||
private string $name,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Mautic\FormBundle\Crate;
|
||||
|
||||
use Mautic\FormBundle\Entity\Field;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class UploadFileCrate implements \Iterator
|
||||
{
|
||||
/**
|
||||
* @var array|FileFieldCrate[]
|
||||
*/
|
||||
private array $fileFieldCrate = [];
|
||||
|
||||
private int $position = 0;
|
||||
|
||||
public function addFile(UploadedFile $file, Field $field): void
|
||||
{
|
||||
$this->fileFieldCrate[] = new FileFieldCrate($file, $field);
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
public function current(): mixed
|
||||
{
|
||||
return $this->fileFieldCrate[$this->position];
|
||||
}
|
||||
|
||||
public function key(): mixed
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function next(): void
|
||||
{
|
||||
++$this->position;
|
||||
}
|
||||
|
||||
public function valid(): bool
|
||||
{
|
||||
return isset($this->fileFieldCrate[$this->position]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user