1
1
<?php
2
2
/**
3
- * Copyright 2017 Adobe All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2017 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
16
16
use Magento \Framework \Setup \Declaration \Schema \Sharding ;
17
17
use Magento \Framework \Config \FileResolverByModule ;
18
18
use Magento \Framework \Setup \Declaration \Schema \Declaration \ReaderComposite ;
19
+ use Psr \Log \LoggerInterface ;
20
+ use Magento \Framework \Exception \LocalizedException ;
19
21
20
22
/**
21
23
* This type of builder is responsible for converting ENTIRE data, that comes from db
27
29
*
28
30
* @see Schema
29
31
* @inheritdoc
32
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30
33
*/
31
34
class SchemaBuilder
32
35
{
@@ -55,30 +58,39 @@ class SchemaBuilder
55
58
*/
56
59
private $ readerComposite ;
57
60
61
+ /**
62
+ * @var LoggerInterface
63
+ */
64
+ private $ logger ;
65
+
58
66
/**
59
67
* Constructor.
60
68
*
61
69
* @param ElementFactory $elementFactory
62
70
* @param DbSchemaReaderInterface $dbSchemaReader
63
71
* @param Sharding $sharding
64
72
* @param ReaderComposite $readerComposite
73
+ * @param LoggerInterface $logger
65
74
*/
66
75
public function __construct (
67
76
ElementFactory $ elementFactory ,
68
77
DbSchemaReaderInterface $ dbSchemaReader ,
69
78
Sharding $ sharding ,
70
- ReaderComposite $ readerComposite
79
+ ReaderComposite $ readerComposite ,
80
+ LoggerInterface $ logger
71
81
) {
72
82
$ this ->elementFactory = $ elementFactory ;
73
83
$ this ->dbSchemaReader = $ dbSchemaReader ;
74
84
$ this ->sharding = $ sharding ;
75
85
$ this ->readerComposite = $ readerComposite ;
86
+ $ this ->logger = $ logger ;
76
87
}
77
88
78
89
/**
79
90
* @inheritdoc
80
91
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
81
92
* @SuppressWarnings(PHPMD.NPathComplexity)
93
+ * @throws LocalizedException
82
94
*/
83
95
public function build (Schema $ schema )
84
96
{
@@ -100,10 +112,10 @@ public function build(Schema $schema)
100
112
$ keyTable ,
101
113
$ keyColumn
102
114
);
103
-
115
+ $ this -> logger -> error ( $ errorMessage );
104
116
// Throw a new exception with the extended message
105
117
// This preserves the original error but adds our context
106
- throw new \ Exception ( $ errorMessage , $ e -> getCode (), $ e );
118
+ throw new LocalizedException ( new Phrase ( $ errorMessage ) );
107
119
}
108
120
}
109
121
}
0 commit comments