PHP 8.2.30
Preview: Button.php Size: 8.62 KB
/opt/cloudlinux/alt-php53/root/usr/share/pear/Symfony/Component/Form/Button.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form;

use Symfony\Component\Form\Exception\AlreadySubmittedException;
use Symfony\Component\Form\Exception\BadMethodCallException;

/**
 * A form button.
 *
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class Button implements \IteratorAggregate, FormInterface
{
    /**
     * @var FormInterface|null
     */
    private $parent;

    /**
     * @var FormConfigInterface
     */
    private $config;

    /**
     * @var Boolean
     */
    private $submitted = false;

    /**
     * Creates a new button from a form configuration.
     *
     * @param FormConfigInterface $config The button's configuration.
     */
    public function __construct(FormConfigInterface $config)
    {
        $this->config = $config;
    }

    /**
     * Unsupported method.
     *
     * @param mixed $offset
     *
     * @return Boolean Always returns false.
     */
    public function offsetExists($offset)
    {
        return false;
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param mixed $offset
     *
     * @throws BadMethodCallException
     */
    public function offsetGet($offset)
    {
        throw new BadMethodCallException('Buttons cannot have children.');
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param mixed $offset
     * @param mixed $value
     *
     * @throws BadMethodCallException
     */
    public function offsetSet($offset, $value)
    {
        throw new BadMethodCallException('Buttons cannot have children.');
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param mixed $offset
     *
     * @throws BadMethodCallException
     */
    public function offsetUnset($offset)
    {
        throw new BadMethodCallException('Buttons cannot have children.');
    }

    /**
     * {@inheritdoc}
     */
    public function setParent(FormInterface $parent = null)
    {
        $this->parent = $parent;
    }

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return $this->parent;
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param int|string|FormInterface $child
     * @param null                     $type
     * @param array                    $options
     *
     * @throws BadMethodCallException
     */
    public function add($child, $type = null, array $options = array())
    {
        throw new BadMethodCallException('Buttons cannot have children.');
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param string $name
     *
     * @throws BadMethodCallException
     */
    public function get($name)
    {
        throw new BadMethodCallException('Buttons cannot have children.');
    }

    /**
     * Unsupported method.
     *
     * @param string $name
     *
     * @return Boolean Always returns false.
     */
    public function has($name)
    {
        return false;
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param string $name
     *
     * @throws BadMethodCallException
     */
    public function remove($name)
    {
        throw new BadMethodCallException('Buttons cannot have children.');
    }

    /**
     * {@inheritdoc}
     */
    public function all()
    {
        return array();
    }

    /**
     * {@inheritdoc}
     */
    public function getErrors()
    {
        return array();
    }

    /**
     * Unsupported method.
     *
     * This method should not be invoked.
     *
     * @param string $modelData
     *
     * @throws BadMethodCallException
     */
    public function setData($modelData)
    {
        // called during initialization of the form tree
        // noop
    }

    /**
     * Unsupported method.
     *
     * @return null Always returns null.
     */
    public function getData()
    {
        return null;
    }

    /**
     * Unsupported method.
     *
     * @return null Always returns null.
     */
    public function getNormData()
    {
        return null;
    }

    /**
     * Unsupported method.
     *
     * @return null Always returns null.
     */
    public function getViewData()
    {
        return null;
    }

    /**
     * Unsupported method.
     *
     * @return array Always returns an empty array.
     */
    public function getExtraData()
    {
        return array();
    }

    /**
     * Returns the button's configuration.
     *
     * @return FormConfigInterface The configuration.
     */
    public function getConfig()
    {
        return $this->config;
    }

    /**
     * Returns whether the button is submitted.
     *
     * @return Boolean true if the button was submitted.
     */
    public function isSubmitted()
    {
        return $this->submitted;
    }

    /**
     * Returns the name by which the button is identified in forms.
     *
     * @return string The name of the button.
     */
    public function getName()
    {
        return $this->config->getName();
    }

    /**
     * Unsupported method.
     *
     * @return null Always returns null.
     */
    public function getPropertyPath()
    {
        return null;
    }

    /**
     * Unsupported method.
     *
     * @param FormError $error
     *
     * @throws BadMethodCallException
     */
    public function addError(FormError $error)
    {
        throw new BadMethodCallException('Buttons cannot have errors.');
    }

    /**
     * Unsupported method.
     *
     * @return Boolean Always returns true.
     */
    public function isValid()
    {
        return true;
    }

    /**
     * Unsupported method.
     *
     * @return Boolean Always returns false.
     */
    public function isRequired()
    {
        return false;
    }

    /**
     * {@inheritdoc}
     */
    public function isDisabled()
    {
        return $this->config->getDisabled();
    }

    /**
     * Unsupported method.
     *
     * @return Boolean Always returns true.
     */
    public function isEmpty()
    {
        return true;
    }

    /**
     * Unsupported method.
     *
     * @return Boolean Always returns true.
     */
    public function isSynchronized()
    {
        return true;
    }

    /**
     * Unsupported method.
     *
     * @throws BadMethodCallException
     */
    public function initialize()
    {
        throw new BadMethodCallException('Buttons cannot be initialized. Call initialize() on the root form instead.');
    }

    /**
     * Unsupported method.
     *
     * @param mixed $request
     *
     * @throws BadMethodCallException
     */
    public function handleRequest($request = null)
    {
        throw new BadMethodCallException('Buttons cannot handle requests. Call handleRequest() on the root form instead.');
    }

    /**
     * Submits data to the button.
     *
     * @param null|string $submittedData The data.
     * @param Boolean     $clearMissing  Not used.
     *
     * @return Button The button instance
     *
     * @throws Exception\AlreadySubmittedException If the button has already been submitted.
     */
    public function submit($submittedData, $clearMissing = true)
    {
        if ($this->submitted) {
            throw new AlreadySubmittedException('A form can only be submitted once');
        }

        $this->submitted = true;

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function getRoot()
    {
        return $this->parent ? $this->parent->getRoot() : $this;
    }

    /**
     * {@inheritdoc}
     */
    public function isRoot()
    {
        return null === $this->parent;
    }

    /**
     * {@inheritdoc}
     */
    public function createView(FormView $parent = null)
    {
        if (null === $parent && $this->parent) {
            $parent = $this->parent->createView();
        }

        $type = $this->config->getType();
        $options = $this->config->getOptions();

        $view = $type->createView($this, $parent);

        $type->buildView($view, $this, $options);
        $type->finishView($view, $this, $options);

        return $view;
    }

    /**
     * Unsupported method.
     *
     * @return integer Always returns 0.
     */
    public function count()
    {
        return 0;
    }

    /**
     * Unsupported method.
     *
     * @return \EmptyIterator Always returns an empty iterator.
     */
    public function getIterator()
    {
        return new \EmptyIterator();
    }
}

Directory Contents

Dirs: 6 × Files: 49

Name Size Perms Modified Actions
Exception DIR
- drwxr-xr-x 2024-03-03 22:55:08
Edit Download
Extension DIR
- drwxr-xr-x 2024-03-03 22:55:07
Edit Download
Guess DIR
- drwxr-xr-x 2024-03-03 22:55:08
Edit Download
Resources DIR
- drwxr-xr-x 2024-03-03 22:55:08
Edit Download
Test DIR
- drwxr-xr-x 2024-03-03 22:55:08
Edit Download
Util DIR
- drwxr-xr-x 2024-03-03 22:55:08
Edit Download
4.77 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
7.46 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.05 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
993 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
334 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
8.62 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
18.09 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
462 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.09 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
559 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.10 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
3.08 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
34.05 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
7.69 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.28 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
21.17 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
8.46 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
6.29 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.50 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.22 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.11 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.63 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
5.10 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
3.52 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.99 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
4.14 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
8.13 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
4.64 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.41 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
11.67 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
6.90 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
3.20 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
5.76 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.08 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.81 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.12 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
3.15 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
3.44 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
5.48 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
2.26 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
668 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
7.48 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
658 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.27 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
3.23 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.23 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
1.11 KB lrw-r--r-- 2019-12-18 11:20:41
Edit Download
624 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download
474 B lrw-r--r-- 2019-12-18 11:20:41
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).