| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- declare(strict_types=1);
- namespace App\Service\Rest\Operation;
- use JetBrains\PhpStorm\Pure;
- /**
- * A single create operation (a POST request)
- */
- class CreateOperation extends BaseRestOperation
- {
- /**
- * @param string $label A label for the operation
- * @param string $entityName The name of the entity to update. This will be used in the path of the request.
- * @param array $data The data to update, will be post as Json within the request.
- * @param array $parameters
- * @param array $options
- */
- #[Pure]
- public function __construct(
- protected string $label,
- protected string $entityName,
- protected array $data,
- protected array $parameters = [],
- protected array $options = []
- ) {
- $options['json'] = $this->data;
- parent::__construct(
- $label,
- 'POST',
- $entityName,
- [],
- $parameters,
- $options
- );
- }
- /**
- * @return string
- */
- public function getEntityName(): string
- {
- return $this->entityName;
- }
- /**
- * @return array
- */
- public function getData(): array
- {
- return $this->data;
- }
- /**
- * Return an array of messages describing the change that this operation will bring
- *
- * @return array
- */
- public function getChangeLog(): array
- {
- $messages = [
- '[POST ' . $this->entityName . ']'
- ];
- array_push(
- $messages,
- ...self::getRecursiveChangeLog([], $this->data)
- );
- return $messages;
- }
- }
|