Skip to content

Commit 16e2f00

Browse files
committed
Merge remote-tracking branch 'origin/develop' into refactor/test-names
# Conflicts: # app/code/Magento/PageBuilder/Test/Mftf/Test/AdminCatalogCategoryPageBuilderTest.xml # app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderBlockRenderLayoutContentTypesTest.xml # app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderBlockRenderMediaContentTypesTest.xml
2 parents d5db946 + fe9daa1 commit 16e2f00

File tree

385 files changed

+31006
-2856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

385 files changed

+31006
-2856
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageBuilder\Api\Data;
8+
9+
use Magento\Framework\Api\ExtensionAttributesInterface;
10+
11+
/**
12+
* Extension interface for templates
13+
*/
14+
interface TemplateExtensionInterface extends ExtensionAttributesInterface
15+
{
16+
17+
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageBuilder\Api\Data;
8+
9+
use Magento\Framework\Api\ExtensibleDataInterface;
10+
11+
/**
12+
* Template Manager template interface
13+
*/
14+
interface TemplateInterface extends ExtensibleDataInterface
15+
{
16+
const KEY_ID = 'template_id';
17+
18+
const KEY_NAME = 'name';
19+
20+
const KEY_PREVIEW_IMAGE = 'preview_image';
21+
22+
const KEY_TEMPLATE = 'template';
23+
24+
const KEY_CREATED_FOR = 'created_for';
25+
26+
const KEY_CREATED_AT = 'created_at';
27+
28+
const KEY_UPDATED_AT = 'updated_at';
29+
30+
/**
31+
* Get Template ID
32+
*
33+
* @return int|null
34+
*/
35+
public function getId();
36+
37+
/**
38+
* Set the templates ID
39+
*
40+
* @param int $templateId
41+
* @return TemplateInterface
42+
*/
43+
public function setId($templateId);
44+
45+
/**
46+
* Retrieve name of template
47+
*
48+
* @return string|null
49+
*/
50+
public function getName() : string;
51+
52+
/**
53+
* Set the name of the template
54+
*
55+
* @param string $name
56+
* @return TemplateInterface
57+
*/
58+
public function setName(string $name) : TemplateInterface;
59+
60+
/**
61+
* Retrieve the preview image
62+
*
63+
* @return string
64+
*/
65+
public function getPreviewImage() : string;
66+
67+
/**
68+
* Set the preview image
69+
*
70+
* @param string $path
71+
* @return TemplateInterface
72+
*/
73+
public function setPreviewImage(string $path) : TemplateInterface;
74+
75+
/**
76+
* Get the thumbnail image for the preview
77+
*
78+
* @return string
79+
*/
80+
public function getPreviewThumbnailImage() : string;
81+
82+
/**
83+
* Retrieve template value
84+
*
85+
* @return string
86+
*/
87+
public function getTemplate() : string;
88+
89+
/**
90+
* Set template value
91+
*
92+
* @param string $template
93+
* @return TemplateInterface
94+
*/
95+
public function setTemplate(string $template) : TemplateInterface;
96+
97+
/**
98+
* Retrieve created for value, created for is a user provided field with entity names as values such as Page
99+
*
100+
* @return string
101+
*/
102+
public function getCreatedFor() : string;
103+
104+
/**
105+
* Set the created for value
106+
*
107+
* @param string $createdFor
108+
* @return TemplateInterface
109+
*/
110+
public function setCreatedFor(string $createdFor) : TemplateInterface;
111+
112+
/**
113+
* Retrieve the updated at date
114+
*
115+
* @return mixed
116+
*/
117+
public function getUpdatedAt() : string;
118+
119+
/**
120+
* Set updated at date
121+
*
122+
* @param string $updatedAt
123+
* @return TemplateInterface
124+
*/
125+
public function setUpdatedAt(string $updatedAt) : TemplateInterface;
126+
127+
/**
128+
* Get the created at date
129+
*
130+
* @return string
131+
*/
132+
public function getCreatedAt() : string;
133+
134+
/**
135+
* Set the created at date
136+
*
137+
* @param string $createdAt
138+
* @return TemplateInterface
139+
*/
140+
public function setCreatedAt(string $createdAt) : TemplateInterface;
141+
142+
/**
143+
* Retrieve existing extension attributes object or create a new one
144+
*
145+
* @return \Magento\PageBuilder\Api\Data\TemplateExtensionInterface|null
146+
*/
147+
public function getExtensionAttributes();
148+
149+
/**
150+
* Set an extension attributes object
151+
*
152+
* @param \Magento\PageBuilder\Api\Data\TemplateExtensionInterface $extensionAttributes
153+
* @return $this
154+
*/
155+
public function setExtensionAttributes(
156+
\Magento\PageBuilder\Api\Data\TemplateExtensionInterface $extensionAttributes
157+
);
158+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageBuilder\Api\Data;
8+
9+
use Magento\Framework\Api\SearchResultsInterface;
10+
11+
interface TemplateSearchResultsInterface extends SearchResultsInterface
12+
{
13+
/**
14+
* Get template list
15+
*
16+
* @return TemplateInterface[]
17+
*/
18+
public function getItems();
19+
20+
/**
21+
* Set template list
22+
*
23+
* @param TemplateInterface[] $items
24+
* @return $this
25+
*/
26+
public function setItems(array $items);
27+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageBuilder\Api;
8+
9+
use Magento\Framework\Api\SearchCriteriaInterface;
10+
use Magento\PageBuilder\Api\Data\TemplateInterface;
11+
use Magento\PageBuilder\Api\Data\TemplateSearchResultsInterface;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Exception\NoSuchEntityException;
14+
15+
interface TemplateRepositoryInterface
16+
{
17+
/**
18+
* Save Template
19+
*
20+
* @param TemplateInterface $template
21+
* @return TemplateInterface
22+
* @throws LocalizedException
23+
*/
24+
public function save(TemplateInterface $template) : TemplateInterface;
25+
26+
/**
27+
* Retrieve Template
28+
*
29+
* @param string $templateId
30+
* @return TemplateInterface
31+
* @throws LocalizedException
32+
*/
33+
public function get($templateId) : TemplateInterface;
34+
35+
/**
36+
* Retrieve Template matching the specified criteria.
37+
*
38+
* @param SearchCriteriaInterface $searchCriteria
39+
* @return TemplateSearchResultsInterface
40+
* @throws LocalizedException
41+
*/
42+
public function getList(SearchCriteriaInterface $searchCriteria);
43+
44+
/**
45+
* Delete Template
46+
*
47+
* @param TemplateInterface $template
48+
* @return bool true on success
49+
* @throws LocalizedException
50+
*/
51+
public function delete(TemplateInterface $template) : bool;
52+
53+
/**
54+
* Delete Template by ID
55+
*
56+
* @param string $templateId
57+
* @return bool true on success
58+
* @throws NoSuchEntityException
59+
* @throws LocalizedException
60+
*/
61+
public function deleteById($templateId) : bool;
62+
}

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductTotals.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ public function execute()
5454
$conditions = $this->getRequest()->getParam('conditionValue');
5555

5656
try {
57-
$totals = $this->productTotals->getProductTotals($conditions);
58-
$response = [
59-
'total' => $totals['total'],
60-
'disabled' => $totals['disabled'],
61-
'notVisible' => $totals['notVisible'],
62-
'outOfStock' => $totals['outOfStock'],
63-
];
57+
$response = $this->productTotals->getProductTotals($conditions);
6458
} catch (Exception $e) {
6559
$response = [
6660
'total' => 0,
6761
'disabled' => 0,
6862
'notVisible' => 0,
69-
'outOfStock' => 0,
7063
];
7164
}
7265

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Controller\Adminhtml\Template;
10+
11+
use Magento\Backend\App\Action;
12+
use Magento\Backend\App\Action\Context;
13+
use Magento\Framework\App\Action\HttpPostActionInterface;
14+
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\PageBuilder\Api\Data\TemplateInterface;
16+
use Magento\PageBuilder\Api\TemplateRepositoryInterface;
17+
use Magento\Backend\Model\View\Result\Redirect;
18+
use Psr\Log\LoggerInterface;
19+
20+
/**
21+
* Delete a template within template manager
22+
*/
23+
class Delete extends Action implements HttpPostActionInterface
24+
{
25+
const ADMIN_RESOURCE = 'Magento_PageBuilder::template_delete';
26+
27+
/**
28+
* @var LoggerInterface
29+
*/
30+
private $logger;
31+
32+
/**
33+
* @var TemplateRepositoryInterface
34+
*/
35+
private $templateRepository;
36+
37+
/**
38+
* @param Context $context
39+
* @param LoggerInterface $logger
40+
* @param TemplateRepositoryInterface $templateRepository
41+
*/
42+
public function __construct(
43+
Context $context,
44+
LoggerInterface $logger,
45+
TemplateRepositoryInterface $templateRepository
46+
) {
47+
parent::__construct($context);
48+
49+
$this->logger = $logger;
50+
$this->templateRepository = $templateRepository;
51+
}
52+
53+
/**
54+
* Delete a template from the database
55+
*
56+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
57+
*/
58+
public function execute()
59+
{
60+
/** @var Redirect $resultRedirect */
61+
$resultRedirect = $this->resultRedirectFactory->create();
62+
63+
$request = $this->getRequest();
64+
65+
try {
66+
$this->templateRepository->deleteById($request->getParam(TemplateInterface::KEY_ID));
67+
68+
$this->messageManager->addSuccessMessage(__('Template successfully deleted.'));
69+
return $resultRedirect->setPath('*/*/');
70+
} catch (LocalizedException $e) {
71+
$this->messageManager->addErrorMessage($e->getMessage());
72+
return $resultRedirect->setPath('*/*/');
73+
} catch (\Exception $e) {
74+
$this->logger->critical($e);
75+
76+
$this->messageManager->addErrorMessage(__('An error occurred while trying to delete this template.'));
77+
return $resultRedirect->setPath('*/*/');
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)