Newer
Older

Eduarda Lentz Rodrigues da Silva
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Model\Repository;
use Firegento\ContentProvisioning\Api\CmsBlockRepositoryInterface;
use Magento\Framework\App\ResourceConnection;
class CmsBlockRepository implements CmsBlockRepositoryInterface
{
/**
* @var ResourceConnection
*/
private $resource;
/**
* CmsBlockRepository constructor.
*
* @param ResourceConnection $resource
*/
public function __construct(
ResourceConnection $resource
) {
$this->resource = $resource;
}
/**
* Get CMS Block data by its identifier.
*
* @param string $identifier
* @return array
*/
public function getByIdentifier(string $identifier): array
{
$connection = $this->resource->getConnection();
$tableName = $this->resource->getTableName('cms_block'); // Get table with prefix
$sql = "SELECT * FROM $tableName WHERE identifier = :identifier";
$bind = ['identifier' => $identifier];
$result = $connection->fetchRow($sql, $bind); // Fetch a single row
return $result ? $result : [];
}
}