CoreFiles by mySites.guru
Url.php54 lines, 1,352 bytes, from Joomla_4.4.2-Stable-Full_Package.zip
Raw History Compare with 4.4.1
md5
3e8d607959d3c254286bdfb65e13da0e
sha1
1950676a091a4be7b9b4373d6b94162156c219cc
sha256
87fe2d4fe89b1e62459242016549864dabc0997fb31607d0a8538193374a5bfc
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.url
 *
 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Plugin\Fields\Url\Extension;

use Joomla\CMS\Form\Form;
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Fields Url Plugin
 *
 * @since  3.7.0
 */
final class Url extends FieldsPlugin
{
    /**
     * Transforms the field into a DOM XML element and appends it as a child on the given parent.
     *
     * @param   stdClass    $field   The field.
     * @param   \DOMElement  $parent  The field node parent.
     * @param   Form        $form    The form.
     *
     * @return  \DOMElement
     *
     * @since   3.7.0
     */
    public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
    {
        $fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);

        if (!$fieldNode) {
            return $fieldNode;
        }

        $fieldNode->setAttribute('validate', 'url');

        if (! $fieldNode->getAttribute('relative')) {
            $fieldNode->removeAttribute('relative');
        }

        return $fieldNode;
    }
}

The same content is in 37 releases, Joomla 4.4.0-alpha3 to 5.0.0-alpha4. See them all, or every version of this file.