21 lines
591 B
PHP
21 lines
591 B
PHP
<?php
|
|
|
|
namespace Lean\Api\Attribute\Action;
|
|
|
|
use Picea\Ui\Method\FormContextInterface;
|
|
use Ulmus\Entity\EntityInterface;
|
|
|
|
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
|
|
class Trim extends \Lean\Api\Attribute\Action
|
|
{
|
|
public function __construct(
|
|
public string $characters = " \n\r\t\v\0"
|
|
) {}
|
|
|
|
public function action(EntityInterface $entity, string $key, FormContextInterface $context, string $field): ActionTypeEnum
|
|
{
|
|
$context->$field = trim($context->$field, $this->characters);
|
|
|
|
return ActionTypeEnum::ValueModifier;
|
|
}
|
|
} |