Skip to content

[Workflow] Allow using public properties for the marking store #18658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,48 @@ The configured property will be used via its implemented getter/setter methods b
return $this->currentPlace;
}

public function setCurrentPlace($currentPlace, $context = []): void
public function setCurrentPlace(string $currentPlace, array $context = []): void
{
$this->currentPlace = $currentPlace;
}
}

It is also possible to use public properties to be used by the marking
store. The above class would become the following::

// src/Entity/BlogPost.php
namespace App\Entity;

class BlogPost
{
// the configured marking store property must be declared
public string $currentPlace;
public string $title;
public string $content;
}

When using public properties, context is not supported. In order
to support it, you must declare a setter to write your property::

// src/Entity/BlogPost.php
namespace App\Entity;

class BlogPost
{
public string $currentPlace;
// ...

public function setCurrentPlace(string $currentPlace, array $context = []): void
{
// Assign the property and so something with `$context`
}
}

.. versionadded:: 6.4

The support of using public properties instead of getter/setter methods
and private properties was introduced in Symfony 6.4.

.. note::

The marking store type could be "multiple_state" or "single_state". A single
Expand Down