Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-cms
Model
GetBlockByIdentifier.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Cms\Model
;
8
9
use
Magento\Cms\Api\GetBlockByIdentifierInterface
;
10
use
Magento\Cms\Api\Data\BlockInterface
;
11
use
Magento\Framework\Exception\NoSuchEntityException
;
12
16
class
GetBlockByIdentifier
implements
GetBlockByIdentifierInterface
17
{
21
private
$blockFactory;
22
26
private
$blockResource;
27
32
public
function
__construct
(
33
\
Magento
\Cms\Model\BlockFactory $blockFactory,
34
\
Magento
\Cms\Model\
ResourceModel
\
Block
$blockResource
35
) {
36
$this->blockFactory = $blockFactory;
37
$this->blockResource = $blockResource;
38
}
39
43
public
function
execute
(
string
$identifier,
int
$storeId
) :
BlockInterface
44
{
45
$block
= $this->blockFactory->create();
46
$block
->setStoreId(
$storeId
);
47
$this->blockResource->load(
$block
, $identifier,
BlockInterface::IDENTIFIER
);
48
49
if
(!
$block
->getId()) {
50
throw
new
NoSuchEntityException
(
__
(
'The CMS block with the "%1" ID doesn\'t exist.'
, $identifier));
51
}
52
53
return
$block
;
54
}
55
}
$storeId
$storeId
Definition:
customer_review_with_rating.php:14
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
Magento\Cms\Model\GetBlockByIdentifier
Definition:
GetBlockByIdentifier.php:16
Magento\Cms\Api\Data\BlockInterface\IDENTIFIER
const IDENTIFIER
Definition:
BlockInterface.php:19
__
__()
Definition:
__.php:13
$block
$block
Definition:
block.php:8
Magento\Cms\Model\Block
Definition:
Block.php:18
Magento\Cms\Model\GetBlockByIdentifier\__construct
__construct(\Magento\Cms\Model\BlockFactory $blockFactory, \Magento\Cms\Model\ResourceModel\Block $blockResource)
Definition:
GetBlockByIdentifier.php:32
Magento\Cms\Model
Definition:
BlockTest.php:6
Magento
Magento\Cms\Api\Data\BlockInterface
Definition:
BlockInterface.php:13
Magento\Cms\Api\GetBlockByIdentifierInterface
Definition:
GetBlockByIdentifierInterface.php:12
Magento\Cms\Model\GetBlockByIdentifier\execute
execute(string $identifier, int $storeId)
Definition:
GetBlockByIdentifier.php:43
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16