@@ -25,45 +25,45 @@ |
||
| 25 | 25 | * @extends AbstractHookCollector<SosaFamilyDatatablesExtenderInterface> |
| 26 | 26 | */ |
| 27 | 27 | class SosaFamilyDatatablesExtenderCollector extends AbstractHookCollector implements |
| 28 | - SosaFamilyDatatablesExtenderInterface |
|
| 28 | + SosaFamilyDatatablesExtenderInterface |
|
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * {@inheritDoc} |
|
| 32 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | - */ |
|
| 34 | - public function title(): string |
|
| 35 | - { |
|
| 36 | - return I18N::translate('Columns extender for tables of ancestors’ families'); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritDoc} |
|
| 32 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | + */ |
|
| 34 | + public function title(): string |
|
| 35 | + { |
|
| 36 | + return I18N::translate('Columns extender for tables of ancestors’ families'); |
|
| 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('Add additional columns to tables of ancestors’ families'); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | + */ |
|
| 43 | + public function description(): string |
|
| 44 | + { |
|
| 45 | + return I18N::translate('Add additional columns to tables of ancestors’ families'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritDoc} |
|
| 50 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | - */ |
|
| 52 | - public function hookInterface(): string |
|
| 53 | - { |
|
| 54 | - return SosaFamilyDatatablesExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return SosaFamilyDatatablesExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaFamilyDatatablesExtenderInterface::sosaFamilyColumns() |
|
| 60 | - */ |
|
| 61 | - public function sosaFamilyColumns(iterable $records): array |
|
| 62 | - { |
|
| 63 | - $result = []; |
|
| 64 | - foreach ($this->hooks() as $hook) { |
|
| 65 | - $result += $hook->sosaFamilyColumns($records); |
|
| 66 | - } |
|
| 67 | - return $result; |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaFamilyDatatablesExtenderInterface::sosaFamilyColumns() |
|
| 60 | + */ |
|
| 61 | + public function sosaFamilyColumns(iterable $records): array |
|
| 62 | + { |
|
| 63 | + $result = []; |
|
| 64 | + foreach ($this->hooks() as $hook) { |
|
| 65 | + $result += $hook->sosaFamilyColumns($records); |
|
| 66 | + } |
|
| 67 | + return $result; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -25,45 +25,45 @@ |
||
| 25 | 25 | * @extends AbstractHookCollector<SosaIndividualDatatablesExtenderInterface> |
| 26 | 26 | */ |
| 27 | 27 | class SosaIndividualDatatablesExtenderCollector extends AbstractHookCollector implements |
| 28 | - SosaIndividualDatatablesExtenderInterface |
|
| 28 | + SosaIndividualDatatablesExtenderInterface |
|
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * {@inheritDoc} |
|
| 32 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | - */ |
|
| 34 | - public function title(): string |
|
| 35 | - { |
|
| 36 | - return I18N::translate('Columns extender for tables of ancestors'); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritDoc} |
|
| 32 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | + */ |
|
| 34 | + public function title(): string |
|
| 35 | + { |
|
| 36 | + return I18N::translate('Columns extender for tables of ancestors'); |
|
| 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('Add additional columns to tables of ancestors'); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | + */ |
|
| 43 | + public function description(): string |
|
| 44 | + { |
|
| 45 | + return I18N::translate('Add additional columns to tables of ancestors'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritDoc} |
|
| 50 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | - */ |
|
| 52 | - public function hookInterface(): string |
|
| 53 | - { |
|
| 54 | - return SosaIndividualDatatablesExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return SosaIndividualDatatablesExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaIndividualDatatablesExtenderInterface::sosaIndividualColumns() |
|
| 60 | - */ |
|
| 61 | - public function sosaIndividualColumns(iterable $records): array |
|
| 62 | - { |
|
| 63 | - $result = []; |
|
| 64 | - foreach ($this->hooks() as $hook) { |
|
| 65 | - $result += $hook->sosaIndividualColumns($records); |
|
| 66 | - } |
|
| 67 | - return $result; |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\SosaIndividualDatatablesExtenderInterface::sosaIndividualColumns() |
|
| 60 | + */ |
|
| 61 | + public function sosaIndividualColumns(iterable $records): array |
|
| 62 | + { |
|
| 63 | + $result = []; |
|
| 64 | + foreach ($this->hooks() as $hook) { |
|
| 65 | + $result += $hook->sosaIndividualColumns($records); |
|
| 66 | + } |
|
| 67 | + return $result; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -27,56 +27,56 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class FactSourceTextExtenderCollector extends AbstractHookCollector implements FactSourceTextExtenderInterface |
| 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 source citations’ title'); |
|
| 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 source citations’ title'); |
|
| 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 title of source citations 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 title of source citations 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 FactSourceTextExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return FactSourceTextExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend() |
|
| 60 | - */ |
|
| 61 | - public function factSourcePrepend(Tree $tree, $fact): string |
|
| 62 | - { |
|
| 63 | - return $this->hooks() |
|
| 64 | - ->map( |
|
| 65 | - fn(FactSourceTextExtenderInterface $hook) => |
|
| 66 | - $hook->factSourcePrepend($tree, $fact) |
|
| 67 | - )->implode(''); |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend() |
|
| 60 | + */ |
|
| 61 | + public function factSourcePrepend(Tree $tree, $fact): string |
|
| 62 | + { |
|
| 63 | + return $this->hooks() |
|
| 64 | + ->map( |
|
| 65 | + fn(FactSourceTextExtenderInterface $hook) => |
|
| 66 | + $hook->factSourcePrepend($tree, $fact) |
|
| 67 | + )->implode(''); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * {@inheritDoc} |
|
| 72 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend() |
|
| 73 | - */ |
|
| 74 | - public function factSourceAppend(Tree $tree, $fact): string |
|
| 75 | - { |
|
| 76 | - return $this->hooks() |
|
| 77 | - ->map( |
|
| 78 | - fn(FactSourceTextExtenderInterface $hook) => |
|
| 79 | - $hook->factSourcePrepend($tree, $fact) |
|
| 80 | - )->implode(''); |
|
| 81 | - } |
|
| 70 | + /** |
|
| 71 | + * {@inheritDoc} |
|
| 72 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend() |
|
| 73 | + */ |
|
| 74 | + public function factSourceAppend(Tree $tree, $fact): string |
|
| 75 | + { |
|
| 76 | + return $this->hooks() |
|
| 77 | + ->map( |
|
| 78 | + fn(FactSourceTextExtenderInterface $hook) => |
|
| 79 | + $hook->factSourcePrepend($tree, $fact) |
|
| 80 | + )->implode(''); |
|
| 81 | + } |
|
| 82 | 82 | } |
@@ -25,45 +25,45 @@ |
||
| 25 | 25 | * @extends AbstractHookCollector<FamilyDatatablesExtenderInterface> |
| 26 | 26 | */ |
| 27 | 27 | class FamilyDatatablesExtenderCollector extends AbstractHookCollector implements |
| 28 | - FamilyDatatablesExtenderInterface |
|
| 28 | + FamilyDatatablesExtenderInterface |
|
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * {@inheritDoc} |
|
| 32 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | - */ |
|
| 34 | - public function title(): string |
|
| 35 | - { |
|
| 36 | - return I18N::translate('Columns extender for tables of families'); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritDoc} |
|
| 32 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | + */ |
|
| 34 | + public function title(): string |
|
| 35 | + { |
|
| 36 | + return I18N::translate('Columns extender for tables of families'); |
|
| 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('Add additional columns to tables of families'); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | + */ |
|
| 43 | + public function description(): string |
|
| 44 | + { |
|
| 45 | + return I18N::translate('Add additional columns to tables of families'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritDoc} |
|
| 50 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | - */ |
|
| 52 | - public function hookInterface(): string |
|
| 53 | - { |
|
| 54 | - return FamilyDatatablesExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return FamilyDatatablesExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\FamilyDatatablesExtenderInterface::familyColumns() |
|
| 60 | - */ |
|
| 61 | - public function familyColumns(iterable $records): array |
|
| 62 | - { |
|
| 63 | - $result = []; |
|
| 64 | - foreach ($this->hooks() as $hook) { |
|
| 65 | - $result += $hook->familyColumns($records); |
|
| 66 | - } |
|
| 67 | - return $result; |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\FamilyDatatablesExtenderInterface::familyColumns() |
|
| 60 | + */ |
|
| 61 | + public function familyColumns(iterable $records): array |
|
| 62 | + { |
|
| 63 | + $result = []; |
|
| 64 | + foreach ($this->hooks() as $hook) { |
|
| 65 | + $result += $hook->familyColumns($records); |
|
| 66 | + } |
|
| 67 | + return $result; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -25,45 +25,45 @@ |
||
| 25 | 25 | * @extends AbstractHookCollector<IndividualDatatablesExtenderInterface> |
| 26 | 26 | */ |
| 27 | 27 | class IndividualDatatablesExtenderCollector extends AbstractHookCollector implements |
| 28 | - IndividualDatatablesExtenderInterface |
|
| 28 | + IndividualDatatablesExtenderInterface |
|
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * {@inheritDoc} |
|
| 32 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | - */ |
|
| 34 | - public function title(): string |
|
| 35 | - { |
|
| 36 | - return I18N::translate('Columns extender for tables of individuals'); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritDoc} |
|
| 32 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
| 33 | + */ |
|
| 34 | + public function title(): string |
|
| 35 | + { |
|
| 36 | + return I18N::translate('Columns extender for tables of individuals'); |
|
| 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('Add additional columns to tables of individuals'); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
| 42 | + */ |
|
| 43 | + public function description(): string |
|
| 44 | + { |
|
| 45 | + return I18N::translate('Add additional columns to tables of individuals'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritDoc} |
|
| 50 | - * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | - */ |
|
| 52 | - public function hookInterface(): string |
|
| 53 | - { |
|
| 54 | - return IndividualDatatablesExtenderInterface::class; |
|
| 55 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inheritDoc} |
|
| 50 | + * @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
| 51 | + */ |
|
| 52 | + public function hookInterface(): string |
|
| 53 | + { |
|
| 54 | + return IndividualDatatablesExtenderInterface::class; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\IndividualDatatablesExtenderInterface::individualColumns() |
|
| 60 | - */ |
|
| 61 | - public function individualColumns(iterable $records): array |
|
| 62 | - { |
|
| 63 | - $result = []; |
|
| 64 | - foreach ($this->hooks() as $hook) { |
|
| 65 | - $result += $hook->individualColumns($records); |
|
| 66 | - } |
|
| 67 | - return $result; |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\IndividualDatatablesExtenderInterface::individualColumns() |
|
| 60 | + */ |
|
| 61 | + public function individualColumns(iterable $records): array |
|
| 62 | + { |
|
| 63 | + $result = []; |
|
| 64 | + foreach ($this->hooks() as $hook) { |
|
| 65 | + $result += $hook->individualColumns($records); |
|
| 66 | + } |
|
| 67 | + return $result; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Migration0 implements MigrationInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritDoc} |
|
| 26 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 27 | - */ |
|
| 28 | - public function upgrade(): void |
|
| 29 | - { |
|
| 24 | + /** |
|
| 25 | + * {@inheritDoc} |
|
| 26 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 27 | + */ |
|
| 28 | + public function upgrade(): void |
|
| 29 | + { |
|
| 30 | 30 | |
| 31 | - // This migration has been superseded by migration 1. |
|
| 32 | - } |
|
| 31 | + // This migration has been superseded by migration 1. |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -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 | } |
@@ -29,44 +29,44 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class ModulesHooksPage implements RequestHandlerInterface |
| 31 | 31 | { |
| 32 | - use ViewResponseTrait; |
|
| 32 | + use ViewResponseTrait; |
|
| 33 | 33 | |
| 34 | - protected HookService $hook_service; |
|
| 34 | + protected HookService $hook_service; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor for ModulesHooksPage request handler |
|
| 38 | - * |
|
| 39 | - * @param HookService $hook_service |
|
| 40 | - */ |
|
| 41 | - public function __construct(HookService $hook_service) |
|
| 42 | - { |
|
| 43 | - $this->hook_service = $hook_service; |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * Constructor for ModulesHooksPage request handler |
|
| 38 | + * |
|
| 39 | + * @param HookService $hook_service |
|
| 40 | + */ |
|
| 41 | + public function __construct(HookService $hook_service) |
|
| 42 | + { |
|
| 43 | + $this->hook_service = $hook_service; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * {@inheritDoc} |
|
| 48 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 49 | - */ |
|
| 50 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 51 | - { |
|
| 52 | - $this->layout = 'layouts/administration'; |
|
| 46 | + /** |
|
| 47 | + * {@inheritDoc} |
|
| 48 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 49 | + */ |
|
| 50 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 51 | + { |
|
| 52 | + $this->layout = 'layouts/administration'; |
|
| 53 | 53 | |
| 54 | - $hook_name = Validator::attributes($request)->string('hook_name', ''); |
|
| 55 | - $hook = $this->hook_service->find($hook_name, true); |
|
| 56 | - if ($hook === null) { |
|
| 57 | - throw new HttpNotFoundException(I18N::translate('The hook with name “%s” does not exist.', $hook_name)); |
|
| 58 | - } |
|
| 54 | + $hook_name = Validator::attributes($request)->string('hook_name', ''); |
|
| 55 | + $hook = $this->hook_service->find($hook_name, true); |
|
| 56 | + if ($hook === null) { |
|
| 57 | + throw new HttpNotFoundException(I18N::translate('The hook with name “%s” does not exist.', $hook_name)); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $modules = $hook->hooks() |
|
| 61 | - ->sortKeys() |
|
| 62 | - ->mapWithKeys(fn(HookInterface $hook) => [$hook->module()->name() => $hook->module()]); |
|
| 60 | + $modules = $hook->hooks() |
|
| 61 | + ->sortKeys() |
|
| 62 | + ->mapWithKeys(fn(HookInterface $hook) => [$hook->module()->name() => $hook->module()]); |
|
| 63 | 63 | |
| 64 | - return $this->viewResponse('admin/components', [ |
|
| 65 | - 'description' => $hook->description(), |
|
| 66 | - 'modules' => $modules, |
|
| 67 | - 'title' => $hook->title(), |
|
| 68 | - 'uses_access' => false, |
|
| 69 | - 'uses_sorting' => true |
|
| 70 | - ]); |
|
| 71 | - } |
|
| 64 | + return $this->viewResponse('admin/components', [ |
|
| 65 | + 'description' => $hook->description(), |
|
| 66 | + 'modules' => $modules, |
|
| 67 | + 'title' => $hook->title(), |
|
| 68 | + 'uses_access' => false, |
|
| 69 | + 'uses_sorting' => true |
|
| 70 | + ]); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -30,101 +30,101 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class HookService implements HookServiceInterface |
| 32 | 32 | { |
| 33 | - private ModuleService $module_service; |
|
| 33 | + private ModuleService $module_service; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Constructor for HookService |
|
| 37 | - * |
|
| 38 | - * @param ModuleService $module_service |
|
| 39 | - */ |
|
| 40 | - public function __construct(ModuleService $module_service) |
|
| 41 | - { |
|
| 42 | - $this->module_service = $module_service; |
|
| 43 | - } |
|
| 35 | + /** |
|
| 36 | + * Constructor for HookService |
|
| 37 | + * |
|
| 38 | + * @param ModuleService $module_service |
|
| 39 | + */ |
|
| 40 | + public function __construct(ModuleService $module_service) |
|
| 41 | + { |
|
| 42 | + $this->module_service = $module_service; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * {@inheritDoc} |
|
| 47 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookServiceInterface::use() |
|
| 48 | - */ |
|
| 49 | - public function use(string $hook_interface): ?HookCollectorInterface |
|
| 50 | - { |
|
| 51 | - return $this->all()->get($hook_interface); |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * {@inheritDoc} |
|
| 47 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookServiceInterface::use() |
|
| 48 | + */ |
|
| 49 | + public function use(string $hook_interface): ?HookCollectorInterface |
|
| 50 | + { |
|
| 51 | + return $this->all()->get($hook_interface); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Find a hook collector by its name, with or without the disabled ones. |
|
| 57 | - * |
|
| 58 | - * @param string $hook_name |
|
| 59 | - * @return HookCollectorInterface|null |
|
| 60 | - */ |
|
| 61 | - public function find(string $hook_name, bool $include_disabled = false): ?HookCollectorInterface |
|
| 62 | - { |
|
| 63 | - return $this->all($include_disabled) |
|
| 64 | - ->first(fn(HookCollectorInterface $hook_collector) => $hook_collector->name() === $hook_name); |
|
| 65 | - } |
|
| 55 | + /** |
|
| 56 | + * Find a hook collector by its name, with or without the disabled ones. |
|
| 57 | + * |
|
| 58 | + * @param string $hook_name |
|
| 59 | + * @return HookCollectorInterface|null |
|
| 60 | + */ |
|
| 61 | + public function find(string $hook_name, bool $include_disabled = false): ?HookCollectorInterface |
|
| 62 | + { |
|
| 63 | + return $this->all($include_disabled) |
|
| 64 | + ->first(fn(HookCollectorInterface $hook_collector) => $hook_collector->name() === $hook_name); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Get all hook collectors subscribed by modules, with hooks ordered, with or without the disabled ones. |
|
| 69 | - * |
|
| 70 | - * @param bool $include_disabled |
|
| 71 | - * @return Collection<string, HookCollectorInterface> |
|
| 72 | - */ |
|
| 73 | - public function all(bool $include_disabled = false): Collection |
|
| 74 | - { |
|
| 75 | - return Registry::cache()->array()->remember('all-hooks', function () use ($include_disabled): Collection { |
|
| 76 | - $hooks_info = DB::table('maj_hook_order') |
|
| 77 | - ->get() |
|
| 78 | - ->groupBy(['majho_hook_name', 'majho_module_name']); |
|
| 67 | + /** |
|
| 68 | + * Get all hook collectors subscribed by modules, with hooks ordered, with or without the disabled ones. |
|
| 69 | + * |
|
| 70 | + * @param bool $include_disabled |
|
| 71 | + * @return Collection<string, HookCollectorInterface> |
|
| 72 | + */ |
|
| 73 | + public function all(bool $include_disabled = false): Collection |
|
| 74 | + { |
|
| 75 | + return Registry::cache()->array()->remember('all-hooks', function () use ($include_disabled): Collection { |
|
| 76 | + $hooks_info = DB::table('maj_hook_order') |
|
| 77 | + ->get() |
|
| 78 | + ->groupBy(['majho_hook_name', 'majho_module_name']); |
|
| 79 | 79 | |
| 80 | - $hooks = $this->module_service |
|
| 81 | - ->findByInterface(ModuleHookSubscriberInterface::class, $include_disabled) |
|
| 82 | - ->flatMap(fn(ModuleHookSubscriberInterface $module) => $module->listSubscribedHooks()); |
|
| 80 | + $hooks = $this->module_service |
|
| 81 | + ->findByInterface(ModuleHookSubscriberInterface::class, $include_disabled) |
|
| 82 | + ->flatMap(fn(ModuleHookSubscriberInterface $module) => $module->listSubscribedHooks()); |
|
| 83 | 83 | |
| 84 | - $hook_collectors = collect(); |
|
| 85 | - $hook_instances = collect(); |
|
| 86 | - foreach ($hooks as $hook) { |
|
| 87 | - if (!($hook instanceof HookInterface)) { |
|
| 88 | - continue; |
|
| 89 | - } |
|
| 90 | - if ($hook instanceof HookCollectorInterface) { |
|
| 91 | - $hook_collectors->put($hook->hookInterface(), $hook); |
|
| 92 | - } else { |
|
| 93 | - $hook_instances->add($hook); |
|
| 94 | - } |
|
| 95 | - } |
|
| 84 | + $hook_collectors = collect(); |
|
| 85 | + $hook_instances = collect(); |
|
| 86 | + foreach ($hooks as $hook) { |
|
| 87 | + if (!($hook instanceof HookInterface)) { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 90 | + if ($hook instanceof HookCollectorInterface) { |
|
| 91 | + $hook_collectors->put($hook->hookInterface(), $hook); |
|
| 92 | + } else { |
|
| 93 | + $hook_instances->add($hook); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - foreach ($hook_collectors as $hook_interface => $hook_collector) { |
|
| 98 | - $hook_info = $hooks_info->get($hook_collector->name()) ?? collect(); |
|
| 99 | - foreach ( |
|
| 100 | - $hook_instances->filter( |
|
| 101 | - fn(HookInterface $hook): bool => $hook instanceof $hook_interface |
|
| 102 | - ) as $hook_instance |
|
| 103 | - ) { |
|
| 104 | - $hook_module_info = $hook_info->get($hook_instance->module()->name(), collect())->first(); |
|
| 105 | - $hook_order = $hook_module_info instanceof stdClass ? (int) $hook_module_info->majho_hook_order : 0; |
|
| 106 | - $hook_collector->register($hook_instance, $hook_order); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - return $hook_collectors; |
|
| 110 | - }); |
|
| 111 | - } |
|
| 97 | + foreach ($hook_collectors as $hook_interface => $hook_collector) { |
|
| 98 | + $hook_info = $hooks_info->get($hook_collector->name()) ?? collect(); |
|
| 99 | + foreach ( |
|
| 100 | + $hook_instances->filter( |
|
| 101 | + fn(HookInterface $hook): bool => $hook instanceof $hook_interface |
|
| 102 | + ) as $hook_instance |
|
| 103 | + ) { |
|
| 104 | + $hook_module_info = $hook_info->get($hook_instance->module()->name(), collect())->first(); |
|
| 105 | + $hook_order = $hook_module_info instanceof stdClass ? (int) $hook_module_info->majho_hook_order : 0; |
|
| 106 | + $hook_collector->register($hook_instance, $hook_order); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + return $hook_collectors; |
|
| 110 | + }); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Update the order of the modules implementing a hook in the database. |
|
| 115 | - * |
|
| 116 | - * @param HookCollectorInterface $hook_collector |
|
| 117 | - * @param ModuleInterface $module |
|
| 118 | - * @param int $order |
|
| 119 | - * @return int |
|
| 120 | - */ |
|
| 121 | - public function updateOrder(HookCollectorInterface $hook_collector, ModuleInterface $module, int $order): int |
|
| 122 | - { |
|
| 123 | - return DB::table('maj_hook_order') |
|
| 124 | - ->upsert([ |
|
| 125 | - 'majho_module_name' => $module->name(), |
|
| 126 | - 'majho_hook_name' => $hook_collector->name(), |
|
| 127 | - 'majho_hook_order' => $order |
|
| 128 | - ], ['majho_module_name', 'majho_hook_name'], ['majho_hook_order']); |
|
| 129 | - } |
|
| 113 | + /** |
|
| 114 | + * Update the order of the modules implementing a hook in the database. |
|
| 115 | + * |
|
| 116 | + * @param HookCollectorInterface $hook_collector |
|
| 117 | + * @param ModuleInterface $module |
|
| 118 | + * @param int $order |
|
| 119 | + * @return int |
|
| 120 | + */ |
|
| 121 | + public function updateOrder(HookCollectorInterface $hook_collector, ModuleInterface $module, int $order): int |
|
| 122 | + { |
|
| 123 | + return DB::table('maj_hook_order') |
|
| 124 | + ->upsert([ |
|
| 125 | + 'majho_module_name' => $module->name(), |
|
| 126 | + 'majho_hook_name' => $hook_collector->name(), |
|
| 127 | + 'majho_hook_order' => $order |
|
| 128 | + ], ['majho_module_name', 'majho_hook_name'], ['majho_hook_order']); |
|
| 129 | + } |
|
| 130 | 130 | } |