1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4/** 5 * @author Björn Heyser <bheyser@databay.de> 6 * @version $Id$ 7 * 8 * @package Modules/Test 9 */ 10abstract class ilTestProcessLocker 11{ 12 /** 13 * @param callable $operation 14 */ 15 protected function executeOperation(callable $operation) 16 { 17 $operation(); 18 } 19 20 /** 21 * @param callable $operation 22 */ 23 final public function executeTestStartLockOperation(callable $operation) 24 { 25 $this->onBeforeExecutingTestStartOperation(); 26 $this->executeOperation($operation); 27 $this->onAfterExecutingTestStartOperation(); 28 } 29 30 /** 31 * 32 */ 33 protected function onBeforeExecutingTestStartOperation() 34 { 35 } 36 37 /** 38 * 39 */ 40 protected function onAfterExecutingTestStartOperation() 41 { 42 } 43 44 /** 45 * @param callable $operation 46 * @param bool $withTaxonomyTables 47 */ 48 final public function executeRandomPassBuildOperation(callable $operation, $withTaxonomyTables = false) 49 { 50 $this->onBeforeExecutingRandomPassBuildOperation($withTaxonomyTables); 51 $this->executeOperation($operation); 52 $this->onAfterExecutingRandomPassBuildOperation($withTaxonomyTables); 53 } 54 55 /** 56 * @param bool $withTaxonomyTables 57 */ 58 protected function onBeforeExecutingRandomPassBuildOperation($withTaxonomyTables = false) 59 { 60 } 61 62 /** 63 * @param bool $withTaxonomyTables 64 */ 65 protected function onAfterExecutingRandomPassBuildOperation($withTaxonomyTables = false) 66 { 67 } 68 69 70 /** 71 * @param callable $operation 72 */ 73 final public function executeTestFinishOperation(callable $operation) 74 { 75 $this->onBeforeExecutingTestFinishOperation(); 76 $this->executeOperation($operation); 77 $this->onAfterExecutingTestFinishOperation(); 78 } 79 80 /** 81 * 82 */ 83 protected function onBeforeExecutingTestFinishOperation() 84 { 85 } 86 87 /** 88 * 89 */ 90 protected function onAfterExecutingTestFinishOperation() 91 { 92 } 93} 94