-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge forwardport of #11686 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/11686.patch (created by @tdgroot) based on commit(s): 1. 177e540 2. 0d65213 3. a781bf6 4. dcc480d 5. 5d4e1c2 6. b552dd1 7. b85b91e Fixed GitHub Issues in 2.3-develop branch: - #5188: Error generating URN-catalog when blank one exists (reported by @JamesonNetworks)
- Loading branch information
Showing
4 changed files
with
130 additions
and
19 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
63 changes: 63 additions & 0 deletions
63
app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm/DomDocumentFactory.php
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,63 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Developer\Model\XmlCatalog\Format\PhpStorm; | ||
|
||
use DOMDocument; | ||
|
||
class DomDocumentFactory | ||
{ | ||
/** | ||
* @var \Magento\Framework\DomDocument\DomDocumentFactory | ||
*/ | ||
private $documentFactory; | ||
|
||
/** | ||
* DomDocumentFactory constructor. | ||
* @param \Magento\Framework\DomDocument\DomDocumentFactory $documentFactory | ||
*/ | ||
public function __construct(\Magento\Framework\DomDocument\DomDocumentFactory $documentFactory) | ||
{ | ||
$this->documentFactory = $documentFactory; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create(string $data = null) | ||
{ | ||
$dom = $this->documentFactory->create($data); | ||
|
||
if (empty($data)) { | ||
$this->initializeDocument($dom); | ||
} | ||
|
||
return $dom; | ||
} | ||
|
||
/** | ||
* Initialize document to be used as 'misc.xml' | ||
* | ||
* @param DOMDocument $document | ||
* @return DOMDocument | ||
*/ | ||
private function initializeDocument(DOMDocument $document) | ||
{ | ||
$document->xmlVersion = '1.0'; | ||
$projectNode = $document->createElement('project'); | ||
|
||
//PhpStorm 9 version for component is "4" | ||
$projectNode->setAttribute('version', '4'); | ||
$document->appendChild($projectNode); | ||
$rootComponentNode = $document->createElement('component'); | ||
|
||
//PhpStorm 9 version for ProjectRootManager is "2" | ||
$rootComponentNode->setAttribute('version', '2'); | ||
$rootComponentNode->setAttribute('name', 'ProjectRootManager'); | ||
$projectNode->appendChild($rootComponentNode); | ||
|
||
return $document; | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
lib/internal/Magento/Framework/Test/Unit/DomDocument/DomDocumentFactoryTest.php
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,21 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Framework\Test\Unit\DomDocument; | ||
|
||
use Magento\Framework\DomDocument\DomDocumentFactory; | ||
|
||
class DomDocumentFactoryTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testCreateReturnsDomDocument() | ||
{ | ||
$domDocumentFactory = new DomDocumentFactory(); | ||
$this->assertInstanceOf( | ||
\DOMDocument::class, | ||
$domDocumentFactory->create() | ||
); | ||
} | ||
} |