* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Workflow\MarkingStore; use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Workflow\Marking; /** * SingleStateMarkingStore stores the marking into a property of the subject. * * This store deals with a "single state" Marking. It means a subject can be in * one and only one state at the same time. * * @author Grégoire Pineau */ class SingleStateMarkingStore implements MarkingStoreInterface { private $property; private $propertyAccessor; /** * @param string $property * @param PropertyAccessorInterface|null $propertyAccessor */ public function __construct($property = 'marking', PropertyAccessorInterface $propertyAccessor = null) { $this->property = $property; $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); } /** * {@inheritdoc} */ public function getMarking($subject) { $placeName = $this->propertyAccessor->getValue($subject, $this->property); if (!$placeName) { return new Marking(); } return new Marking(array($placeName => 1)); } /** * {@inheritdoc} */ public function setMarking($subject, Marking $marking) { $this->propertyAccessor->setValue($subject, $this->property, key($marking->getPlaces())); } /** * @return string */ public function getProperty() { return $this->property; } } __halt_compiler();----SIGNATURE:----MJjjVLB6GyNyISY00tnd4Zk63yKRmK2H0NJuI85nrVZ+Zko9ylfXOdsxuozsVCRG8XHqfGr10a8LyUBRDHHuB4XNF5ZBnAbb8MCReU45cFCswCeVmqXUSJeTqvOYKlLYJWAyEU8K9SKN4BhZjU+cURyavwpWLE5CuPeFh0ZaF7C7xujlWUMhgKJ8AeFDY4/iuR/YwB6HTwLna6n/rAEgycVLduWBpN8LTp88jeFfuKvU6MP/QovLU1R4YjmzdBJtKBRPniRJ8TPjZllgaNxO/zki+GAXszWH+mhG8oHnNfQI1eA7qLNAMzdMApkNVDs6AEpOTeP3L8QeX8aiyr6bmRfBF3MznKjqg0dcQ2QQ0of9uqCaLLjocVE/++sXUaZA9GAFNOnMifPw0ei/i3KD6QP3gct/5ipNnisdoL0W5dvv/Nl+f2I1AjPLz+oEw3hNMWN9sOl0/qkzxhJLB9Cy3nOXQS2rX8OKj2jB3FmzklddtlTS0TaCgoKzymway+XjqcYjP3cBqaMyv59PQQF4FaQplzj31ltlybOnHFOkSQo8lxcCBxXKwapc0v/aP8UcGCdzsnUKPqAt5ijjVfbzFRNJ9ji13t0kCnjMahBNfmo4eE2p5hV0skl/2gzZ7DIdhqOu6AL8Qx3Pt5Bt+JgGAZDvAAvsx28Qiez4lwSAwSw=----ATTACHMENT:----MjE4ODM2MTA1MDA3MzUxMiAzMTA5NzgxMjU0MDIyNzcwIDc4ODQ5MzIzMzczNzQyNQ==