1 | <?php |
||
49 | trait ProcessingInstructionsTrait |
||
50 | { |
||
51 | /** |
||
52 | * Processing instructions |
||
53 | * |
||
54 | * @var GenericPropertiesInterface |
||
55 | */ |
||
56 | protected $processingInstructions; |
||
57 | |||
58 | /** |
||
59 | * Set the processing instruction collection |
||
60 | * |
||
61 | * @param GenericPropertiesInterface $processingInstructions Processing instruction collection |
||
62 | * @param bool $overwrite Overwrite the existing collection (if present) |
||
63 | */ |
||
64 | 19 | protected function setProcessingInstructions(GenericPropertiesInterface $processingInstructions, $overwrite = false) |
|
65 | { |
||
66 | 19 | $this->processingInstructions = $processingInstructions; |
|
67 | 19 | $processingInstructionsState = spl_object_hash($this->processingInstructions); |
|
68 | |||
69 | // If the domain property collection state has changed |
||
70 | 19 | if (!$overwrite |
|
71 | 19 | && !empty($this->collectionStates[ProcessingInstructions::COLLECTION]) |
|
72 | 19 | && ($processingInstructionsState !== $this->collectionStates[ProcessingInstructions::COLLECTION]) |
|
73 | ) { |
||
74 | // Flag this object as dirty |
||
75 | 1 | $this->setDirtyState(); |
|
76 | } |
||
77 | |||
78 | 19 | $this->collectionStates[ProcessingInstructions::COLLECTION] = $processingInstructionsState; |
|
79 | 19 | } |
|
80 | |||
81 | /** |
||
82 | * Get a processing instruction |
||
83 | * |
||
84 | * @param string $procInst Processing instruction name |
||
85 | * @return mixed Processing instruction |
||
86 | */ |
||
87 | public function getProcessingInstruction($procInst) |
||
91 | |||
92 | /** |
||
93 | * Set a processing instruction |
||
94 | * |
||
95 | * @param string $procInst Processing instruction name |
||
96 | * @param mixed $value Processing instruction |
||
97 | * @return ObjectInterface Self reference |
||
98 | */ |
||
99 | 1 | public function setProcessingInstruction($procInst, $value) |
|
104 | |||
105 | /** |
||
106 | * Set the object state to dirty |
||
107 | */ |
||
108 | abstract protected function setDirtyState(); |
||
109 | } |
||
110 |