[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Table/ -> Extension.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Table;
  11  
  12  use Joomla\CMS\Language\Text;
  13  use Joomla\Database\DatabaseDriver;
  14  
  15  // phpcs:disable PSR1.Files.SideEffects
  16  \defined('JPATH_PLATFORM') or die;
  17  // phpcs:enable PSR1.Files.SideEffects
  18  
  19  /**
  20   * Extension table
  21   *
  22   * @since  1.7.0
  23   */
  24  class Extension extends Table
  25  {
  26      /**
  27       * Indicates that columns fully support the NULL value in the database
  28       *
  29       * @var    boolean
  30       * @since  4.0.0
  31       */
  32      protected $_supportNullValue = true;
  33  
  34      /**
  35       * Ensure the params in json encoded in the bind method
  36       *
  37       * @var    array
  38       * @since  4.0.0
  39       */
  40      protected $_jsonEncode = ['params'];
  41  
  42      /**
  43       * Custom data can be used by extension developers
  44       *
  45       * @var    string
  46       * @since  4.0.0
  47       */
  48      public $custom_data = '';
  49  
  50      /**
  51       * Constructor
  52       *
  53       * @param   DatabaseDriver  $db  Database driver object.
  54       *
  55       * @since   1.7.0
  56       */
  57      public function __construct(DatabaseDriver $db)
  58      {
  59          parent::__construct('#__extensions', 'extension_id', $db);
  60  
  61          // Set the alias since the column is called enabled
  62          $this->setColumnAlias('published', 'enabled');
  63      }
  64  
  65      /**
  66       * Overloaded check function
  67       *
  68       * @return  boolean  True if the object is ok
  69       *
  70       * @see     Table::check()
  71       * @since   1.7.0
  72       */
  73      public function check()
  74      {
  75          try {
  76              parent::check();
  77          } catch (\Exception $e) {
  78              $this->setError($e->getMessage());
  79  
  80              return false;
  81          }
  82  
  83          // Check for valid name
  84          if (trim($this->name) == '' || trim($this->element) == '') {
  85              $this->setError(Text::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION'));
  86  
  87              return false;
  88          }
  89  
  90          return true;
  91      }
  92  
  93      /**
  94       * Method to create and execute a SELECT WHERE query.
  95       *
  96       * @param   array  $options  Array of options
  97       *
  98       * @return  string  The database query result
  99       *
 100       * @since   1.7.0
 101       */
 102      public function find($options = array())
 103      {
 104          // Get the DatabaseQuery object
 105          $query = $this->_db->getQuery(true);
 106  
 107          foreach ($options as $col => $val) {
 108              $query->where($col . ' = ' . $this->_db->quote($val));
 109          }
 110  
 111          $query->select($this->_db->quoteName('extension_id'))
 112              ->from($this->_db->quoteName('#__extensions'));
 113          $this->_db->setQuery($query);
 114  
 115          return $this->_db->loadResult();
 116      }
 117  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer