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-release-notification
Model
ResourceModel
Viewer
Logger.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\ReleaseNotification\Model\ResourceModel\Viewer
;
9
10
use
Magento\ReleaseNotification\Model\Viewer\Log
;
11
use Magento\ReleaseNotification\Model\Viewer\LogFactory;
12
use
Magento\Framework\App\ResourceConnection
;
13
19
class
Logger
20
{
24
const
LOG_TABLE_NAME
=
'release_notification_viewer_log'
;
25
29
private
$resource;
30
34
private
$logFactory;
35
41
public
function
__construct
(
42
ResourceConnection
$resource,
43
LogFactory $logFactory
44
) {
45
$this->resource =
$resource
;
46
$this->logFactory =
$logFactory
;
47
}
48
56
public
function
log(
int
$viewerId,
string
$lastViewVersion) : bool
57
{
59
$connection
= $this->resource->getConnection(
ResourceConnection::DEFAULT_CONNECTION
);
60
$connection
->insertOnDuplicate(
61
$this->resource->getTableName(self::LOG_TABLE_NAME),
62
[
63
'viewer_id'
=> $viewerId,
64
'last_view_version'
=> $lastViewVersion
65
],
66
[
67
'last_view_version'
68
]
69
);
70
return
true
;
71
}
72
79
public
function
get
(
int
$viewerId) :
Log
80
{
81
return
$this->logFactory->create([
'data'
=> $this->loadLogData($viewerId)]);
82
}
83
90
private
function
loadLogData(
int
$viewerId) : array
91
{
92
$connection
= $this->resource->getConnection();
93
$select
=
$connection
->select()
94
->from($this->resource->getTableName(self::LOG_TABLE_NAME))
95
->where(
'viewer_id = ?'
, $viewerId);
96
97
$data
=
$connection
->fetchRow(
$select
);
98
if
(!
$data
) {
99
$data
= [];
100
}
101
return
$data
;
102
}
103
}
$logFactory
$logFactory
Definition:
failed_logins_backend.php:13
Magento\ReleaseNotification\Model\ResourceModel\Viewer\Logger\__construct
__construct(ResourceConnection $resource, LogFactory $logFactory)
Definition:
Logger.php:41
Magento\ReleaseNotification\Model\ResourceModel\Viewer\Logger\LOG_TABLE_NAME
const LOG_TABLE_NAME
Definition:
Logger.php:24
$resource
$resource
Definition:
bulk.php:12
$select
$select
Definition:
catalog_rule_10_off_not_logged_rollback.php:14
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento\Framework\App\ResourceConnection\DEFAULT_CONNECTION
const DEFAULT_CONNECTION
Definition:
ResourceConnection.php:26
Magento\ReleaseNotification\Model\Viewer\Log
Definition:
Log.php:13
Magento\Framework\App\ResourceConnection
Definition:
ResourceConnection.php:18
$connection
$connection
Definition:
bulk.php:13
Magento\Framework\App\ResourceConnection
Magento\ReleaseNotification\Model\ResourceModel\Viewer\Logger
Definition:
Logger.php:19
Magento\ReleaseNotification\Model\ResourceModel\Viewer
Definition:
LoggerTest.php:6