Spamworldpro Mini Shell
Spamworldpro


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/cartforge.co/app/code/Xtento/XtCore/Model/ResourceModel/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Xtento/XtCore/Model/ResourceModel/Config.php
<?php

/**
 * Product:       Xtento_XtCore
 * ID:            u66QkJ5rBwmimhUzUElhIKqqWRvsbhC3WLqSMk5AjmQ=
 * Last Modified: 2017-08-16T08:52:13+00:00
 * File:          app/code/Xtento/XtCore/Model/ResourceModel/Config.php
 * Copyright:     Copyright (c) XTENTO GmbH & Co. KG <[email protected]> / All rights reserved.
 */

namespace Xtento\XtCore\Model\ResourceModel;

class Config extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    protected static $configTablesCreated = null;

    protected function _construct()
    {
        $this->_init('xtento_xtcore_config_data', 'config_id');
    }

    /**
     * Save config value
     *
     * @param $path
     * @param $value
     *
     * @return $this
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function saveConfig($path, $value)
    {
        if (!$this->getConfigTablesCreated()) {
            return $this;
        }

        $writeAdapter = $this->getConnection();
        $select = $writeAdapter->select()
            ->from($this->getMainTable())
            ->where('path=?', $path);
        $row = $writeAdapter->fetchRow($select);

        $newData = [
            'path' => $path,
            'value' => $value
        ];

        if ($row) {
            $whereCondition = $writeAdapter->quoteInto($this->getIdFieldName() . '=?', $row[$this->getIdFieldName()]);
            $writeAdapter->update($this->getMainTable(), $newData, $whereCondition);
        } else {
            $writeAdapter->insert($this->getMainTable(), $newData);
        }
        return $this;
    }

    /**
     * Delete config value
     *
     * @param $path
     *
     * @return $this
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function deleteConfig($path)
    {
        if (!$this->getConfigTablesCreated()) {
            return $this;
        }

        $writeAdapter = $this->getConnection();
        $writeAdapter->delete(
            $this->getMainTable(),
            [
                $writeAdapter->quoteInto('path=?', $path)
            ]
        );
        return $this;
    }

    /**
     * Get config value
     *
     * @param $path
     *
     * @return null
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getConfigValue($path)
    {
        if (!$this->getConfigTablesCreated()) {
            return null;
        }

        $readAdapter = $this->getConnection();
        $select = $readAdapter->select()
            ->from($this->getMainTable())
            ->where('path=?', $path);
        $row = $readAdapter->fetchRow($select);

        if ($row) {
            return $row['value'];
        } else {
            return null;
        }
    }

    protected function getConfigTablesCreated()
    {
        // Check if DB table(s) have been created.
        if (self::$configTablesCreated !== null) {
            return self::$configTablesCreated;
        } else {
            try {
                self::$configTablesCreated = ($this->getConnection()->showTableStatus($this->getMainTable()) !== false);
            } catch (\Exception $e) {
                return false;
            }
            return self::$configTablesCreated;
        }
    }
}

Spamworldpro Mini