Thanks to visit codestin.com
Credit goes to github.com

Skip to content

workflow_marked_places() doesn't handle property marking_store.property #34092

Closed
@amalricBzh

Description

@amalricBzh

Symfony version(s) affected: 4.3.5

Description
Calling Twig bridge workflow_marked_places() on a workflow using custom marking_store.property, with an entity which don't have getMarking() getter raise an error.

How to reproduce

  1. Create a workflow with a custom marking field
      supports: App\Entity\MyEntity
      marking_store:
                type: single_state
                property: status
  1. MyEntity has status field with getter and setter:
    /**
     * @var string
     * @ORM\Column(type="string")
     */
    private $status;

    /**
     * @return string
     */
    public function getStatus(): string
    {
        return $this->status;
    }

    /**
     * @param string $status
     * @return MyEntity 
     */
    public function setStatus(string $status): MyEntity 
    {
        $this->status = $status;
        return $this;
    }
  1. In Twig view, call workflow_marked_places
{% for place in workflow_marked_places(oneEntity) %}
    {{ place }}
{% endfor %}

Possible Solution
The bridge try to call getMarking() on my entity instead of getStatus(). If I had a getMarking() in my entity wich give the status field it's OK. But I think I shouldn't have this getter in my entity as I don't have a $marking property...

    /**
     * @return string
     */
    public function getMarking(): string
    {
        return $this->status;
    }

Traces and warning below may help you...

Additional context
The error and trace:

> Symfony\Component\PropertyAccess\Exception\ NoSuchPropertyException

Neither the property "marking" nor one of the methods "getMarking()", "marking()", "isMarking()", "hasMarking()", "__get()" exist and have public access in class "App\Entity\Tud\Transcription".
in vendor/symfony/property-access/PropertyAccessor.php (line 419)
in vendor/symfony/property-access/PropertyAccessor.php->readProperty (line 93)
in vendor/symfony/workflow/MarkingStore/SingleStateMarkingStore.php->getValue (line 46)
in vendor/symfony/workflow/Workflow.php->getMarking (line 55)
in vendor/symfony/twig-bridge/Extension/WorkflowExtension.php->getMarking (line 98)
in var/cache/dev/twig/95/95fbfe4eb42dd8e45d89142d3197a1579c76c4f042676c73aeb29a45c69fade1.php->getMarkedPlaces (line 246)
in vendor/twig/twig/src/Template.php->block_body (line 184)
in var/cache/dev/twig/69/69cea8d72335b574079f91fdfd25b1dc0c169b9258dd1ab7ffe3fde559a0c954.php->displayBlock (line 154) 

The Workflow component throw a deprecation warning:

User Deprecated: "Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" is deprecated since Symfony 4.3, use "Symfony\Component\Workflow\MarkingStore\MethodMarkingStore" instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions