Skip to content

Commit 1dfd160

Browse files
committed
Fix XSD location of test files
1 parent 4149122 commit 1dfd160

18 files changed

+124
-66
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# CHANGELOG
22

3+
## 1.3.4
4+
5+
* *Bugfix:* Set correct XSD URN
6+
* *Bugfix:* Pin composer to Version 1
7+
8+
## 1.3.3
9+
10+
* *Bugfix:* Fix return type of convert on error
11+
12+
## 1.3.2
13+
14+
* *Bugfix:* Fix xml schema reference to pass magento static tests
15+
16+
## 1.3.0 / 1.3.1
17+
18+
* *Feature:* Add Magento 2.4 support
19+
* *Feature:* Add phpUnit 9 support
20+
21+
## 1.2.4
22+
23+
* *Feature:* Enable PHP 7.2 support
24+
* *Feature:* Enable PHP 7.3 support
25+
* *Feature:* Add command to add blocks and pages
26+
327
## 1.2.2 / 1.2.3
428

529
* *Bugfix:* `composer.json` blocked installation of the module in Magento 2.2

Controller/Adminhtml/Block/Save.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77

88
namespace Firegento\ContentProvisioning\Controller\Adminhtml\Block;
99

10+
use Exception;
1011
use Firegento\ContentProvisioning\Model\Command\ApplyBlockEntry;
1112
use Firegento\ContentProvisioning\Model\Query\GetBlockEntryByBlock;
1213
use Magento\Backend\App\Action\Context;
14+
use Magento\Backend\Model\View\Result\Redirect;
1315
use Magento\Cms\Api\BlockRepositoryInterface;
1416
use Magento\Cms\Model\Block;
1517
use Magento\Cms\Model\BlockFactory;
1618
use Magento\Framework\App\Action\HttpPostActionInterface;
19+
use Magento\Framework\App\ObjectManager;
1720
use Magento\Framework\App\Request\DataPersistorInterface;
21+
use Magento\Framework\Controller\ResultInterface;
1822
use Magento\Framework\Exception\LocalizedException;
1923
use Magento\Framework\Registry;
2024

@@ -66,9 +70,9 @@ public function __construct(
6670
) {
6771
$this->dataPersistor = $dataPersistor;
6872
$this->blockFactory = $blockFactory
69-
?: \Magento\Framework\App\ObjectManager::getInstance()->get(BlockFactory::class);
73+
?: ObjectManager::getInstance()->get(BlockFactory::class);
7074
$this->blockRepository = $blockRepository
71-
?: \Magento\Framework\App\ObjectManager::getInstance()->get(BlockRepositoryInterface::class);
75+
?: ObjectManager::getInstance()->get(BlockRepositoryInterface::class);
7276
parent::__construct($context, $coreRegistry);
7377
$this->getBlockEntryByBlock = $getBlockEntryByBlock;
7478
$this->applyBlockEntry = $applyBlockEntry;
@@ -78,11 +82,11 @@ public function __construct(
7882
* Save action
7983
*
8084
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
81-
* @return \Magento\Framework\Controller\ResultInterface
85+
* @return ResultInterface
8286
*/
8387
public function execute()
8488
{
85-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
89+
/** @var Redirect $resultRedirect */
8690
$resultRedirect = $this->resultRedirectFactory->create();
8791
$data = $this->getRequest()->getPostValue();
8892
if ($data) {
@@ -93,7 +97,7 @@ public function execute()
9397
$data['block_id'] = null;
9498
}
9599

96-
/** @var \Magento\Cms\Model\Block $model */
100+
/** @var Block $model */
97101
$model = $this->blockFactory->create();
98102

99103
$id = $this->getRequest()->getParam('block_id');
@@ -115,7 +119,7 @@ public function execute()
115119
return $this->processBlockReturn($model, $data, $resultRedirect);
116120
} catch (LocalizedException $e) {
117121
$this->messageManager->addErrorMessage($e->getMessage());
118-
} catch (\Exception $e) {
122+
} catch (Exception $e) {
119123
$this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the block.'));
120124
}
121125

@@ -128,11 +132,11 @@ public function execute()
128132
/**
129133
* Process and set the block return
130134
*
131-
* @param \Magento\Cms\Model\Block $model
135+
* @param Block $model
132136
* @param array $data
133-
* @param \Magento\Framework\Controller\ResultInterface $resultRedirect
137+
* @param ResultInterface $resultRedirect
134138
*
135-
* @return \Magento\Framework\Controller\ResultInterface
139+
* @return ResultInterface
136140
* @throws LocalizedException
137141
*/
138142
private function processBlockReturn($model, $data, $resultRedirect)

Controller/Adminhtml/Page/Save.php

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@
77

88
namespace Firegento\ContentProvisioning\Controller\Adminhtml\Page;
99

10+
use Exception;
1011
use Firegento\ContentProvisioning\Model\Command\ApplyPageEntry;
1112
use Firegento\ContentProvisioning\Model\Query\GetPageEntryByPage;
1213
use Magento\Backend\App\Action;
14+
use Magento\Backend\Model\View\Result\Redirect;
15+
use Magento\Cms\Api\Data\PageInterface;
16+
use Magento\Cms\Api\PageRepositoryInterface;
1317
use Magento\Cms\Controller\Adminhtml\Page\PostDataProcessor;
1418
use Magento\Cms\Model\Page;
19+
use Magento\Cms\Model\PageFactory;
1520
use Magento\Framework\App\Action\HttpPostActionInterface;
21+
use Magento\Framework\App\ObjectManager;
1622
use Magento\Framework\App\Request\DataPersistorInterface;
23+
use Magento\Framework\Controller\ResultInterface;
1724
use Magento\Framework\Exception\LocalizedException;
1825

1926
/**
2027
* Save CMS page action.
2128
*/
22-
class Save extends \Magento\Backend\App\Action implements HttpPostActionInterface
29+
class Save extends Action implements HttpPostActionInterface
2330
{
2431
/**
2532
* Authorization level of a basic admin session
@@ -39,12 +46,12 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
3946
protected $dataPersistor;
4047

4148
/**
42-
* @var \Magento\Cms\Model\PageFactory
49+
* @var PageFactory
4350
*/
4451
private $pageFactory;
4552

4653
/**
47-
* @var \Magento\Cms\Api\PageRepositoryInterface
54+
* @var PageRepositoryInterface
4855
*/
4956
private $pageRepository;
5057

@@ -62,25 +69,25 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
6269
* @param Action\Context $context
6370
* @param PostDataProcessor $dataProcessor
6471
* @param DataPersistorInterface $dataPersistor
65-
* @param \Magento\Cms\Model\PageFactory|null $pageFactory
66-
* @param \Magento\Cms\Api\PageRepositoryInterface|null $pageRepository
72+
* @param PageFactory|null $pageFactory
73+
* @param PageRepositoryInterface|null $pageRepository
6774
*/
6875
public function __construct(
6976
Action\Context $context,
7077
PostDataProcessor $dataProcessor,
7178
DataPersistorInterface $dataPersistor,
7279
GetPageEntryByPage $getPageEntryByPage,
7380
ApplyPageEntry $applyPageEntry,
74-
\Magento\Cms\Model\PageFactory $pageFactory = null,
75-
\Magento\Cms\Api\PageRepositoryInterface $pageRepository = null
81+
PageFactory $pageFactory = null,
82+
PageRepositoryInterface $pageRepository = null
7683
) {
7784
$this->dataProcessor = $dataProcessor;
7885
$this->dataPersistor = $dataPersistor;
7986
$this->pageFactory = $pageFactory
80-
?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Cms\Model\PageFactory::class);
87+
?: ObjectManager::getInstance()->get(PageFactory::class);
8188
$this->pageRepository = $pageRepository
82-
?: \Magento\Framework\App\ObjectManager::getInstance()
83-
->get(\Magento\Cms\Api\PageRepositoryInterface::class);
89+
?: ObjectManager::getInstance()
90+
->get(PageRepositoryInterface::class);
8491
parent::__construct($context);
8592
$this->getPageEntryByPage = $getPageEntryByPage;
8693
$this->applyPageEntry = $applyPageEntry;
@@ -90,12 +97,12 @@ public function __construct(
9097
* Save action
9198
*
9299
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
93-
* @return \Magento\Framework\Controller\ResultInterface
100+
* @return ResultInterface
94101
*/
95102
public function execute()
96103
{
97104
$data = $this->getRequest()->getPostValue();
98-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
105+
/** @var Redirect $resultRedirect */
99106
$resultRedirect = $this->resultRedirectFactory->create();
100107
if ($data) {
101108
$data = $this->dataProcessor->filter($data);
@@ -106,7 +113,7 @@ public function execute()
106113
$data['page_id'] = null;
107114
}
108115

109-
/** @var \Magento\Cms\Model\Page $model */
116+
/** @var Page $model */
110117
$model = $this->pageFactory->create();
111118

112119
$id = $this->getRequest()->getParam('page_id');
@@ -136,7 +143,7 @@ public function execute()
136143
return $this->processResultRedirect($model, $resultRedirect, $data);
137144
} catch (LocalizedException $e) {
138145
$this->messageManager->addExceptionMessage($e->getPrevious() ?: $e);
139-
} catch (\Exception $e) {
146+
} catch (Exception $e) {
140147
$this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the page.'));
141148
}
142149

@@ -149,10 +156,10 @@ public function execute()
149156
/**
150157
* Process result redirect
151158
*
152-
* @param \Magento\Cms\Api\Data\PageInterface $model
153-
* @param \Magento\Backend\Model\View\Result\Redirect $resultRedirect
159+
* @param PageInterface $model
160+
* @param Redirect $resultRedirect
154161
* @param array $data
155-
* @return \Magento\Backend\Model\View\Result\Redirect
162+
* @return Redirect
156163
* @throws LocalizedException
157164
*/
158165
private function processResultRedirect($model, $resultRedirect, $data)

Model/BlockInstaller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Firegento\ContentProvisioning\Model;
55

6+
use Exception;
67
use Firegento\ContentProvisioning\Model\Command\ApplyBlockEntry;
78
use Firegento\ContentProvisioning\Model\Command\ApplyMediaFiles;
89
use Firegento\ContentProvisioning\Model\Query\GetBlockEntryList;
@@ -70,7 +71,7 @@ public function install(): void
7071
$this->applyBlockEntry->execute($blockEntry);
7172
$this->applyMediaFiles->execute($blockEntry);
7273
}
73-
} catch (\Exception $exception) {
74+
} catch (Exception $exception) {
7475
$this->logger->error(sprintf(
7576
'An error appeared while applying cms block content: %s',
7677
$exception->getMessage()
@@ -81,4 +82,4 @@ public function install(): void
8182
}
8283
}
8384
}
84-
}
85+
}

Model/Config/Converter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Firegento\ContentProvisioning\Model\Config;
55

6+
use Exception;
67
use Magento\Framework\Config\ConverterInterface;
78
use Magento\Framework\Exception\LocalizedException;
89
use Psr\Log\LoggerInterface;
@@ -50,7 +51,7 @@ public function convert($source): array
5051
'pages' => $this->pageNodeConverter->convert($source),
5152
'blocks' => $this->blockNodeConverter->convert($source),
5253
];
53-
} catch (\Exception $exception) {
54+
} catch (Exception $exception) {
5455
$this->logger->error($exception->getMessage(), $exception->getTrace());
5556
}
5657
return [];

Model/Config/SchemaLocator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
namespace Firegento\ContentProvisioning\Model\Config;
55

6+
use Magento\Framework\Config\SchemaLocatorInterface;
7+
use Magento\Framework\Module\Dir;
68
use Magento\Framework\Module\Dir\Reader;
79

8-
class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
10+
class SchemaLocator implements SchemaLocatorInterface
911
{
1012
/**
1113
* Path to corresponding XSD file with validation rules for merged config
@@ -27,7 +29,7 @@ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
2729
public function __construct(Reader $moduleReader)
2830
{
2931
$etcDir = $moduleReader->getModuleDir(
30-
\Magento\Framework\Module\Dir::MODULE_ETC_DIR,
32+
Dir::MODULE_ETC_DIR,
3133
'Firegento_ContentProvisioning'
3234
);
3335
$this->_schema = $etcDir . '/content_provisioning.xsd';

Model/PageInstaller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Firegento\ContentProvisioning\Model;
55

6+
use Exception;
67
use Firegento\ContentProvisioning\Model\Command\ApplyMediaFiles;
78
use Firegento\ContentProvisioning\Model\Command\ApplyPageEntry;
89
use Firegento\ContentProvisioning\Model\Query\GetPageEntryList;
@@ -70,7 +71,7 @@ public function install(): void
7071
$this->applyPageEntry->execute($pageEntry);
7172
$this->applyMediaFiles->execute($pageEntry);
7273
}
73-
} catch (\Exception $exception) {
74+
} catch (Exception $exception) {
7475
$this->logger->error(sprintf(
7576
'An error appeared while applying cms page content: %s',
7677
$exception->getMessage()
@@ -81,4 +82,4 @@ public function install(): void
8182
}
8283
}
8384
}
84-
}
85+
}

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ composer require firegento/magento2-content-provisioning
3333

3434
## How it works
3535

36-
After installing this module you can create own `content_provisioning.xml` in each of your modules.
36+
After installing this module you can create your own `content_provisioning.xml` in each of your modules.
3737

3838
## Example configurations
3939

@@ -60,9 +60,9 @@ After installing this module you can create own `content_provisioning.xml` in ea
6060
<content heading="New Page Heading" type="file">Your_Module::path/to/content.html</content>
6161
<media_directory>Your_Module::path/to/media</media_directory>
6262
<stores>
63-
<store code="germany_german" />
64-
<store code="swiss_german" />
65-
<store code="austria_german" />
63+
<store code="germany_german"/>
64+
<store code="swiss_german"/>
65+
<store code="austria_german"/>
6666
</stores>
6767
<seo>
6868
<title>SEO Page Title</title>
@@ -107,9 +107,9 @@ After installing this module you can create own `content_provisioning.xml` in ea
107107
<content type="file">Your_Module::path/to/content.html</content>
108108
<media_directory>Your_Module::path/to/media</media_directory>
109109
<stores>
110-
<store code="germany_german" />
111-
<store code="swiss_german" />
112-
<store code="austria_german" />
110+
<store code="germany_german"/>
111+
<store code="swiss_german"/>
112+
<store code="austria_german"/>
113113
</stores>
114114
</block>
115115
...

Test/Integration/Model/BlockInstaller/TestCase.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Firegento\ContentProvisioning\Model\Query\GetFirstBlockByBlockEntry;
1111
use Magento\Cms\Api\Data\BlockInterface;
1212
use Magento\Framework\App\ResourceConnection;
13+
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Framework\Exception\NoSuchEntityException;
1315
use Magento\Store\Model\StoreManagerInterface;
1416
use Magento\TestFramework\Helper\Bootstrap;
1517
use PHPUnit\Framework\MockObject\MockObject;
@@ -118,8 +120,8 @@ protected function compareBlockWithEntryForStore($entryIndex)
118120
/**
119121
* @param BlockEntryInterface $entry
120122
* @return BlockInterface
121-
* @throws \Magento\Framework\Exception\NoSuchEntityException
122-
* @throws \Magento\Framework\Exception\LocalizedException
123+
* @throws NoSuchEntityException
124+
* @throws LocalizedException
123125
*/
124126
protected function getBlockByBlockEntry(BlockEntryInterface $entry): BlockInterface
125127
{

0 commit comments

Comments
 (0)