![]() 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/Ecombricks/Framework/Plugin/Setup/Declaration/Schema/Dto/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See COPYING.txt for license details. */ namespace Ecombricks\Framework\Plugin\Setup\Declaration\Schema\Dto; /** * Setup declaration DTO schema plugin */ class Schema { /** * Resource connection * * @var \Magento\Framework\App\ResourceConnection */ protected $resourceConnection; /** * Table mapper * * @var \Ecombricks\Framework\App\ResourceConnection\TableMapperInterface */ protected $tableMapper; /** * Tables * * @var \Magento\Framework\Setup\Declaration\Schema\Dto\Table[] */ protected $tables; /** * Constructor * * @param \Magento\Framework\App\ResourceConnection $resourceConnection * @param \Ecombricks\Framework\App\ResourceConnection\TableMapperInterface $tableMapper * @return void */ public function __construct( \Magento\Framework\App\ResourceConnection $resourceConnection, \Ecombricks\Framework\App\ResourceConnection\TableMapperInterface $tableMapper ) { $this->resourceConnection = $resourceConnection; $this->tableMapper = $tableMapper; } /** * Around get table by name * * @param \Magento\Framework\Setup\Declaration\Schema\Dto\Schema $subject * @param \Closure $proceed * @return \Magento\Framework\Setup\Declaration\Schema\Dto\Table[] */ public function aroundGetTables( \Magento\Framework\Setup\Declaration\Schema\Dto\Schema $subject, \Closure $proceed ) { return $this->tables; } /** * Around add table * * @param \Magento\Framework\Setup\Declaration\Schema\Dto\Schema $subject * @param \Closure $proceed * @param \Magento\Framework\Setup\Declaration\Schema\Dto\Table $table * @return \Magento\Framework\Setup\Declaration\Schema\Dto\Schema */ public function aroundAddTable( \Magento\Framework\Setup\Declaration\Schema\Dto\Schema $subject, \Closure $proceed, $table ) { $this->tables[$table->getName()] = $table; return $subject; } /** * Around get table by name * * @param \Magento\Framework\Setup\Declaration\Schema\Dto\Schema $subject * @param \Closure $proceed * @param string $name * @return \Magento\Framework\Setup\Declaration\Schema\Dto\Table */ public function aroundGetTableByName( \Magento\Framework\Setup\Declaration\Schema\Dto\Schema $subject, \Closure $proceed, $name ) { if ($this->tableMapper->isEnabled()) { $this->tableMapper->setIsEnabled(false); $name = $this->resourceConnection->getTableName($name); $this->tableMapper->setIsEnabled(true); } else { $name = $this->resourceConnection->getTableName($name); } return isset($this->tables[$name]) ? $this->tables[$name] : false; } }