Code Duplication    Length = 8-11 lines in 5 locations

src/Webtrees/Hook/Hook.php 5 locations

@@ 65-75 (lines=11) @@
62
	 * @param string $hsubscriber Name of the subscriber module
63
	 * @param int $priority Priority of execution
64
	 */
65
	public function setPriority($hsubscriber, $priority){
66
		if(HookProvider::getInstance()->isModuleOperational()){
67
			Database::prepare(
68
			"UPDATE `##maj_hooks`".
69
			" SET majh_module_priority=?".
70
			" WHERE majh_hook_function=?".
71
			" AND majh_hook_context=?".
72
			" AND majh_module_name=?"
73
					)->execute(array($priority, $this->hook_function, $this->hook_context, $hsubscriber));
74
		}
75
	}
76
77
	/**
78
	 * Enable the hook for a specific HookSubscriberInterface.
@@ 82-92 (lines=11) @@
79
	 *
80
	 * @param string $hsubscriber Name of the subscriber module
81
	 */
82
	public function enable($hsubscriber){
83
		if(HookProvider::getInstance()->isModuleOperational()){
84
		Database::prepare(
85
			"UPDATE `##maj_hooks`".
86
			" SET majh_status='enabled'".
87
			" WHERE majh_hook_function=?".
88
			" AND majh_hook_context=?".
89
			" AND majh_module_name=?"
90
			)->execute(array($this->hook_function, $this->hook_context, $hsubscriber));
91
		}
92
	}
93
94
	/**
95
	 * Disable the hook for a specific HookSubscriberInterface.
@@ 99-109 (lines=11) @@
96
	 *
97
	 * @param string $hsubscriber Name of the subscriber module
98
	 */
99
	public function disable($hsubscriber){
100
		if(HookProvider::getInstance()->isModuleOperational()){
101
		Database::prepare(
102
			"UPDATE `##maj_hooks`".
103
			" SET majh_status='disabled'".
104
			" WHERE majh_hook_function=?".
105
			" AND majh_hook_context=?".
106
			" AND majh_module_name=?"
107
			)->execute(array($this->hook_function, $this->hook_context, $hsubscriber));
108
		}
109
	}
110
111
	/**
112
	 * Remove the hook for a specific HookSubscriberInterface.
@@ 116-125 (lines=10) @@
113
	 *
114
	 * @param string $hsubscriber Name of the subscriber module
115
	 */
116
	public function remove($hsubscriber){
117
		if(HookProvider::getInstance()->isModuleOperational()){
118
		Database::prepare(
119
			"DELETE FROM `##maj_hooks`".
120
			" WHERE majh_hook_function=?".
121
			" AND majh_hook_context=?".
122
			" AND majh_module_name=?"
123
				)->execute(array($this->hook_function, $this->hook_context, $hsubscriber));
124
		}
125
	}
126
127
128
	/**
@@ 50-57 (lines=8) @@
47
	 *
48
	 * @param string $hsubscriber Name of the subscriber module
49
	 */
50
	public function subscribe($hsubscriber){
51
		if(HookProvider::getInstance()->isModuleOperational()){
52
			Database::prepare(
53
					"INSERT IGNORE INTO `##maj_hooks` (majh_hook_function, majh_hook_context, majh_module_name)".
54
					" VALUES (?, ?, ?)"
55
			)->execute(array($this->hook_function, $this->hook_context, $hsubscriber));
56
		}
57
	}
58
59
	/**
60
	 *  Define the priority for execution of the Hook for the specific HookSubscriberInterface