本文整理匯總了PHP中Magento\Framework\View\Element\UiComponentInterface::getContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP UiComponentInterface::getContext方法的具體用法?PHP UiComponentInterface::getContext怎麽用?PHP UiComponentInterface::getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\Element\UiComponentInterface
的用法示例。
在下文中一共展示了UiComponentInterface::getContext方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* {@inheritdoc}
*/
public function update(UiComponentInterface $component)
{
if (!$component instanceof \Magento\Ui\Component\Filters) {
return;
}
$attributeCodes = $component->getContext()->getRequestParam('attributes_codes');
if ($attributeCodes) {
foreach ($this->getAttributes($attributeCodes) as $attribute) {
$filter = $this->filterFactory->create($attribute, $component->getContext());
$filter->prepare();
$component->addComponent($attribute->getAttributeCode(), $filter);
}
}
}
示例2: createChildFormComponent
/**
* Create child of form
*
* @param UiComponentInterface $childComponent
* @param string $name
* @return UiComponentInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function createChildFormComponent(UiComponentInterface $childComponent, $name)
{
$panelComponent = $this->uiComponentFactory->create($name, $this->getConfig(self::CONFIG_PANEL_COMPONENT), ['context' => $this->component->getContext(), 'components' => [$childComponent->getName() => $childComponent]]);
$panelComponent->prepare();
$this->component->addComponent($name, $panelComponent);
return $panelComponent;
}
示例3: build
/**
* Generate Java Script configuration element
*
* @param UiComponentInterface $component
* @return array
*/
public function build(UiComponentInterface $component)
{
$children = [];
$context = $component->getContext();
$this->addChildren($children, $component, $component->getName());
$dataSources = $component->getDataSourceData();
$configuration = ['types' => $context->getComponentsDefinitions(), 'components' => [$context->getNamespace() => ['children' => array_merge($children, $dataSources)]]];
return $configuration;
}
示例4: build
/**
* Build
*
* @param UiComponentInterface $component
* @return array
*/
public function build(UiComponentInterface $component)
{
$this->component = $component;
$this->namespace = $component->getContext()->getNamespace();
$this->addNavigationBlock();
// Initialization of structure components
$this->initSections();
$this->initAreas();
return parent::build($component);
}
示例5: render
/**
* Render data
*
* @param UiComponentInterface $component
* @param string $template
* @return string
* @throws \Exception
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function render(UiComponentInterface $component, $template = '')
{
$context = $component->getContext();
$isComponent = $context->getRequestParam('componentJson');
if ($isComponent) {
$data = $this->structure->generate($component);
return $this->encoder->encode($data);
} else {
$data = $component->getContext()->getDataSourceData($component);
$data = reset($data);
return $this->encoder->encode($data['config']['data']);
}
}
示例6: addNavigationBlock
/**
* Add navigation block
*
* @return void
*/
protected function addNavigationBlock()
{
$pageLayout = $this->component->getContext()->getPageLayout();
/** @var \Magento\Ui\Component\Layout\Tabs\Nav $navBlock */
if (isset($this->navContainerName)) {
$navBlock = $pageLayout->addBlock('Magento\\Ui\\Component\\Layout\\Tabs\\Nav', 'tabs_nav', $this->navContainerName);
} else {
$navBlock = $pageLayout->addBlock('Magento\\Ui\\Component\\Layout\\Tabs\\Nav', 'tabs_nav', 'content');
}
$navBlock->setTemplate('Magento_Ui::layout/tabs/nav/default.phtml');
$navBlock->setData('data_scope', $this->namespace);
$this->component->getContext()->addComponentDefinition('nav', ['component' => 'Magento_Ui/js/form/components/tab_group', 'config' => ['template' => 'ui/tab'], 'extends' => $this->namespace]);
}
示例7: getJsConfig
/**
* Get configuration of related JavaScript Component
* (force extending the root component if component does not extend other component)
*
* @param UiComponentInterface $component
* @return array
*/
public function getJsConfig(UiComponentInterface $component)
{
$jsConfig = (array) $component->getData('js_config');
if (!isset($jsConfig['extends'])) {
$jsConfig['extends'] = $component->getContext()->getNamespace();
}
return $jsConfig;
}
示例8: getConfiguration
/**
* Get JS configuration
*
* @param UiComponentInterface $component
* @param null|string $extends
* @return array
*/
protected function getConfiguration(UiComponentInterface $component, $extends = null)
{
$jsConfig = (array) $component->getData('js_config');
if (isset($jsConfig['extends'])) {
return $jsConfig;
} else {
if (null !== $extends) {
$jsConfig['extends'] = $extends;
} else {
$jsConfig['extends'] = $component->getContext()->getNamespace();
}
}
return $jsConfig;
}