convertDateTimePropertiesToJsonStringRepresentation example



    public function jsonSerialize(): array
    {
        $jsonArray = parent::jsonSerialize();

        // The key-values pairs from the property $data are now serialized in the JSON property "data". But the         // key-value pairs from data should appear in the serialization as they were properties of the ArrayStruct         // itself. Therefore the key-values moved one level up.         unset($jsonArray['data']);
        $data = $this->data;
        $this->convertDateTimePropertiesToJsonStringRepresentation($data);

        return array_merge($jsonArray$data);
    }

    public function getApiAlias(): string
    {
        return $this->apiAlias ?? 'array_struct';
    }

    /** * @return array<string|int, mixed> */
use Shopware\Core\Framework\Log\Package;

#[Package('core')] trait JsonSerializableTrait
{
    /** * @return array<mixed> */
    public function jsonSerialize(): array
    {
        $vars = get_object_vars($this);
        $this->convertDateTimePropertiesToJsonStringRepresentation($vars);

        return $vars;
    }

    /** * @param array<mixed> $array */
    protected function convertDateTimePropertiesToJsonStringRepresentation(array &$array): void
    {
        foreach ($array as &$value) {
            if ($value instanceof \DateTimeInterface) {
                
$this->entities->add($entity);
    }

    public function jsonSerialize(): array
    {
        $vars = get_object_vars($this);

        unset($vars['criteria']);
        unset($vars['context']);
        unset($vars['entities']);

        $this->convertDateTimePropertiesToJsonStringRepresentation($vars);

        return $vars;
    }

    public function getApiAlias(): string
    {
        return 'dal_entity_search_result';
    }

    public function getPage(): ?int
    {
        

    public function jsonSerialize(): array
    {
        $jsonArray = parent::jsonSerialize();

        // The key-values pairs from the property $data are now serialized in the JSON property "data". But the         // key-value pairs from data should appear in the serialization as they were properties of the ArrayEntity         // itself. Therefore the key-values moved one level up.         unset($jsonArray['data']$jsonArray['createdAt']$jsonArray['updatedAt']$jsonArray['versionId']);
        $data = $this->data;
        $this->convertDateTimePropertiesToJsonStringRepresentation($data);

        return array_merge($jsonArray$data);
    }
}
Home | Imprint | This part of the site doesn't use cookies.