@@ -22,148 +22,148 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class SourceStatus |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var boolean $source_exist |
|
| 27 | - */ |
|
| 28 | - private $source_exist = false; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var boolean $has_document |
|
| 32 | - */ |
|
| 33 | - private $has_document = false; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Return whether the SourceStatus object contains relevant data. |
|
| 37 | - * |
|
| 38 | - * @return bool |
|
| 39 | - */ |
|
| 40 | - public function isSet(): bool |
|
| 41 | - { |
|
| 42 | - return true; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Returns whether the record contains a source. |
|
| 47 | - * |
|
| 48 | - * @return bool |
|
| 49 | - */ |
|
| 50 | - public function hasSource(): bool |
|
| 51 | - { |
|
| 52 | - return $this->source_exist; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Set whether the record contains a source. |
|
| 57 | - * |
|
| 58 | - * @param bool $source_exist |
|
| 59 | - * @return $this |
|
| 60 | - */ |
|
| 61 | - public function setHasSource(bool $source_exist): self |
|
| 62 | - { |
|
| 63 | - $this->source_exist = $source_exist; |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Combine whether the record contains a source with the previous status. |
|
| 69 | - * |
|
| 70 | - * @param bool $source_exist |
|
| 71 | - * @return $this |
|
| 72 | - */ |
|
| 73 | - public function addHasSource(bool $source_exist): self |
|
| 74 | - { |
|
| 75 | - $this->source_exist = $this->source_exist || $source_exist; |
|
| 76 | - return $this; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Return whether the source citation is supported by a document. |
|
| 81 | - * Uses the _ACT tag from the MyArtJaub Certificates module. |
|
| 82 | - * |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - public function hasSupportingDocument(): bool |
|
| 86 | - { |
|
| 87 | - return $this->hasSource() && $this->has_document; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Set whether the source citation is supported by a document. |
|
| 92 | - * |
|
| 93 | - * @param bool $has_document |
|
| 94 | - * @return $this |
|
| 95 | - */ |
|
| 96 | - public function setHasSupportingDocument(bool $has_document): self |
|
| 97 | - { |
|
| 98 | - $this->has_document = $has_document; |
|
| 99 | - return $this; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Combine whether the source citation is supported by a document with the previous status. |
|
| 104 | - * |
|
| 105 | - * @param bool $has_document |
|
| 106 | - * @return $this |
|
| 107 | - */ |
|
| 108 | - public function addHasSupportingDocument(bool $has_document): self |
|
| 109 | - { |
|
| 110 | - $this->has_document = $this->has_document || $has_document; |
|
| 111 | - return $this; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Check whether all possible criteria for defining a sourced element have been met. |
|
| 116 | - * |
|
| 117 | - * @return bool |
|
| 118 | - */ |
|
| 119 | - public function isFullySourced(): bool |
|
| 120 | - { |
|
| 121 | - return $this->hasSupportingDocument(); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Get the label to display to describe the source status. |
|
| 126 | - * |
|
| 127 | - * @param string $context |
|
| 128 | - * @return string |
|
| 129 | - */ |
|
| 130 | - public function label(string $context): string |
|
| 131 | - { |
|
| 132 | - $context_label = Registry::elementFactory()->make($context)->label(); |
|
| 133 | - |
|
| 134 | - if (!$this->hasSource()) { |
|
| 135 | - return I18N::translate('%s not sourced', $context_label); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($this->hasSupportingDocument()) { |
|
| 139 | - return I18N::translate('%s sourced with a certificate', $context_label); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - return I18N::translate('%s sourced', $context_label); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Get an indicative value to order source statuses |
|
| 147 | - * |
|
| 148 | - * @return int |
|
| 149 | - */ |
|
| 150 | - public function order(): int |
|
| 151 | - { |
|
| 152 | - return ($this->hasSource() ? 1 : 0) * (1 + ($this->hasSupportingDocument() ? 1 : 0)); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Return an element combining properties of the current object with another SourceStatus. |
|
| 157 | - * Do not use the initial object anymore, it may not appropriately describe the status anymore. |
|
| 158 | - * |
|
| 159 | - * @template T of SourceStatus |
|
| 160 | - * @param T $other |
|
| 161 | - * @return $this|T |
|
| 162 | - */ |
|
| 163 | - public function combineWith(SourceStatus $other) |
|
| 164 | - { |
|
| 165 | - $this->addHasSource($other->hasSource()); |
|
| 166 | - $this->addHasSupportingDocument($other->hasSource()); |
|
| 167 | - return $this; |
|
| 168 | - } |
|
| 25 | + /** |
|
| 26 | + * @var boolean $source_exist |
|
| 27 | + */ |
|
| 28 | + private $source_exist = false; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var boolean $has_document |
|
| 32 | + */ |
|
| 33 | + private $has_document = false; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Return whether the SourceStatus object contains relevant data. |
|
| 37 | + * |
|
| 38 | + * @return bool |
|
| 39 | + */ |
|
| 40 | + public function isSet(): bool |
|
| 41 | + { |
|
| 42 | + return true; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Returns whether the record contains a source. |
|
| 47 | + * |
|
| 48 | + * @return bool |
|
| 49 | + */ |
|
| 50 | + public function hasSource(): bool |
|
| 51 | + { |
|
| 52 | + return $this->source_exist; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Set whether the record contains a source. |
|
| 57 | + * |
|
| 58 | + * @param bool $source_exist |
|
| 59 | + * @return $this |
|
| 60 | + */ |
|
| 61 | + public function setHasSource(bool $source_exist): self |
|
| 62 | + { |
|
| 63 | + $this->source_exist = $source_exist; |
|
| 64 | + return $this; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Combine whether the record contains a source with the previous status. |
|
| 69 | + * |
|
| 70 | + * @param bool $source_exist |
|
| 71 | + * @return $this |
|
| 72 | + */ |
|
| 73 | + public function addHasSource(bool $source_exist): self |
|
| 74 | + { |
|
| 75 | + $this->source_exist = $this->source_exist || $source_exist; |
|
| 76 | + return $this; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Return whether the source citation is supported by a document. |
|
| 81 | + * Uses the _ACT tag from the MyArtJaub Certificates module. |
|
| 82 | + * |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + public function hasSupportingDocument(): bool |
|
| 86 | + { |
|
| 87 | + return $this->hasSource() && $this->has_document; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Set whether the source citation is supported by a document. |
|
| 92 | + * |
|
| 93 | + * @param bool $has_document |
|
| 94 | + * @return $this |
|
| 95 | + */ |
|
| 96 | + public function setHasSupportingDocument(bool $has_document): self |
|
| 97 | + { |
|
| 98 | + $this->has_document = $has_document; |
|
| 99 | + return $this; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Combine whether the source citation is supported by a document with the previous status. |
|
| 104 | + * |
|
| 105 | + * @param bool $has_document |
|
| 106 | + * @return $this |
|
| 107 | + */ |
|
| 108 | + public function addHasSupportingDocument(bool $has_document): self |
|
| 109 | + { |
|
| 110 | + $this->has_document = $this->has_document || $has_document; |
|
| 111 | + return $this; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Check whether all possible criteria for defining a sourced element have been met. |
|
| 116 | + * |
|
| 117 | + * @return bool |
|
| 118 | + */ |
|
| 119 | + public function isFullySourced(): bool |
|
| 120 | + { |
|
| 121 | + return $this->hasSupportingDocument(); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Get the label to display to describe the source status. |
|
| 126 | + * |
|
| 127 | + * @param string $context |
|
| 128 | + * @return string |
|
| 129 | + */ |
|
| 130 | + public function label(string $context): string |
|
| 131 | + { |
|
| 132 | + $context_label = Registry::elementFactory()->make($context)->label(); |
|
| 133 | + |
|
| 134 | + if (!$this->hasSource()) { |
|
| 135 | + return I18N::translate('%s not sourced', $context_label); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($this->hasSupportingDocument()) { |
|
| 139 | + return I18N::translate('%s sourced with a certificate', $context_label); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + return I18N::translate('%s sourced', $context_label); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Get an indicative value to order source statuses |
|
| 147 | + * |
|
| 148 | + * @return int |
|
| 149 | + */ |
|
| 150 | + public function order(): int |
|
| 151 | + { |
|
| 152 | + return ($this->hasSource() ? 1 : 0) * (1 + ($this->hasSupportingDocument() ? 1 : 0)); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Return an element combining properties of the current object with another SourceStatus. |
|
| 157 | + * Do not use the initial object anymore, it may not appropriately describe the status anymore. |
|
| 158 | + * |
|
| 159 | + * @template T of SourceStatus |
|
| 160 | + * @param T $other |
|
| 161 | + * @return $this|T |
|
| 162 | + */ |
|
| 163 | + public function combineWith(SourceStatus $other) |
|
| 164 | + { |
|
| 165 | + $this->addHasSource($other->hasSource()); |
|
| 166 | + $this->addHasSupportingDocument($other->hasSource()); |
|
| 167 | + return $this; |
|
| 168 | + } |
|
| 169 | 169 | } |
@@ -149,7 +149,7 @@ |
||
| 149 | 149 | */ |
| 150 | 150 | public function order(): int |
| 151 | 151 | { |
| 152 | - return ($this->hasSource() ? 1 : 0) * (1 + ($this->hasSupportingDocument() ? 1 : 0)); |
|
| 152 | + return ($this->hasSource() ? 1 : 0) * (1 + ($this->hasSupportingDocument() ? 1 : 0)); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -228,7 +228,7 @@ |
||
| 228 | 228 | public function order(): int |
| 229 | 229 | { |
| 230 | 230 | return ($this->factHasDate() ? 1 : 0) * ($this->hasSource() ? 1 : -1) * |
| 231 | - ( 1 + ($this->factHasPreciseDate() ? 1 : 0) * (1 + |
|
| 231 | + (1 + ($this->factHasPreciseDate() ? 1 : 0) * (1 + |
|
| 232 | 232 | 0b010 * ($this->sourceMatchesFactDate() ? 1 : 0) + |
| 233 | 233 | 0b100 * ($this->hasSupportingDocument() ? 1 : 0) |
| 234 | 234 | ) |
@@ -22,233 +22,233 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class FactSourceStatus extends SourceStatus |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var boolean $has_date |
|
| 27 | - */ |
|
| 28 | - private $has_date = false; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var boolean $has_precise_date |
|
| 32 | - */ |
|
| 33 | - private $has_precise_date = false; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var boolean $has_source_date |
|
| 37 | - */ |
|
| 38 | - private $has_source_date = false; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var boolean $source_date_match |
|
| 42 | - */ |
|
| 43 | - private $source_date_match = false; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Return whether the fact is dated. |
|
| 47 | - * |
|
| 48 | - * @return bool |
|
| 49 | - */ |
|
| 50 | - public function factHasDate(): bool |
|
| 51 | - { |
|
| 52 | - return $this->has_date; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Set whether the fact is dated. |
|
| 57 | - * |
|
| 58 | - * @param bool $has_date |
|
| 59 | - * @return $this |
|
| 60 | - */ |
|
| 61 | - public function setFactHasDate(bool $has_date): self |
|
| 62 | - { |
|
| 63 | - $this->has_date = $has_date; |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Combinate whether the fact is dated with the previous status. |
|
| 69 | - * |
|
| 70 | - * @param bool $has_date |
|
| 71 | - * @return $this |
|
| 72 | - */ |
|
| 73 | - public function addFactHasDate(bool $has_date): self |
|
| 74 | - { |
|
| 75 | - $this->has_date = $this->has_date || $has_date; |
|
| 76 | - return $this; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Return whether the fact is dated with a precise day. |
|
| 81 | - * Any date modifier will be considered as not precise. |
|
| 82 | - * A month or year will be considered as not precise. |
|
| 83 | - * |
|
| 84 | - * @return bool |
|
| 85 | - */ |
|
| 86 | - public function factHasPreciseDate(): bool |
|
| 87 | - { |
|
| 88 | - return $this->has_date && $this->has_precise_date; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Set whather the fact is dated with a precise day. |
|
| 93 | - * |
|
| 94 | - * @param bool $has_precise_date |
|
| 95 | - * @return $this |
|
| 96 | - */ |
|
| 97 | - public function setFactHasPreciseDate(bool $has_precise_date): self |
|
| 98 | - { |
|
| 99 | - $this->has_precise_date = $has_precise_date; |
|
| 100 | - return $this; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Combine whether the fact is dated with a precise day. |
|
| 105 | - * |
|
| 106 | - * @param bool $has_precise_date |
|
| 107 | - * @return $this |
|
| 108 | - */ |
|
| 109 | - public function addFactHasPreciseDate(bool $has_precise_date): self |
|
| 110 | - { |
|
| 111 | - $this->has_precise_date = $this->has_precise_date || $has_precise_date; |
|
| 112 | - return $this; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Return whether the source citation is dated. |
|
| 117 | - * |
|
| 118 | - * @return bool |
|
| 119 | - */ |
|
| 120 | - public function sourceHasDate(): bool |
|
| 121 | - { |
|
| 122 | - return $this->has_source_date; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Set whether the source citation is dated. |
|
| 127 | - * |
|
| 128 | - * @param bool $has_source_date |
|
| 129 | - * @return $this |
|
| 130 | - */ |
|
| 131 | - public function setSourceHasDate(bool $has_source_date): self |
|
| 132 | - { |
|
| 133 | - $this->has_source_date = $has_source_date; |
|
| 134 | - return $this; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Combine whether the source citation is dated with the previous status. |
|
| 139 | - * |
|
| 140 | - * @param bool $has_source_date |
|
| 141 | - * @return $this |
|
| 142 | - */ |
|
| 143 | - public function addSourceHasDate(bool $has_source_date): self |
|
| 144 | - { |
|
| 145 | - $this->has_source_date = $this->has_source_date || $has_source_date; |
|
| 146 | - return $this; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Return whether the source citation date is close to the fact date. |
|
| 151 | - * |
|
| 152 | - * @return bool |
|
| 153 | - */ |
|
| 154 | - public function sourceMatchesFactDate(): bool |
|
| 155 | - { |
|
| 156 | - return $this->has_precise_date && $this->has_source_date && $this->source_date_match; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Set whether the source citation date is close to the fact date. |
|
| 161 | - * |
|
| 162 | - * @param bool $source_date_match |
|
| 163 | - * @return $this |
|
| 164 | - */ |
|
| 165 | - public function setSourceMatchesFactDate(bool $source_date_match): self |
|
| 166 | - { |
|
| 167 | - $this->source_date_match = $source_date_match; |
|
| 168 | - return $this; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Combine whether the source citation date is close to the fact date with the previous status. |
|
| 173 | - * |
|
| 174 | - * @param bool $source_date_match |
|
| 175 | - * @return $this |
|
| 176 | - */ |
|
| 177 | - public function addSourceMatchesFactDate(bool $source_date_match): self |
|
| 178 | - { |
|
| 179 | - $this->source_date_match = $this->source_date_match || $source_date_match; |
|
| 180 | - return $this; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * {@inheritDoc} |
|
| 185 | - * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::isFullySourced() |
|
| 186 | - */ |
|
| 187 | - public function isFullySourced(): bool |
|
| 188 | - { |
|
| 189 | - return parent::isFullySourced() && $this->sourceMatchesFactDate(); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * {@inheritDoc} |
|
| 194 | - * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::label() |
|
| 195 | - */ |
|
| 196 | - public function label(string $context): string |
|
| 197 | - { |
|
| 198 | - $context_label = Registry::elementFactory()->make($context)->label(); |
|
| 199 | - |
|
| 200 | - if ($this->factHasPreciseDate()) { |
|
| 201 | - if ($this->hasSource()) { |
|
| 202 | - if ($this->hasSupportingDocument()) { |
|
| 203 | - if ($this->sourceMatchesFactDate()) { |
|
| 204 | - return I18N::translate('%s sourced with exact certificate', $context_label); |
|
| 205 | - } else { |
|
| 206 | - return I18N::translate('%s sourced with a certificate', $context_label); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - if ($this->sourceMatchesFactDate()) { |
|
| 211 | - return I18N::translate('%s precisely sourced', $context_label); |
|
| 212 | - } |
|
| 213 | - return I18N::translate('%s sourced', $context_label); |
|
| 214 | - } |
|
| 215 | - return I18N::translate('%s not sourced', $context_label); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if ($this->factHasDate()) { |
|
| 219 | - return I18N::translate('%s not precise', $context_label); |
|
| 220 | - } |
|
| 221 | - return I18N::translate('%s not found', $context_label); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * {@inheritDoc} |
|
| 226 | - * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::order() |
|
| 227 | - */ |
|
| 228 | - public function order(): int |
|
| 229 | - { |
|
| 230 | - return ($this->factHasDate() ? 1 : 0) * ($this->hasSource() ? 1 : -1) * |
|
| 231 | - ( 1 + ($this->factHasPreciseDate() ? 1 : 0) * (1 + |
|
| 232 | - 0b010 * ($this->sourceMatchesFactDate() ? 1 : 0) + |
|
| 233 | - 0b100 * ($this->hasSupportingDocument() ? 1 : 0) |
|
| 234 | - ) |
|
| 235 | - ); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * {@inheritDoc} |
|
| 240 | - * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::combineWith() |
|
| 241 | - */ |
|
| 242 | - public function combineWith(SourceStatus $other) |
|
| 243 | - { |
|
| 244 | - if ($other instanceof FactSourceStatus) { |
|
| 245 | - $this->addFactHasDate($other->factHasDate()); |
|
| 246 | - $this->addFactHasPreciseDate($other->factHasPreciseDate()); |
|
| 247 | - $this->addSourceHasDate($other->sourceHasDate()); |
|
| 248 | - $this->addSourceMatchesFactDate($other->sourceMatchesFactDate()); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - parent::combineWith($other); |
|
| 252 | - return $this; |
|
| 253 | - } |
|
| 25 | + /** |
|
| 26 | + * @var boolean $has_date |
|
| 27 | + */ |
|
| 28 | + private $has_date = false; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var boolean $has_precise_date |
|
| 32 | + */ |
|
| 33 | + private $has_precise_date = false; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var boolean $has_source_date |
|
| 37 | + */ |
|
| 38 | + private $has_source_date = false; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var boolean $source_date_match |
|
| 42 | + */ |
|
| 43 | + private $source_date_match = false; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Return whether the fact is dated. |
|
| 47 | + * |
|
| 48 | + * @return bool |
|
| 49 | + */ |
|
| 50 | + public function factHasDate(): bool |
|
| 51 | + { |
|
| 52 | + return $this->has_date; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Set whether the fact is dated. |
|
| 57 | + * |
|
| 58 | + * @param bool $has_date |
|
| 59 | + * @return $this |
|
| 60 | + */ |
|
| 61 | + public function setFactHasDate(bool $has_date): self |
|
| 62 | + { |
|
| 63 | + $this->has_date = $has_date; |
|
| 64 | + return $this; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Combinate whether the fact is dated with the previous status. |
|
| 69 | + * |
|
| 70 | + * @param bool $has_date |
|
| 71 | + * @return $this |
|
| 72 | + */ |
|
| 73 | + public function addFactHasDate(bool $has_date): self |
|
| 74 | + { |
|
| 75 | + $this->has_date = $this->has_date || $has_date; |
|
| 76 | + return $this; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Return whether the fact is dated with a precise day. |
|
| 81 | + * Any date modifier will be considered as not precise. |
|
| 82 | + * A month or year will be considered as not precise. |
|
| 83 | + * |
|
| 84 | + * @return bool |
|
| 85 | + */ |
|
| 86 | + public function factHasPreciseDate(): bool |
|
| 87 | + { |
|
| 88 | + return $this->has_date && $this->has_precise_date; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Set whather the fact is dated with a precise day. |
|
| 93 | + * |
|
| 94 | + * @param bool $has_precise_date |
|
| 95 | + * @return $this |
|
| 96 | + */ |
|
| 97 | + public function setFactHasPreciseDate(bool $has_precise_date): self |
|
| 98 | + { |
|
| 99 | + $this->has_precise_date = $has_precise_date; |
|
| 100 | + return $this; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Combine whether the fact is dated with a precise day. |
|
| 105 | + * |
|
| 106 | + * @param bool $has_precise_date |
|
| 107 | + * @return $this |
|
| 108 | + */ |
|
| 109 | + public function addFactHasPreciseDate(bool $has_precise_date): self |
|
| 110 | + { |
|
| 111 | + $this->has_precise_date = $this->has_precise_date || $has_precise_date; |
|
| 112 | + return $this; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Return whether the source citation is dated. |
|
| 117 | + * |
|
| 118 | + * @return bool |
|
| 119 | + */ |
|
| 120 | + public function sourceHasDate(): bool |
|
| 121 | + { |
|
| 122 | + return $this->has_source_date; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Set whether the source citation is dated. |
|
| 127 | + * |
|
| 128 | + * @param bool $has_source_date |
|
| 129 | + * @return $this |
|
| 130 | + */ |
|
| 131 | + public function setSourceHasDate(bool $has_source_date): self |
|
| 132 | + { |
|
| 133 | + $this->has_source_date = $has_source_date; |
|
| 134 | + return $this; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Combine whether the source citation is dated with the previous status. |
|
| 139 | + * |
|
| 140 | + * @param bool $has_source_date |
|
| 141 | + * @return $this |
|
| 142 | + */ |
|
| 143 | + public function addSourceHasDate(bool $has_source_date): self |
|
| 144 | + { |
|
| 145 | + $this->has_source_date = $this->has_source_date || $has_source_date; |
|
| 146 | + return $this; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Return whether the source citation date is close to the fact date. |
|
| 151 | + * |
|
| 152 | + * @return bool |
|
| 153 | + */ |
|
| 154 | + public function sourceMatchesFactDate(): bool |
|
| 155 | + { |
|
| 156 | + return $this->has_precise_date && $this->has_source_date && $this->source_date_match; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Set whether the source citation date is close to the fact date. |
|
| 161 | + * |
|
| 162 | + * @param bool $source_date_match |
|
| 163 | + * @return $this |
|
| 164 | + */ |
|
| 165 | + public function setSourceMatchesFactDate(bool $source_date_match): self |
|
| 166 | + { |
|
| 167 | + $this->source_date_match = $source_date_match; |
|
| 168 | + return $this; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Combine whether the source citation date is close to the fact date with the previous status. |
|
| 173 | + * |
|
| 174 | + * @param bool $source_date_match |
|
| 175 | + * @return $this |
|
| 176 | + */ |
|
| 177 | + public function addSourceMatchesFactDate(bool $source_date_match): self |
|
| 178 | + { |
|
| 179 | + $this->source_date_match = $this->source_date_match || $source_date_match; |
|
| 180 | + return $this; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * {@inheritDoc} |
|
| 185 | + * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::isFullySourced() |
|
| 186 | + */ |
|
| 187 | + public function isFullySourced(): bool |
|
| 188 | + { |
|
| 189 | + return parent::isFullySourced() && $this->sourceMatchesFactDate(); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * {@inheritDoc} |
|
| 194 | + * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::label() |
|
| 195 | + */ |
|
| 196 | + public function label(string $context): string |
|
| 197 | + { |
|
| 198 | + $context_label = Registry::elementFactory()->make($context)->label(); |
|
| 199 | + |
|
| 200 | + if ($this->factHasPreciseDate()) { |
|
| 201 | + if ($this->hasSource()) { |
|
| 202 | + if ($this->hasSupportingDocument()) { |
|
| 203 | + if ($this->sourceMatchesFactDate()) { |
|
| 204 | + return I18N::translate('%s sourced with exact certificate', $context_label); |
|
| 205 | + } else { |
|
| 206 | + return I18N::translate('%s sourced with a certificate', $context_label); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + if ($this->sourceMatchesFactDate()) { |
|
| 211 | + return I18N::translate('%s precisely sourced', $context_label); |
|
| 212 | + } |
|
| 213 | + return I18N::translate('%s sourced', $context_label); |
|
| 214 | + } |
|
| 215 | + return I18N::translate('%s not sourced', $context_label); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if ($this->factHasDate()) { |
|
| 219 | + return I18N::translate('%s not precise', $context_label); |
|
| 220 | + } |
|
| 221 | + return I18N::translate('%s not found', $context_label); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * {@inheritDoc} |
|
| 226 | + * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::order() |
|
| 227 | + */ |
|
| 228 | + public function order(): int |
|
| 229 | + { |
|
| 230 | + return ($this->factHasDate() ? 1 : 0) * ($this->hasSource() ? 1 : -1) * |
|
| 231 | + ( 1 + ($this->factHasPreciseDate() ? 1 : 0) * (1 + |
|
| 232 | + 0b010 * ($this->sourceMatchesFactDate() ? 1 : 0) + |
|
| 233 | + 0b100 * ($this->hasSupportingDocument() ? 1 : 0) |
|
| 234 | + ) |
|
| 235 | + ); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * {@inheritDoc} |
|
| 240 | + * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::combineWith() |
|
| 241 | + */ |
|
| 242 | + public function combineWith(SourceStatus $other) |
|
| 243 | + { |
|
| 244 | + if ($other instanceof FactSourceStatus) { |
|
| 245 | + $this->addFactHasDate($other->factHasDate()); |
|
| 246 | + $this->addFactHasPreciseDate($other->factHasPreciseDate()); |
|
| 247 | + $this->addSourceHasDate($other->sourceHasDate()); |
|
| 248 | + $this->addSourceMatchesFactDate($other->sourceMatchesFactDate()); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + parent::combineWith($other); |
|
| 252 | + return $this; |
|
| 253 | + } |
|
| 254 | 254 | } |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class NullFactSourceStatus extends FactSourceStatus |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * {@inheritDoc} |
|
| 24 | - * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::isSet() |
|
| 25 | - */ |
|
| 26 | - public function isSet(): bool |
|
| 27 | - { |
|
| 28 | - return false; |
|
| 29 | - } |
|
| 22 | + /** |
|
| 23 | + * {@inheritDoc} |
|
| 24 | + * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\SourceStatus::isSet() |
|
| 25 | + */ |
|
| 26 | + public function isSet(): bool |
|
| 27 | + { |
|
| 28 | + return false; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * {@inheritDoc} |
|
| 33 | - * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\FactSourceStatus::combineWith() |
|
| 34 | - */ |
|
| 35 | - public function combineWith(SourceStatus $other) |
|
| 36 | - { |
|
| 37 | - return $other; |
|
| 38 | - } |
|
| 31 | + /** |
|
| 32 | + * {@inheritDoc} |
|
| 33 | + * @see \MyArtJaub\Webtrees\Module\IsSourced\Data\FactSourceStatus::combineWith() |
|
| 34 | + */ |
|
| 35 | + public function combineWith(SourceStatus $other) |
|
| 36 | + { |
|
| 37 | + return $other; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function headContent(): string |
| 77 | 77 | { |
| 78 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 78 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function bodyContent(): string |
| 86 | 86 | { |
| 87 | - return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>'; |
|
| 87 | + return '<script src="'.$this->assetUrl('js/issourced.min.js').'"></script>'; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | $source_status_service = app(SourceStatusService::class); |
| 107 | 107 | |
| 108 | 108 | $spouse_families_status = $individual->spouseFamilies()->map( |
| 109 | - function (Family $sfamily) use ($source_status_service): array { |
|
| 110 | - return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)]; |
|
| 109 | + function(Family $sfamily) use ($source_status_service): array { |
|
| 110 | + return [$sfamily, $source_status_service->sourceStatusForMarriage($sfamily)]; |
|
| 111 | 111 | } |
| 112 | - )->filter(function (array $item): bool { |
|
| 112 | + )->filter(function(array $item): bool { |
|
| 113 | 113 | return $item[1]->isSet(); |
| 114 | 114 | }); |
| 115 | 115 | |
| 116 | - return view($this->name() . '::sidebar/content', [ |
|
| 116 | + return view($this->name().'::sidebar/content', [ |
|
| 117 | 117 | 'module_name' => $this->name(), |
| 118 | 118 | 'individual' => $individual, |
| 119 | 119 | 'source_status_individual' => $source_status_service->sourceStatusForRecord($individual), |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | public function listSubscribedHooks(): array |
| 131 | 131 | { |
| 132 | 132 | return [ |
| 133 | - app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]), |
|
| 134 | - app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ]) |
|
| 133 | + app()->makeWith(IsSourcedStatusHook::class, ['module' => $this]), |
|
| 134 | + app()->makeWith(IsSourcedStatusColumnsHook::class, ['module' => $this]) |
|
| 135 | 135 | ]; |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -33,105 +33,105 @@ |
||
| 33 | 33 | * IsSourced Module |
| 34 | 34 | */ |
| 35 | 35 | class IsSourcedModule extends AbstractModule implements |
| 36 | - ModuleMyArtJaubInterface, |
|
| 37 | - ModuleGlobalInterface, |
|
| 38 | - ModuleSidebarInterface, |
|
| 39 | - ModuleHookSubscriberInterface |
|
| 36 | + ModuleMyArtJaubInterface, |
|
| 37 | + ModuleGlobalInterface, |
|
| 38 | + ModuleSidebarInterface, |
|
| 39 | + ModuleHookSubscriberInterface |
|
| 40 | 40 | { |
| 41 | - use ModuleMyArtJaubTrait; |
|
| 42 | - use ModuleGlobalTrait; |
|
| 43 | - use ModuleSidebarTrait; |
|
| 41 | + use ModuleMyArtJaubTrait; |
|
| 42 | + use ModuleGlobalTrait; |
|
| 43 | + use ModuleSidebarTrait; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * {@inheritDoc} |
|
| 47 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 48 | - */ |
|
| 49 | - public function title(): string |
|
| 50 | - { |
|
| 51 | - return I18N::translate('Sourced events'); |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * {@inheritDoc} |
|
| 47 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 48 | + */ |
|
| 49 | + public function title(): string |
|
| 50 | + { |
|
| 51 | + return I18N::translate('Sourced events'); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * {@inheritDoc} |
|
| 56 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 57 | - */ |
|
| 58 | - public function description(): string |
|
| 59 | - { |
|
| 60 | - return I18N::translate('Indicate if events related to an record are sourced.'); |
|
| 61 | - } |
|
| 54 | + /** |
|
| 55 | + * {@inheritDoc} |
|
| 56 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 57 | + */ |
|
| 58 | + public function description(): string |
|
| 59 | + { |
|
| 60 | + return I18N::translate('Indicate if events related to an record are sourced.'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * {@inheritDoc} |
|
| 65 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 66 | - */ |
|
| 67 | - public function customModuleVersion(): string |
|
| 68 | - { |
|
| 69 | - return '2.1.8-v.1'; |
|
| 70 | - } |
|
| 63 | + /** |
|
| 64 | + * {@inheritDoc} |
|
| 65 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 66 | + */ |
|
| 67 | + public function customModuleVersion(): string |
|
| 68 | + { |
|
| 69 | + return '2.1.8-v.1'; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * {@inheritDoc} |
|
| 74 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
| 75 | - */ |
|
| 76 | - public function headContent(): string |
|
| 77 | - { |
|
| 78 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 79 | - } |
|
| 72 | + /** |
|
| 73 | + * {@inheritDoc} |
|
| 74 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
| 75 | + */ |
|
| 76 | + public function headContent(): string |
|
| 77 | + { |
|
| 78 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * {@inheritDoc} |
|
| 83 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
| 84 | - */ |
|
| 85 | - public function bodyContent(): string |
|
| 86 | - { |
|
| 87 | - return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>'; |
|
| 88 | - } |
|
| 81 | + /** |
|
| 82 | + * {@inheritDoc} |
|
| 83 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
| 84 | + */ |
|
| 85 | + public function bodyContent(): string |
|
| 86 | + { |
|
| 87 | + return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>'; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * {@inheritDoc} |
|
| 92 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() |
|
| 93 | - */ |
|
| 94 | - public function hasSidebarContent(Individual $individual): bool |
|
| 95 | - { |
|
| 96 | - return true; |
|
| 97 | - } |
|
| 90 | + /** |
|
| 91 | + * {@inheritDoc} |
|
| 92 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() |
|
| 93 | + */ |
|
| 94 | + public function hasSidebarContent(Individual $individual): bool |
|
| 95 | + { |
|
| 96 | + return true; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * {@inheritDoc} |
|
| 101 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent() |
|
| 102 | - */ |
|
| 103 | - public function getSidebarContent(Individual $individual): string |
|
| 104 | - { |
|
| 105 | - /** @var SourceStatusService $source_status_service */ |
|
| 106 | - $source_status_service = app(SourceStatusService::class); |
|
| 99 | + /** |
|
| 100 | + * {@inheritDoc} |
|
| 101 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent() |
|
| 102 | + */ |
|
| 103 | + public function getSidebarContent(Individual $individual): string |
|
| 104 | + { |
|
| 105 | + /** @var SourceStatusService $source_status_service */ |
|
| 106 | + $source_status_service = app(SourceStatusService::class); |
|
| 107 | 107 | |
| 108 | - $spouse_families_status = $individual->spouseFamilies()->map( |
|
| 109 | - function (Family $sfamily) use ($source_status_service): array { |
|
| 110 | - return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)]; |
|
| 111 | - } |
|
| 112 | - )->filter(function (array $item): bool { |
|
| 113 | - return $item[1]->isSet(); |
|
| 114 | - }); |
|
| 108 | + $spouse_families_status = $individual->spouseFamilies()->map( |
|
| 109 | + function (Family $sfamily) use ($source_status_service): array { |
|
| 110 | + return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)]; |
|
| 111 | + } |
|
| 112 | + )->filter(function (array $item): bool { |
|
| 113 | + return $item[1]->isSet(); |
|
| 114 | + }); |
|
| 115 | 115 | |
| 116 | - return view($this->name() . '::sidebar/content', [ |
|
| 117 | - 'module_name' => $this->name(), |
|
| 118 | - 'individual' => $individual, |
|
| 119 | - 'source_status_individual' => $source_status_service->sourceStatusForRecord($individual), |
|
| 120 | - 'source_status_birth' => $source_status_service->sourceStatusForBirth($individual), |
|
| 121 | - 'source_status_marriages' => $spouse_families_status, |
|
| 122 | - 'source_status_death' => $source_status_service->sourceStatusForDeath($individual) |
|
| 123 | - ]); |
|
| 124 | - } |
|
| 116 | + return view($this->name() . '::sidebar/content', [ |
|
| 117 | + 'module_name' => $this->name(), |
|
| 118 | + 'individual' => $individual, |
|
| 119 | + 'source_status_individual' => $source_status_service->sourceStatusForRecord($individual), |
|
| 120 | + 'source_status_birth' => $source_status_service->sourceStatusForBirth($individual), |
|
| 121 | + 'source_status_marriages' => $spouse_families_status, |
|
| 122 | + 'source_status_death' => $source_status_service->sourceStatusForDeath($individual) |
|
| 123 | + ]); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * {@inheritDoc} |
|
| 128 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
| 129 | - */ |
|
| 130 | - public function listSubscribedHooks(): array |
|
| 131 | - { |
|
| 132 | - return [ |
|
| 133 | - app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]), |
|
| 134 | - app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ]) |
|
| 135 | - ]; |
|
| 136 | - } |
|
| 126 | + /** |
|
| 127 | + * {@inheritDoc} |
|
| 128 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
| 129 | + */ |
|
| 130 | + public function listSubscribedHooks(): array |
|
| 131 | + { |
|
| 132 | + return [ |
|
| 133 | + app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]), |
|
| 134 | + app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ]) |
|
| 135 | + ]; |
|
| 136 | + } |
|
| 137 | 137 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | // How to update the database schema for this module |
| 56 | 56 | private const SCHEMA_TARGET_VERSION = 2; |
| 57 | 57 | private const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
| 58 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 58 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * {@inheritDoc} |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function loadRoutes(Map $router): void |
| 98 | 98 | { |
| 99 | - $router->attach('', '', static function (Map $router): void { |
|
| 99 | + $router->attach('', '', static function(Map $router): void { |
|
| 100 | 100 | |
| 101 | - $router->attach('', '/module-maj/hooks', static function (Map $router): void { |
|
| 101 | + $router->attach('', '/module-maj/hooks', static function(Map $router): void { |
|
| 102 | 102 | |
| 103 | - $router->attach('', '/config/admin', static function (Map $router): void { |
|
| 103 | + $router->attach('', '/config/admin', static function(Map $router): void { |
|
| 104 | 104 | |
| 105 | 105 | $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
| 106 | 106 | $router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class); |
@@ -42,106 +42,106 @@ |
||
| 42 | 42 | * Provide entry points to extend core webtrees code. |
| 43 | 43 | */ |
| 44 | 44 | class HooksModule extends AbstractModule implements |
| 45 | - ModuleMyArtJaubInterface, |
|
| 46 | - ModuleConfigInterface, |
|
| 47 | - ModuleHookSubscriberInterface |
|
| 45 | + ModuleMyArtJaubInterface, |
|
| 46 | + ModuleConfigInterface, |
|
| 47 | + ModuleHookSubscriberInterface |
|
| 48 | 48 | { |
| 49 | - use ModuleMyArtJaubTrait { |
|
| 50 | - boot as traitBoot; |
|
| 51 | - } |
|
| 52 | - use ModuleConfigTrait; |
|
| 53 | - |
|
| 54 | - // How to update the database schema for this module |
|
| 55 | - private const SCHEMA_TARGET_VERSION = 2; |
|
| 56 | - private const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
| 57 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * {@inheritDoc} |
|
| 61 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 62 | - */ |
|
| 63 | - public function title(): string |
|
| 64 | - { |
|
| 65 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * {@inheritDoc} |
|
| 70 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 71 | - */ |
|
| 72 | - public function description(): string |
|
| 73 | - { |
|
| 74 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * {@inheritDoc} |
|
| 79 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
| 80 | - */ |
|
| 81 | - public function boot(): void |
|
| 82 | - { |
|
| 83 | - $this->traitBoot(); |
|
| 84 | - app()->bind(HookServiceInterface::class, HookService::class); |
|
| 85 | - app(MigrationService::class)->updateSchema( |
|
| 86 | - self::SCHEMA_MIGRATION_PREFIX, |
|
| 87 | - self::SCHEMA_SETTING_NAME, |
|
| 88 | - self::SCHEMA_TARGET_VERSION |
|
| 89 | - ); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * {@inheritDoc} |
|
| 94 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 95 | - */ |
|
| 96 | - public function loadRoutes(Map $router): void |
|
| 97 | - { |
|
| 98 | - $router->attach('', '', static function (Map $router): void { |
|
| 99 | - |
|
| 100 | - $router->attach('', '/module-maj/hooks', static function (Map $router): void { |
|
| 101 | - |
|
| 102 | - $router->attach('', '/config/admin', static function (Map $router): void { |
|
| 103 | - |
|
| 104 | - $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
| 105 | - $router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class); |
|
| 106 | - $router->post(ModulesHooksAction::class, '/{hook_name}', ModulesHooksAction::class); |
|
| 107 | - }); |
|
| 108 | - }); |
|
| 109 | - }); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * {@inheritDoc} |
|
| 114 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 115 | - */ |
|
| 116 | - public function customModuleVersion(): string |
|
| 117 | - { |
|
| 118 | - return '2.1.6-v.1'; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * {@inheritDoc} |
|
| 123 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 124 | - */ |
|
| 125 | - public function getConfigLink(): string |
|
| 126 | - { |
|
| 127 | - return route(AdminConfigPage::class); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * {@inheritDoc} |
|
| 132 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
| 133 | - */ |
|
| 134 | - public function listSubscribedHooks(): array |
|
| 135 | - { |
|
| 136 | - return [ |
|
| 137 | - app()->makeWith(FactSourceTextExtenderCollector::class, ['module' => $this]), |
|
| 138 | - app()->makeWith(FamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 139 | - app()->makeWith(IndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 140 | - app()->makeWith(NameAccordionExtenderCollector::class, ['module' => $this]), |
|
| 141 | - app()->makeWith(RecordNameTextExtenderCollector::class, ['module' => $this]), |
|
| 142 | - app()->makeWith(SosaFamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 143 | - app()->makeWith(SosaIndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 144 | - app()->makeWith(SosaMissingDatatablesExtenderCollector::class, ['module' => $this]) |
|
| 145 | - ]; |
|
| 146 | - } |
|
| 49 | + use ModuleMyArtJaubTrait { |
|
| 50 | + boot as traitBoot; |
|
| 51 | + } |
|
| 52 | + use ModuleConfigTrait; |
|
| 53 | + |
|
| 54 | + // How to update the database schema for this module |
|
| 55 | + private const SCHEMA_TARGET_VERSION = 2; |
|
| 56 | + private const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
| 57 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * {@inheritDoc} |
|
| 61 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
| 62 | + */ |
|
| 63 | + public function title(): string |
|
| 64 | + { |
|
| 65 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * {@inheritDoc} |
|
| 70 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
| 71 | + */ |
|
| 72 | + public function description(): string |
|
| 73 | + { |
|
| 74 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * {@inheritDoc} |
|
| 79 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
| 80 | + */ |
|
| 81 | + public function boot(): void |
|
| 82 | + { |
|
| 83 | + $this->traitBoot(); |
|
| 84 | + app()->bind(HookServiceInterface::class, HookService::class); |
|
| 85 | + app(MigrationService::class)->updateSchema( |
|
| 86 | + self::SCHEMA_MIGRATION_PREFIX, |
|
| 87 | + self::SCHEMA_SETTING_NAME, |
|
| 88 | + self::SCHEMA_TARGET_VERSION |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * {@inheritDoc} |
|
| 94 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
| 95 | + */ |
|
| 96 | + public function loadRoutes(Map $router): void |
|
| 97 | + { |
|
| 98 | + $router->attach('', '', static function (Map $router): void { |
|
| 99 | + |
|
| 100 | + $router->attach('', '/module-maj/hooks', static function (Map $router): void { |
|
| 101 | + |
|
| 102 | + $router->attach('', '/config/admin', static function (Map $router): void { |
|
| 103 | + |
|
| 104 | + $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
| 105 | + $router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class); |
|
| 106 | + $router->post(ModulesHooksAction::class, '/{hook_name}', ModulesHooksAction::class); |
|
| 107 | + }); |
|
| 108 | + }); |
|
| 109 | + }); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * {@inheritDoc} |
|
| 114 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
| 115 | + */ |
|
| 116 | + public function customModuleVersion(): string |
|
| 117 | + { |
|
| 118 | + return '2.1.6-v.1'; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * {@inheritDoc} |
|
| 123 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 124 | + */ |
|
| 125 | + public function getConfigLink(): string |
|
| 126 | + { |
|
| 127 | + return route(AdminConfigPage::class); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * {@inheritDoc} |
|
| 132 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
| 133 | + */ |
|
| 134 | + public function listSubscribedHooks(): array |
|
| 135 | + { |
|
| 136 | + return [ |
|
| 137 | + app()->makeWith(FactSourceTextExtenderCollector::class, ['module' => $this]), |
|
| 138 | + app()->makeWith(FamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 139 | + app()->makeWith(IndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 140 | + app()->makeWith(NameAccordionExtenderCollector::class, ['module' => $this]), |
|
| 141 | + app()->makeWith(RecordNameTextExtenderCollector::class, ['module' => $this]), |
|
| 142 | + app()->makeWith(SosaFamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 143 | + app()->makeWith(SosaIndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
| 144 | + app()->makeWith(SosaMissingDatatablesExtenderCollector::class, ['module' => $this]) |
|
| 145 | + ]; |
|
| 146 | + } |
|
| 147 | 147 | } |
@@ -27,52 +27,52 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class RecordNameTextExtenderCollector extends AbstractHookCollector implements RecordNameTextExtenderInterface |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * {@inheritDoc} |
|
| 32 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | - */ |
|
| 34 | - public function title(): string |
|
| 35 | - { |
|
| 36 | - return I18N::translate('Text extender for records’ name'); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritDoc} |
|
| 32 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | + */ |
|
| 34 | + public function title(): string |
|
| 35 | + { |
|
| 36 | + return I18N::translate('Text extender for records’ name'); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * {@inheritDoc} |
|
| 41 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | - */ |
|
| 43 | - public function description(): string |
|
| 44 | - { |
|
| 45 | - return I18N::translate('Extends the full name of GEDCOM records with additional text or icons.'); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | + */ |
|
| 43 | + public function description(): string |
|
| 44 | + { |
|
| 45 | + return I18N::translate('Extends the full name of GEDCOM records with additional text or icons.'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritDoc} |
|
| 50 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | - */ |
|
| 52 | - public function hookInterface(): string |
|
| 53 | - { |
|
| 54 | - return RecordNameTextExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return RecordNameTextExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
| 60 | - */ |
|
| 61 | - public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 62 | - { |
|
| 63 | - return $this->hooks() |
|
| 64 | - ->map(fn(RecordNameTextExtenderInterface $hook) => $hook->recordNamePrepend($record, $use_long, $size)) |
|
| 65 | - ->implode(''); |
|
| 66 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
| 60 | + */ |
|
| 61 | + public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 62 | + { |
|
| 63 | + return $this->hooks() |
|
| 64 | + ->map(fn(RecordNameTextExtenderInterface $hook) => $hook->recordNamePrepend($record, $use_long, $size)) |
|
| 65 | + ->implode(''); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * {@inheritDoc} |
|
| 70 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
| 71 | - */ |
|
| 72 | - public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 73 | - { |
|
| 74 | - return $this->hooks() |
|
| 75 | - ->map(fn(RecordNameTextExtenderInterface $hook) => $hook->recordNameAppend($record, $use_long, $size)) |
|
| 76 | - ->implode(''); |
|
| 77 | - } |
|
| 68 | + /** |
|
| 69 | + * {@inheritDoc} |
|
| 70 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
| 71 | + */ |
|
| 72 | + public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
| 73 | + { |
|
| 74 | + return $this->hooks() |
|
| 75 | + ->map(fn(RecordNameTextExtenderInterface $hook) => $hook->recordNameAppend($record, $use_long, $size)) |
|
| 76 | + ->implode(''); |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -27,41 +27,41 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class NameAccordionExtenderCollector extends AbstractHookCollector implements NameAccordionExtenderInterface |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * {@inheritDoc} |
|
| 32 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | - */ |
|
| 34 | - public function title(): string |
|
| 35 | - { |
|
| 36 | - return I18N::translate('Individual names accordion extender'); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritDoc} |
|
| 32 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | + */ |
|
| 34 | + public function title(): string |
|
| 35 | + { |
|
| 36 | + return I18N::translate('Individual names accordion extender'); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * {@inheritDoc} |
|
| 41 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | - */ |
|
| 43 | - public function description(): string |
|
| 44 | - { |
|
| 45 | - return I18N::translate('Extends the names accordion of on an individual’s page.'); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | + */ |
|
| 43 | + public function description(): string |
|
| 44 | + { |
|
| 45 | + return I18N::translate('Extends the names accordion of on an individual’s page.'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritDoc} |
|
| 50 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | - */ |
|
| 52 | - public function hookInterface(): string |
|
| 53 | - { |
|
| 54 | - return NameAccordionExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return NameAccordionExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard() |
|
| 60 | - */ |
|
| 61 | - public function accordionCard(Individual $individual): string |
|
| 62 | - { |
|
| 63 | - return $this->hooks() |
|
| 64 | - ->map(fn(NameAccordionExtenderInterface $hook) => $hook->accordionCard($individual)) |
|
| 65 | - ->implode(''); |
|
| 66 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard() |
|
| 60 | + */ |
|
| 61 | + public function accordionCard(Individual $individual): string |
|
| 62 | + { |
|
| 63 | + return $this->hooks() |
|
| 64 | + ->map(fn(NameAccordionExtenderInterface $hook) => $hook->accordionCard($individual)) |
|
| 65 | + ->implode(''); |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -29,38 +29,38 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class AdminConfigPage implements RequestHandlerInterface |
| 31 | 31 | { |
| 32 | - use ViewResponseTrait; |
|
| 32 | + use ViewResponseTrait; |
|
| 33 | 33 | |
| 34 | - private ?HooksModule $module; |
|
| 35 | - private HookService $hook_service; |
|
| 34 | + private ?HooksModule $module; |
|
| 35 | + private HookService $hook_service; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Constructor for AdminConfigPage Request Handler |
|
| 39 | - * |
|
| 40 | - * @param ModuleService $module_service |
|
| 41 | - * @param HookService $hook_service |
|
| 42 | - */ |
|
| 43 | - public function __construct(ModuleService $module_service, HookService $hook_service) |
|
| 44 | - { |
|
| 45 | - $this->module = $module_service->findByInterface(HooksModule::class)->first(); |
|
| 46 | - $this->hook_service = $hook_service; |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * Constructor for AdminConfigPage Request Handler |
|
| 39 | + * |
|
| 40 | + * @param ModuleService $module_service |
|
| 41 | + * @param HookService $hook_service |
|
| 42 | + */ |
|
| 43 | + public function __construct(ModuleService $module_service, HookService $hook_service) |
|
| 44 | + { |
|
| 45 | + $this->module = $module_service->findByInterface(HooksModule::class)->first(); |
|
| 46 | + $this->hook_service = $hook_service; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * {@inheritDoc} |
|
| 51 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 52 | - */ |
|
| 53 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 54 | - { |
|
| 55 | - $this->layout = 'layouts/administration'; |
|
| 49 | + /** |
|
| 50 | + * {@inheritDoc} |
|
| 51 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 52 | + */ |
|
| 53 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 54 | + { |
|
| 55 | + $this->layout = 'layouts/administration'; |
|
| 56 | 56 | |
| 57 | - if ($this->module === null) { |
|
| 58 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 59 | - } |
|
| 57 | + if ($this->module === null) { |
|
| 58 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
| 62 | - 'title' => $this->module->title(), |
|
| 63 | - 'hook_interfaces_list' => $this->hook_service->all(true) |
|
| 64 | - ]); |
|
| 65 | - } |
|
| 61 | + return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
| 62 | + 'title' => $this->module->title(), |
|
| 63 | + 'hook_interfaces_list' => $this->hook_service->all(true) |
|
| 64 | + ]); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
| 61 | + return $this->viewResponse($this->module->name().'::admin/config', [ |
|
| 62 | 62 | 'title' => $this->module->title(), |
| 63 | 63 | 'hook_interfaces_list' => $this->hook_service->all(true) |
| 64 | 64 | ]); |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | DB::schema()->drop('maj_hooks'); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - DB::schema()->create('maj_hook_order', static function (Blueprint $table): void { |
|
| 37 | + DB::schema()->create('maj_hook_order', static function(Blueprint $table): void { |
|
| 38 | 38 | $table->string('majho_module_name', 32); |
| 39 | 39 | $table->string('majho_hook_name', 64); |
| 40 | 40 | $table->integer('majho_hook_order')->nullable(); |
@@ -23,28 +23,28 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Migration1 implements MigrationInterface |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 29 | - */ |
|
| 30 | - public function upgrade(): void |
|
| 31 | - { |
|
| 32 | - $in_transaction = DB::connection()->getPdo()->inTransaction(); |
|
| 33 | - |
|
| 34 | - if (DB::schema()->hasTable('maj_hooks')) { |
|
| 35 | - DB::schema()->drop('maj_hooks'); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - DB::schema()->create('maj_hook_order', static function (Blueprint $table): void { |
|
| 39 | - $table->string('majho_module_name', 32); |
|
| 40 | - $table->string('majho_hook_name', 64); |
|
| 41 | - $table->integer('majho_hook_order')->nullable(); |
|
| 42 | - |
|
| 43 | - $table->primary(['majho_module_name', 'majho_hook_name']); |
|
| 44 | - }); |
|
| 45 | - |
|
| 46 | - if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
|
| 47 | - DB::connection()->beginTransaction(); |
|
| 48 | - } |
|
| 49 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 29 | + */ |
|
| 30 | + public function upgrade(): void |
|
| 31 | + { |
|
| 32 | + $in_transaction = DB::connection()->getPdo()->inTransaction(); |
|
| 33 | + |
|
| 34 | + if (DB::schema()->hasTable('maj_hooks')) { |
|
| 35 | + DB::schema()->drop('maj_hooks'); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + DB::schema()->create('maj_hook_order', static function (Blueprint $table): void { |
|
| 39 | + $table->string('majho_module_name', 32); |
|
| 40 | + $table->string('majho_hook_name', 64); |
|
| 41 | + $table->integer('majho_hook_order')->nullable(); |
|
| 42 | + |
|
| 43 | + $table->primary(['majho_module_name', 'majho_hook_name']); |
|
| 44 | + }); |
|
| 45 | + |
|
| 46 | + if ($in_transaction && !DB::connection()->getPdo()->inTransaction()) { |
|
| 47 | + DB::connection()->beginTransaction(); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | } |