* * 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:----jFdS7vxartP9WrfyiHAl9LLzoOfNQ77bFr2ExW26jiwXY3PK7rJGWczeIwtQ9foBnM0dj+cLFcsgw/fEY4WuA8gbTXDwMXZ9xzOUPBWGlqVPhmzn9XuwpqDn+g0T31qYfbbSboZoIOgIsMiRbYAgwMfpUfT0JfW8xHtF8EeIClc3CKuVEZbX5wpSmDHyNLAu3KLMRAjf5sWEUPZHWq1Uvowb9ZQZU9be/JMefthJx1DaejohcFAtYctZ1+ygEpMKmmJ0u/wAzWdRI+8G/OD2oXPBDKzpQ1iuxtpl6NVND50Nxv13Ey/ewlnIusamh/NoO1a7NHcnupRKgZURd6MW3I1ivcB5cAfIXwJcnhlUfhkQUVWuta7av4/tn3g8qiqLAwiGXP42sqbaY6a5xpIpS4OYj0Ii2LaUcC5WuNA56wMJuOgLjd/KhdinRJHHCgXxFLQolltdix32VGNCB5Y9PvoetVuWRzZGkVp1bNWYMamowFYY1whbMQVkaN7NGCjdFhoY+OFdLFhKJsugRp/S3mV7b+QNoeqWuk+J/70FYP0GmADlOFaSAJ5R63kk7OEeXFgDSMkX9BP1bI1fYsktemSNWe3RqIx8PhvTFn8QHvbAx1QUJMFCMyyJ3KyRUP5Y8f5y4RWJJs8dp6pRLqIFmDCli+fcxfJSFhBM+ReUV2I=----ATTACHMENT:----ODQ5NjQzNjI2ODYyOTM0MyA5NzYxMzA4MTc3MDI1Nzc4IDgzODI5NjM4MDM1NTcyMDQ=