![]() 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/Setup/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See LICENSE.txt for license details. */ namespace Ecombricks\Framework\Setup; /** * Module data setup trait */ trait ModuleDataSetupTrait { /** * Setup * * @var \Magento\Framework\Setup\ModuleDataSetupInterface */ protected $setup; /** * Set setup * * @param \Magento\Framework\Setup\ModuleDataSetupInterface $setup * @return $this */ protected function setSetup(\Magento\Framework\Setup\ModuleDataSetupInterface $setup) { $this->setup = $setup; return $this; } /** * Get setup * * @return \Magento\Framework\Setup\ModuleDataSetupInterface */ protected function getSetup() { if (empty($this->setup) || !($this->setup instanceof \Magento\Framework\Setup\ModuleDataSetupInterface)) { throw new \Magento\Framework\Exception\LocalizedException(__('Setup is undefined for the module data installer.')); } return $this->setup; } /** * Get connection * * @return \Magento\Framework\DB\Adapter\AdapterInterface */ protected function getConnection() { return $this->getSetup()->getConnection(); } /** * Get table * * @param string $tableName * @return string */ protected function getTable($tableName) { return $this->getSetup()->getTable($tableName); } /** * Describe table * * @param string $tableName * @return array */ protected function describeTable($tableName) { return $this->getConnection()->describeTable($this->getTable($tableName)); } /** * Get columns * * @param string $tableName * @return array */ protected function getColumns($tableName) { $connection = $this->getConnection(); $columns = []; foreach ($this->describeTable($tableName) as $columnDdl) { $columns[] = $connection->getColumnCreateByDescribe($columnDdl); } return $columns; } }