本文整理匯總了PHP中Magento\Framework\View\Element\UiComponentInterface::getJsConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP UiComponentInterface::getJsConfig方法的具體用法?PHP UiComponentInterface::getJsConfig怎麽用?PHP UiComponentInterface::getJsConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\Element\UiComponentInterface
的用法示例。
在下文中一共展示了UiComponentInterface::getJsConfig方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addChildren
/**
* Add children data
*
* @param array $topNode
* @param UiComponentInterface $component
* @param string $componentType
* @return void
*/
protected function addChildren(array &$topNode, UiComponentInterface $component, $componentType)
{
$childrenNode = [];
$childComponents = $component->getChildComponents();
if (!empty($childComponents)) {
/** @var UiComponentInterface $child */
foreach ($childComponents as $child) {
if ($child instanceof DataSourceInterface) {
continue;
}
self::addChildren($childrenNode, $child, $child->getComponentName());
}
}
/** @var JsConfigInterface $component */
$config = $component->getJsConfig();
if (is_string($config)) {
$topNode[] = $config;
} else {
$nodeData = ['type' => $componentType, 'name' => $component->getName()];
if (!empty($childrenNode)) {
$nodeData['children'] = $childrenNode;
}
if (isset($config['dataScope'])) {
$nodeData['dataScope'] = $config['dataScope'];
unset($config['dataScope']);
}
if (!empty($config)) {
$nodeData['config'] = $config;
}
$topNode[] = $nodeData;
}
}
示例2: prepareChildComponents
/**
* To prepare the structure of child components
*
* @param UiComponentInterface $component
* @param string $parentName
* @return array
*/
protected function prepareChildComponents(UiComponentInterface $component, $parentName)
{
$name = $component->getName();
$childComponents = $component->getChildComponents();
$childrenStructure = [];
foreach ($childComponents as $childName => $child) {
$isVisible = $child->getData('config/visible');
if ($isVisible !== null && $isVisible == 0) {
continue;
}
/**
* @var UiComponentInterface $childComponent
* @var array $childStructure
*/
list($childComponent, $childStructure) = $this->prepareChildComponents($child, $component->getName());
$childrenStructure = array_merge($childrenStructure, $childStructure);
$component->addComponent($childName, $childComponent);
}
$structure = [$name => ['type' => $component->getComponentName(), 'name' => $component->getName(), 'children' => $childrenStructure]];
/** @var JsConfigInterface $component */
list($config, $dataScope) = $this->prepareConfig((array) $component->getJsConfig(), $name, $parentName);
if ($dataScope !== false) {
$structure[$name]['dataScope'] = $dataScope;
}
$structure[$name]['config'] = $config;
return [$component, $structure];
}