1
|
|
|
<?php |
2
|
|
|
// @todo |
3
|
|
|
|
4
|
|
|
namespace Finder\Pipelines\Application; |
5
|
|
|
|
6
|
|
|
use League\Pipeline\Pipeline; |
7
|
|
|
use Operador\Contracts\StageInterface; |
8
|
|
|
|
9
|
|
|
class FolderFound implements StageInterface |
10
|
|
|
{ |
11
|
|
View Code Duplication |
public function __invoke($eloquentClasses) |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
return Cache::remember( |
14
|
|
|
'sitec_support_render_database_'.md5(implode('|', $eloquentClasses->values()->all())), 30, function () use ($eloquentClasses) { |
15
|
|
|
Log::debug( |
16
|
|
|
'Mount Database -> Renderizando' |
17
|
|
|
); |
18
|
|
|
$renderDatabase = (new \Support\Components\Database\Render\Database($eloquentClasses)); |
19
|
|
|
return $renderDatabase; |
20
|
|
|
} |
21
|
|
|
); |
22
|
|
|
} |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
// class DatabaseMount implements StageInterface |
26
|
|
|
// { |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
// public function __invoke($renderDatabaseArray) |
30
|
|
|
// { |
31
|
|
|
// $eloquentClasses = collect($renderDatabaseArray["Leitoras"]["displayClasses"]); |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
// $this->entitys = $eloquentClasses->reject(function($eloquentData, $className) { |
35
|
|
|
// return $this->eloquentHasError($className); |
36
|
|
|
// })->map(function($eloquentData, $className) use ($renderDatabaseArray) { |
37
|
|
|
// return (new EloquentMount($className, $renderDatabaseArray))->getEntity(); |
38
|
|
|
// }); |
39
|
|
|
// } |
40
|
|
|
// } |
41
|
|
|
class ReaderPipeline |
42
|
|
|
{ |
43
|
|
View Code Duplication |
public function __invoke($eloquentClasses) |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
|
46
|
|
|
$pipeline = (new Pipeline) |
47
|
|
|
->pipe(new DatabaseRender) |
48
|
|
|
->pipe(new DatabaseMount); |
49
|
|
|
|
50
|
|
|
// Returns 21 |
51
|
|
|
$entitys = $pipeline->process(10); |
|
|
|
|
52
|
|
|
|
53
|
|
|
|
54
|
|
|
|
55
|
|
|
// Re-usable Pipelines |
56
|
|
|
// Because the PipelineInterface is an extension of the StageInterface pipelines can be re-used as stages. This creates a highly composable model to create complex execution patterns while keeping the cognitive load low. |
57
|
|
|
|
58
|
|
|
// For example, if we'd want to compose a pipeline to process API calls, we'd create something along these lines: |
59
|
|
|
|
60
|
|
|
$processApiRequest = (new Pipeline) |
61
|
|
|
->pipe(new ExecuteHttpRequest) // 2 |
62
|
|
|
->pipe(new ParseJsonResponse); // 3 |
63
|
|
|
|
64
|
|
|
$pipeline = (new Pipeline) |
65
|
|
|
->pipe(new ConvertToPsr7Request) // 1 |
66
|
|
|
->pipe($processApiRequest) // (2,3) |
67
|
|
|
->pipe(new ConvertToResponseDto); // 4 |
68
|
|
|
|
69
|
|
|
$pipeline->process(new DeleteBlogPost($postId)); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.