[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Installer/ -> InstallerExtension.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\Installer;
  11  
  12  use Joomla\CMS\Application\ApplicationHelper;
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Log\Log;
  15  use Joomla\CMS\Object\CMSObject;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('JPATH_PLATFORM') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Extension object
  23   *
  24   * @since  3.1
  25   */
  26  class InstallerExtension extends CMSObject
  27  {
  28      /**
  29       * Filename of the extension
  30       *
  31       * @var    string
  32       * @since  3.1
  33       */
  34      public $filename = '';
  35  
  36      /**
  37       * Type of the extension
  38       *
  39       * @var    string
  40       * @since  3.1
  41       */
  42      public $type = '';
  43  
  44      /**
  45       * Unique Identifier for the extension
  46       *
  47       * @var    string
  48       * @since  3.1
  49       */
  50      public $id = '';
  51  
  52      /**
  53       * The status of the extension
  54       *
  55       * @var    boolean
  56       * @since  3.1
  57       */
  58      public $published = false;
  59  
  60      /**
  61       * String representation of client. Valid for modules, templates and languages.
  62       * Set by default to site.
  63       *
  64       * @var    string
  65       * @since  3.1
  66       */
  67      public $client = 'site';
  68  
  69      /**
  70       * The group name of the plugin. Not used for other known extension types (only plugins)
  71       *
  72       * @var string
  73       * @since  3.1
  74       */
  75      public $group = '';
  76  
  77      /**
  78       * An object representation of the manifest file stored metadata
  79       *
  80       * @var object
  81       * @since  3.1
  82       */
  83      public $manifest_cache = null;
  84  
  85      /**
  86       * An object representation of the extension params
  87       *
  88       * @var    object
  89       * @since  3.1
  90       */
  91      public $params = null;
  92  
  93      /**
  94       * The namespace of the extension
  95       *
  96       * @var    string
  97       * @since  4.0.0
  98       */
  99      public $namespace = null;
 100  
 101      /**
 102       * Constructor
 103       *
 104       * @param   \SimpleXMLElement  $element  A SimpleXMLElement from which to load data from
 105       *
 106       * @since  3.1
 107       */
 108      public function __construct(\SimpleXMLElement $element = null)
 109      {
 110          if ($element) {
 111              $this->type = (string) $element->attributes()->type;
 112              $this->id = (string) $element->attributes()->id;
 113  
 114              switch ($this->type) {
 115                  case 'component':
 116                      // By default a component doesn't have anything
 117                      break;
 118  
 119                  case 'module':
 120                  case 'template':
 121                  case 'language':
 122                      $this->client = (string) $element->attributes()->client;
 123                      $tmp_client_id = ApplicationHelper::getClientInfo($this->client, 1);
 124  
 125                      if ($tmp_client_id == null) {
 126                          Log::add(Text::_('JLIB_INSTALLER_ERROR_EXTENSION_INVALID_CLIENT_IDENTIFIER'), Log::WARNING, 'jerror');
 127                      } else {
 128                          $this->client_id = $tmp_client_id->id;
 129                      }
 130                      break;
 131  
 132                  case 'plugin':
 133                      $this->group = (string) $element->attributes()->group;
 134                      break;
 135  
 136                  default:
 137                      // Catch all
 138                      // Get and set client and group if we don't recognise the extension
 139                      if ($element->attributes()->client) {
 140                          $this->client_id = ApplicationHelper::getClientInfo($this->client, 1);
 141                          $this->client_id = $this->client_id->id;
 142                      }
 143  
 144                      if ($element->attributes()->group) {
 145                          $this->group = (string) $element->attributes()->group;
 146                      }
 147                      break;
 148              }
 149  
 150              $this->filename = (string) $element;
 151          }
 152      }
 153  }


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