[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Toolbar/Button/ -> AbstractGroupButton.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2018 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\Toolbar\Button;
  11  
  12  use Joomla\CMS\Toolbar\Toolbar;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('_JEXEC') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * The AbstractGroupButton class.
  20   *
  21   * @since  4.0.0
  22   */
  23  abstract class AbstractGroupButton extends BasicButton
  24  {
  25      /**
  26       * The child Toolbar instance.
  27       *
  28       * @var  Toolbar
  29       *
  30       * @since  4.0.0
  31       */
  32      protected $child;
  33  
  34      /**
  35       * Add children buttons as dropdown.
  36       *
  37       * @param   callable  $handler  The callback to configure dropdown items.
  38       *
  39       * @return  static
  40       *
  41       * @since  4.0.0
  42       */
  43      public function configure(callable $handler): self
  44      {
  45          $child = $this->getChildToolbar();
  46  
  47          $handler($child);
  48  
  49          return $this;
  50      }
  51  
  52      /**
  53       * Get child toolbar.
  54       *
  55       * @return  Toolbar  Return new child Toolbar instance.
  56       *
  57       * @since   4.0.0
  58       */
  59      public function getChildToolbar(): Toolbar
  60      {
  61          if (!$this->child) {
  62              $this->child = $this->parent->createChild($this->getName() . '-children');
  63          }
  64  
  65          return $this->child;
  66      }
  67  
  68      /**
  69       * Get the button CSS Id.
  70       *
  71       * @return  string  Button CSS Id
  72       *
  73       * @since   4.0.0
  74       */
  75      protected function fetchId()
  76      {
  77          return $this->parent->getName() . '-group-' . $this->getName();
  78      }
  79  }


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