CoreFiles by mySites.guru
AbstractGroupButton.php75 lines, 1,483 bytes, from Joomla_4.2.1-rc2-Release_Candidate-Full_Package.zip
Raw History Compare with 4.2.1-rc1
md5
1cb85542f1cf728580745e8464ff61fa
sha1
0983db299c56ddd2423adead29329f726111a830
sha256
1915d206ca0a1a2bde993a1aa7e20c0ee9fcd218527cc617c025f0d9b81446fc
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Toolbar\Button;

use Joomla\CMS\Toolbar\Toolbar;

/**
 * The AbstractGroupButton class.
 *
 * @since  4.0.0
 */
abstract class AbstractGroupButton extends BasicButton
{
    /**
     * The child Toolbar instance.
     *
     * @var  Toolbar
     *
     * @since  4.0.0
     */
    protected $child;

    /**
     * Add children buttons as dropdown.
     *
     * @param   callable  $handler  The callback to configure dropdown items.
     *
     * @return  static
     *
     * @since  4.0.0
     */
    public function configure(callable $handler): self
    {
        $child = $this->getChildToolbar();

        $handler($child);

        return $this;
    }

    /**
     * Get child toolbar.
     *
     * @return  Toolbar  Return new child Toolbar instance.
     *
     * @since   4.0.0
     */
    public function getChildToolbar(): Toolbar
    {
        if (!$this->child) {
            $this->child = $this->parent->createChild($this->getName() . '-children');
        }

        return $this->child;
    }

    /**
     * Get the button CSS Id.
     *
     * @return  string  Button CSS Id
     *
     * @since   4.0.0
     */
    protected function fetchId()
    {
        return $this->parent->getName() . '-group-' . $this->getName();
    }
}

The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.