Skip to content

Commit f35b258

Browse files
committed
Fixed Review Comments & static failures
1 parent 85e70c1 commit f35b258

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/SchemaBuilder.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright 2017 Adobe All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2017 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -16,6 +16,8 @@
1616
use Magento\Framework\Setup\Declaration\Schema\Sharding;
1717
use Magento\Framework\Config\FileResolverByModule;
1818
use Magento\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite;
19+
use Psr\Log\LoggerInterface;
20+
use Magento\Framework\Exception\LocalizedException;
1921

2022
/**
2123
* This type of builder is responsible for converting ENTIRE data, that comes from db
@@ -27,6 +29,7 @@
2729
*
2830
* @see Schema
2931
* @inheritdoc
32+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3033
*/
3134
class SchemaBuilder
3235
{
@@ -55,30 +58,39 @@ class SchemaBuilder
5558
*/
5659
private $readerComposite;
5760

61+
/**
62+
* @var LoggerInterface
63+
*/
64+
private $logger;
65+
5866
/**
5967
* Constructor.
6068
*
6169
* @param ElementFactory $elementFactory
6270
* @param DbSchemaReaderInterface $dbSchemaReader
6371
* @param Sharding $sharding
6472
* @param ReaderComposite $readerComposite
73+
* @param LoggerInterface $logger
6574
*/
6675
public function __construct(
6776
ElementFactory $elementFactory,
6877
DbSchemaReaderInterface $dbSchemaReader,
6978
Sharding $sharding,
70-
ReaderComposite $readerComposite
79+
ReaderComposite $readerComposite,
80+
LoggerInterface $logger
7181
) {
7282
$this->elementFactory = $elementFactory;
7383
$this->dbSchemaReader = $dbSchemaReader;
7484
$this->sharding = $sharding;
7585
$this->readerComposite = $readerComposite;
86+
$this->logger = $logger;
7687
}
7788

7889
/**
7990
* @inheritdoc
8091
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8192
* @SuppressWarnings(PHPMD.NPathComplexity)
93+
* @throws LocalizedException
8294
*/
8395
public function build(Schema $schema)
8496
{
@@ -100,10 +112,10 @@ public function build(Schema $schema)
100112
$keyTable,
101113
$keyColumn
102114
);
103-
115+
$this->logger->error($errorMessage);
104116
// Throw a new exception with the extended message
105117
// This preserves the original error but adds our context
106-
throw new \Exception($errorMessage, $e->getCode(), $e);
118+
throw new LocalizedException(new Phrase($errorMessage));
107119
}
108120
}
109121
}

0 commit comments

Comments
 (0)