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-analytics
Model
Config
Backend
CollectionTime.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Analytics\Model\Config\Backend
;
7
8
use
Magento\Framework\App\Cache\TypeListInterface
;
9
use
Magento\Framework\App\Config\ScopeConfigInterface
;
10
use
Magento\Framework\App\Config\Storage\WriterInterface
;
11
use
Magento\Framework\App\Config\Value
;
12
use
Magento\Framework\Data\Collection\AbstractDb
;
13
use
Magento\Framework\Exception\LocalizedException
;
14
use
Magento\Framework\Model\Context
;
15
use
Magento\Framework\Model\ResourceModel\AbstractResource
;
16
use
Magento\Framework\Registry
;
17
21
class
CollectionTime
extends
Value
22
{
26
const
CRON_SCHEDULE_PATH
=
'crontab/default/jobs/analytics_collect_data/schedule/cron_expr'
;
27
31
private
$configWriter;
32
43
public
function
__construct
(
44
Context
$context,
45
Registry
$registry
,
46
ScopeConfigInterface
$config
,
47
TypeListInterface
$cacheTypeList
,
48
WriterInterface
$configWriter,
49
AbstractResource
$resource
=
null
,
50
AbstractDb
$resourceCollection =
null
,
51
array $data = []
52
) {
53
$this->configWriter =
$configWriter
;
54
parent::__construct($context,
$registry
,
$config
,
$cacheTypeList
,
$resource
, $resourceCollection,
$data
);
55
}
56
64
public
function
afterSave
()
65
{
66
$result
= preg_match(
'#(?<hour>\d{2}),(?<min>\d{2}),(?<sec>\d{2})#'
, $this->getValue(), $time);
67
68
if
(!
$result
) {
69
throw
new
LocalizedException
(
70
__
(
'The time value is using an unsupported format. Enter a supported format and try again.'
)
71
);
72
}
73
74
$cronExprArray = [
75
$time[
'min'
], # Minute
76
$time[
'hour'
], # Hour
77
'*'
, # Day of the Month
78
'*'
, # Month of the Year
79
'*'
, # Day of the Week
80
];
81
82
$cronExprString = join(
' '
, $cronExprArray);
83
84
try
{
85
$this->configWriter->save(self::CRON_SCHEDULE_PATH, $cronExprString);
86
}
catch
(\Exception $e) {
87
$this->_logger->error($e->getMessage());
88
throw
new
LocalizedException
(
__
(
'Cron settings can\'t be saved'
));
89
}
90
91
return
parent::afterSave();
92
}
93
}
$configWriter
$configWriter
Definition:
enabled_subscription_with_invalid_token.php:13
Magento\Framework\App\Config\Value
Definition:
Value.php:28
$result
$result
Definition:
product_configurable_not_available_rollback.php:26
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\Analytics\Model\Config\Backend\CollectionTime
Definition:
CollectionTime.php:21
$config
$config
Definition:
fraud_order.php:17
Magento\Analytics\Model\Config\Backend\CollectionTime\CRON_SCHEDULE_PATH
const CRON_SCHEDULE_PATH
Definition:
CollectionTime.php:26
__
__()
Definition:
__.php:13
$resource
$resource
Definition:
bulk.php:12
Magento\Analytics\Model\Config\Backend
Magento\Framework\Model\Context
Definition:
Context.php:24
Magento\Analytics\Model\Config\Backend\CollectionTime\__construct
__construct(Context $context, Registry $registry, ScopeConfigInterface $config, TypeListInterface $cacheTypeList, WriterInterface $configWriter, AbstractResource $resource=null, AbstractDb $resourceCollection=null, array $data=[])
Definition:
CollectionTime.php:43
Magento\Framework\Data\Collection\AbstractDb
Definition:
AbstractDb.php:23
$registry
$registry
Definition:
bundle_product_with_not_visible_children_rollback.php:16
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento\Analytics\Model\Config\Backend\CollectionTime\afterSave
afterSave()
Definition:
CollectionTime.php:64
Magento\Framework\App\Cache\TypeListInterface
Definition:
TypeListInterface.php:12
Magento\Framework\Registry
Definition:
Registry.php:18
Magento\Framework\Model\ResourceModel\AbstractResource
Definition:
AbstractResource.php:19
Magento\Framework\App\Config\ScopeConfigInterface
Definition:
ScopeConfigInterface.php:15
Magento\Framework\App\Config\Value\$cacheTypeList
$cacheTypeList
Definition:
Value.php:54
Magento\Framework\App\Config\Storage\WriterInterface
Definition:
WriterInterface.php:16