-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b032bbc
commit 3a8cb88
Showing
21 changed files
with
597 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Ui\Component\Form\Element; | ||
|
||
/** | ||
* Url Input to process data for urlInput component | ||
*/ | ||
class UrlInput extends \Magento\Ui\Component\Form\Element\AbstractElement | ||
{ | ||
const NAME = 'urlInput'; | ||
|
||
/** | ||
* Get component name | ||
* | ||
* @return string | ||
*/ | ||
public function getComponentName() | ||
{ | ||
return static::NAME; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function prepare() | ||
{ | ||
$config = $this->getData('config'); | ||
//process urlTypes | ||
if (isset($config['urlTypes'])) { | ||
$links = $config['urlTypes']->getConfig(); | ||
$config['urlTypes'] = $links; | ||
} | ||
$this->setData('config', (array)$config); | ||
parent::prepare(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Ui\Model\UrlInput; | ||
|
||
/** | ||
* Config interface for url link types | ||
*/ | ||
interface ConfigInterface | ||
{ | ||
/** | ||
* Returns config for url link type | ||
* | ||
* @return array | ||
*/ | ||
public function getConfig(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Ui\Model\UrlInput; | ||
|
||
/** | ||
* Returns configuration for default Url Input type | ||
*/ | ||
class DefaultLink implements ConfigInterface | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfig() | ||
{ | ||
return [ | ||
'label' => __('URL'), | ||
'component' => 'Magento_Ui/js/form/element/abstract', | ||
'template' => 'ui/form/element/input', | ||
'sortOrder' => 20, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Ui\Model\UrlInput; | ||
|
||
/** | ||
* Returns information about allowed links | ||
*/ | ||
class LinksProvider implements ConfigInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $linksConfiguration; | ||
|
||
/** | ||
* Object manager | ||
* | ||
* @var \Magento\Framework\ObjectManagerInterface | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* LinksProvider constructor. | ||
* @param array $linksConfiguration | ||
* @param \Magento\Framework\ObjectManagerInterface $objectManager | ||
*/ | ||
public function __construct( | ||
array $linksConfiguration, | ||
\Magento\Framework\ObjectManagerInterface $objectManager | ||
) { | ||
$this->linksConfiguration = $linksConfiguration; | ||
$this->objectManager = $objectManager; | ||
} | ||
|
||
|
||
public function getConfig() | ||
{ | ||
$config = []; | ||
foreach ($this->linksConfiguration as $linkName => $className) | ||
{ | ||
$config[$linkName] = $this->createConfigProvider($className)->getConfig(); | ||
} | ||
return $config; | ||
} | ||
|
||
/** | ||
* Create config provider | ||
* | ||
* @param string $instance | ||
* @return ConfigInterface | ||
*/ | ||
private function createConfigProvider($instance) | ||
{ | ||
if (!is_subclass_of( | ||
$instance, | ||
ConfigInterface::class | ||
) | ||
) { | ||
throw new \InvalidArgumentException( | ||
$instance . | ||
' does not implement ' . | ||
ConfigInterface::class | ||
); | ||
} | ||
return $this->objectManager->create($instance); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/code/Magento/Ui/view/base/ui_component/etc/definition/urlInput.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> | ||
<!-- Include section --> | ||
<xs:include schemaLocation="urn:magento:module:Magento_Ui:view/base/ui_component/etc/definition/ui_component.xsd"/> | ||
|
||
<xs:complexType name="componentUrlInput"> | ||
<xs:sequence> | ||
<xs:group ref="configurable" minOccurs="0" maxOccurs="unbounded"/> | ||
<xs:element name="settings" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:choice minOccurs="0" maxOccurs="unbounded"> | ||
<xs:group ref="componentUrlInputSettings"/> | ||
</xs:choice> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attributeGroup ref="ui_element_attributes"/> | ||
</xs:complexType> | ||
|
||
<xs:group name="componentUrlInputSettings"> | ||
<xs:choice> | ||
<xs:group ref="abstractSettings"/> | ||
<xs:element ref="scopeLabel"/> | ||
<xs:element name="urlTypes" type="urlTypes"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
Options for "urlInput" element | ||
</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element name="settingTemplate" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
The path to the custom url setting ".html" template. | ||
</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element name="typeSelectorTemplate" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
The path to the custom url types selector ".html" template. | ||
</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element name="settingLabel" type="translatableString"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
The label for custom url setting. | ||
</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element name="isDisplayAdditionalSettings" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
Allows to specify if display additional settings | ||
</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:choice> | ||
</xs:group> | ||
</xs:schema> |
Oops, something went wrong.