![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magefan/module-community/Cron/ |
<?php /** * Copyright © Magefan ([email protected]). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). */ namespace Magefan\Community\Cron; use Magefan\Community\Model\SectionFactory; use Magefan\Community\Model\Section\Info; use Magento\Framework\App\ResourceConnection; /** * Class Sections * @package Magefan\Community */ class Sections { /** * @var SectionFactory */ protected $sectionFactory; /** * @var Info */ protected $info; /** * @var ResourceConnection */ protected $resource; /** * Sections constructor. * @param ResourceConnection $resource * @param SectionFactory $sectionFactory * @param Info $info */ public function __construct( ResourceConnection $resource, SectionFactory $sectionFactory, Info $info ) { $this->resource = $resource; $this->sectionFactory = $sectionFactory; $this->info = $info; } /** * Execute cron job */ public function execute() { $connection = $this->resource->getConnection(); $table = $this->resource->getTableName('core_config_data'); $path = 'gen' . 'er' . 'al'. '/' . 'ena' . 'bled'; $select = $connection->select()->from( [$table] )->where( 'path LIKE ?', '%' . $path ); $sections = []; foreach ($connection->fetchAll($select) as $config) { $matches = false; preg_match("/(.*)\/" . str_replace('/', '\/', $path) . "/", $config['path'], $matches); if (empty($matches[1])) { continue; } $section = $this->sectionFactory->create([ 'name' => $matches[1] ]); if ($section->getModule()) { $sections[$section->getModule()] = $section; } else { unset($section); } } if (count($sections)) { $data = $this->info->load($sections); if ($data && is_array($data)) { foreach ($data as $module => $item) { $section = $sections[$module]; if (!$section->validate($data)) { $connection->update( $table, [ 'value' => 0 ], ['path = ? ' => $section->getName() . '/' . $path] ); } } } } } }