44 * See COPYING.txt for license details.
55 */
66
7+ declare (strict_types=1 );
8+
79namespace Magento \Analytics \Setup \Patch \Data ;
810
911use Magento \Analytics \Model \Config \Backend \Enabled \SubscriptionHandler ;
12+ use Magento \Config \Model \Config \Source \Enabledisable ;
1013use Magento \Framework \Setup \ModuleDataSetupInterface ;
1114use Magento \Framework \Setup \Patch \DataPatchInterface ;
1215use Magento \Framework \Setup \Patch \PatchVersionInterface ;
1316
1417/**
15- * Initial patch.
16- *
17- * @package Magento\Analytics\Setup\Patch
18+ * Active subscription process for Advanced Reporting
1819 */
1920class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
2021{
@@ -24,66 +25,63 @@ class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
2425 private $ moduleDataSetup ;
2526
2627 /**
27- * PrepareInitialConfig constructor.
28+ * @var SubscriptionHandler
29+ */
30+ private $ subscriptionHandler ;
31+
32+ /**
33+ * @var string
34+ */
35+ private $ subscriptionEnabledConfigPath = 'analytics/subscription/enabled ' ;
36+
37+ /**
2838 * @param ModuleDataSetupInterface $moduleDataSetup
39+ * @param SubscriptionHandler $subscriptionHandler
2940 */
3041 public function __construct (
31- ModuleDataSetupInterface $ moduleDataSetup
42+ ModuleDataSetupInterface $ moduleDataSetup ,
43+ SubscriptionHandler $ subscriptionHandler
3244 ) {
3345 $ this ->moduleDataSetup = $ moduleDataSetup ;
46+ $ this ->subscriptionHandler = $ subscriptionHandler ;
3447 }
3548
3649 /**
37- * {@inheritdoc}
50+ * @inheritDoc
3851 */
3952 public function apply ()
4053 {
41- $ this ->moduleDataSetup ->getConnection ()->insertMultiple (
54+ $ this ->moduleDataSetup ->getConnection ()->insert (
4255 $ this ->moduleDataSetup ->getTable ('core_config_data ' ),
4356 [
44- [
45- 'scope ' => 'default ' ,
46- 'scope_id ' => 0 ,
47- 'path ' => 'analytics/subscription/enabled ' ,
48- 'value ' => 1
49- ],
50- [
51- 'scope ' => 'default ' ,
52- 'scope_id ' => 0 ,
53- 'path ' => SubscriptionHandler::CRON_STRING_PATH ,
54- 'value ' => join (' ' , SubscriptionHandler::CRON_EXPR_ARRAY )
55- ]
57+ 'path ' => $ this ->subscriptionEnabledConfigPath ,
58+ 'value ' => Enabledisable::ENABLE_VALUE ,
5659 ]
5760 );
5861
59- $ this ->moduleDataSetup ->getConnection ()->insert (
60- $ this ->moduleDataSetup ->getTable ('flag ' ),
61- [
62- 'flag_code ' => SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE ,
63- 'state ' => 0 ,
64- 'flag_data ' => 24 ,
65- ]
66- );
62+ $ this ->subscriptionHandler ->processEnabled ();
63+
64+ return $ this ;
6765 }
6866
6967 /**
70- * {@inheritdoc}
68+ * @inheritDoc
7169 */
7270 public static function getDependencies ()
7371 {
7472 return [];
7573 }
7674
7775 /**
78- * {@inheritdoc}
76+ * @inheritDoc
7977 */
8078 public static function getVersion ()
8179 {
8280 return '2.0.0 ' ;
8381 }
8482
8583 /**
86- * {@inheritdoc}
84+ * @inheritDoc
8785 */
8886 public function getAliases ()
8987 {
0 commit comments