-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark jobs as final once again, but add an abstract decorator that hel…
…ps construction (#82)
- Loading branch information
1 parent
f548a96
commit ea92362
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yokai\Batch\Job; | ||
|
||
use Yokai\Batch\JobExecution; | ||
|
||
/** | ||
* This {@see JobInterface} is designed to be extended in your project. | ||
* It decorates another {@see JobInterface} that will actually run the code. | ||
* It might be used as a "constructor helper". | ||
*/ | ||
abstract class AbstractDecoratedJob implements JobInterface | ||
{ | ||
public function __construct( | ||
private JobInterface $job, | ||
) { | ||
} | ||
|
||
final public function execute(JobExecution $jobExecution): void | ||
{ | ||
$this->preExecute($jobExecution); | ||
$this->job->execute($jobExecution); | ||
$this->postExecute($jobExecution); | ||
} | ||
|
||
/** | ||
* Overrides this method if you want to do something before the job is executed. | ||
*/ | ||
protected function preExecute(JobExecution $jobExecution): void | ||
{ | ||
} | ||
|
||
/** | ||
* Overrides this method if you want to do something after the job is executed. | ||
*/ | ||
protected function postExecute(JobExecution $jobExecution): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters