문제

Magento 2.0.2 새로운 사용자 역할을 추가하려고하지만 역할 자원 탭으로 이동하면 리소스 트리가 표시되지 않습니다.나는 오류가 표시되지 않습니다.이것이 왜 표시되지 않는 이유를 알아낼 다음 단계는 무엇입니까?

참고 : i 관리자로 loggedin

sreenshot : 여기에 이미지 설명 입력

도움이 되었습니까?

해결책

긴 연구 후이 문제를 해결할 수 있습니다. 실수는 XML의 형식이었습니다.

초기 코드 :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Adminhtml::admin">
            <resource id="Company_Module::" title="test" sortOrder="100"/>
        <!--AddMenuAcl-->
        </resource>
    </resources>
</acl>
</config>
.

바꾸기 :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Company_module::test" title="test module" sortOrder="100"/>
            <!--AddMenuAcl-->
        </resource>
    </resources>
</acl>
</config>
.

이를 확인하십시오.

 <?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"             xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Adminhtml::admin">
        </resource>
    </resources>
</acl>
.

리소스가 정의되지 않은 경우 주석을 주석을 입력하십시오 :

    <?xml version="1.0"?>
     <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <!--<resource id="Magento_Adminhtml::admin">
        </resource>-->
    </resources>
</acl>
.

다른 팁

manish 가보고 된 것을 확인합니다.문제는 acl.xml 파일에 있습니다. 내 경우에 (Magento 2.1) 나는 다음과 같은 acl.xml :

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Backend::all_elements" title="Ves ALl">
                <resource id="Ves_All::ves_all" title="Ves All" sortOrder="10">
                </resource>
        </resource>
        <resource id="Magento_Backend::admin">
            <resource id="Magento_Backend::stores">
                <resource id="Magento_Backend::stores_settings">
                    <resource id="Magento_Config::config">
                        <resource id="Ves_All::config" title="Ves All - Config Settings" />
                    </resource>
                </resource>
            </resource>
        </resource>
    </resources>
</acl>
.

다음과 같이 첫 번째 자원을 제거했습니다.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <!-- <resource id="Magento_Backend::all_elements" title="Ves ALl">
                <resource id="Ves_All::ves_all" title="Ves All" sortOrder="10">
                </resource>
        </resource>  -->
        <resource id="Magento_Backend::admin">
            <resource id="Magento_Backend::stores">
                <resource id="Magento_Backend::stores_settings">
                    <resource id="Magento_Config::config">
                        <resource id="Ves_All::config" title="Ves All - Config Settings" />
                    </resource>
                </resource>
            </resource>
        </resource>
    </resources>
</acl>
.

및 마술 적으로 관리면에서 자원 트리가 다시 나타납니다 (캐시를 플러시 한 후)!

이것은 일시적인 해결책이 저에게 일했습니다. D : \ xampp \ htdocs \ project \ vendor \ magento \ module-user \ block \ role \ tab \ edit.php

    <?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\User\Block\Role\Tab;

use Magento\Framework\App\ObjectManager;
use Magento\User\Controller\Adminhtml\User\Role\SaveRole;

/**
 * Rolesedit Tab Display Block.
 *
 */
class Edit extends \Magento\Backend\Block\Widget\Form implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
    /**
     * @var string
     */
    protected $_template = 'role/edit.phtml';

    /**
     * Root ACL Resource
     *
     * @var \Magento\Framework\Acl\RootResource
     */
    protected $_rootResource;

    /**
     * Rules collection factory
     *
     * @var \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory
     */
    protected $_rulesCollectionFactory;

    /**
     * Acl builder
     *
     * @var \Magento\Authorization\Model\Acl\AclRetriever
     */
    protected $_aclRetriever;

    /**
     * Acl resource provider
     *
     * @var \Magento\Framework\Acl\AclResource\ProviderInterface
     */
    protected $_aclResourceProvider;

    /** @var \Magento\Integration\Helper\Data */
    protected $_integrationData;

    /**
     * Core registry
     *
     * @var \Magento\Framework\Registry
     */
    protected $coreRegistry = null;

    /**
     * @param \Magento\Backend\Block\Template\Context $context
     * @param \Magento\Framework\Acl\RootResource $rootResource
     * @param \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory $rulesCollectionFactory
     * @param \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever
     * @param \Magento\Framework\Acl\AclResource\ProviderInterface $aclResourceProvider
     * @param \Magento\Integration\Helper\Data $integrationData
     * @param array $data
     */
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever,
        \Magento\Framework\Acl\RootResource $rootResource,
        \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory $rulesCollectionFactory,
        \Magento\Framework\Acl\AclResource\ProviderInterface $aclResourceProvider,
        \Magento\Integration\Helper\Data $integrationData,
        array $data = []
    ) {
        $this->_aclRetriever = $aclRetriever;
        $this->_rootResource = $rootResource;
        $this->_rulesCollectionFactory = $rulesCollectionFactory;
        $this->_aclResourceProvider = $aclResourceProvider;
        $this->_integrationData = $integrationData;
        parent::__construct($context, $data);
    }

    /**
     * Set core registry
     *
     * @param \Magento\Framework\Registry $coreRegistry
     * @return void
     * @deprecated
     */
    public function setCoreRegistry(\Magento\Framework\Registry $coreRegistry)
    {

        $this->coreRegistry = $coreRegistry;
    }

    /**
     * Get core registry
     *
     * @return \Magento\Framework\Registry
     * @deprecated
     */
    public function getCoreRegistry()
    {

        if (!($this->coreRegistry instanceof \Magento\Framework\Registry)) {
            return \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\Registry');
        } else {
            return $this->coreRegistry;
        }
    }

    /**
     * Get tab label
     *
     * @return \Magento\Framework\Phrase
     */
    public function getTabLabel()
    {
        return __('Role Resources');
    }

    /**
     * Get tab title
     *
     * @return string
     */
    public function getTabTitle()
    {
        return $this->getTabLabel();
    }

    /**
     * Whether tab is available
     *
     * @return bool
     */
    public function canShowTab()
    {
        return true;
    }

    /**
     * Whether tab is visible
     *
     * @return bool
     */
    public function isHidden()
    {
        return false;
    }

    /**
     * Check if everything is allowed
     *
     * @return bool
     */
    public function isEverythingAllowed()
    {
        $selectedResources = $this->getSelectedResources();
        $id = $this->_rootResource->getId();
        return in_array($id, $selectedResources);
    }

    /**
     * Get selected resources
     *
     * @return array|mixed|\string[]
     */
    public function getSelectedResources()
    {
        $selectedResources = $this->getData('selected_resources');
        if (empty($selectedResources)) {
            $allResource = $this->getCoreRegistry()->registry(SaveRole::RESOURCE_ALL_FORM_DATA_SESSION_KEY);
            if ($allResource) {
                $selectedResources = [$this->_rootResource->getId()];
            } else {
                $selectedResources = $this->getCoreRegistry()->registry(SaveRole::RESOURCE_FORM_DATA_SESSION_KEY);
            }

            if (null === $selectedResources) {
                $rid = $this->_request->getParam('rid', false);
                $selectedResources = $this->_aclRetriever->getAllowedResourcesByRole($rid);
            }

            $this->setData('selected_resources', $selectedResources);
        }
        //var_dump($selectedResources); die();
        return $selectedResources;
    }

    /**
     * Get Json Representation of Resource Tree
     *
     * @return array
     */
    public function getTree()
    {
        $resources = $this->_aclResourceProvider->getAclResources();
        $rootArray = $this->_integrationData->mapResources(
            //isset($resources[1]['children']) ? $resources[1]['children'] : []; //comment this line
            isset($resources[2]['children']) ? $resources[2]['children'] : []
        ); //use this line
        return $rootArray;
    }
}
.

마지막 방법을 코멘트로 참조하십시오.

코드를 역할 자원에 반환하는 코드 :

 <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Ipragmatech_Bannerblock::ipragmatech_indexindex"
                title="Banner Block" sortOrder="40">
                <resource id="Ipragmatech_Bannerblock::slider" title="Slider"
                    sortOrder="10" />
            </resource>
            <!--AddMenuAcl -->
            <resource id="Magento_Backend::stores">
                <resource id="Magento_Backend::stores_settings">
                    <resource id="Magento_Config::config">
                        <resource id="Ipragmatech_Bannerblock::config_bannerblock"
                            title="Banner Block" sortOrder="50" />
                    </resource>
                </resource>
                <!-- <resource id="Magento_Backend::stores_other_settings"> <resource 
                    id="Magento_Customer::group" title="Customer Groups" sortOrder="10" /> </resource> -->
            </resource>
        </resource>
    </resources>
</acl>
.

 <resource id="Ipragmatech_Bannerblock::config_bannerblock"
                        title="Banner Block" sortOrder="50" />
                </resource>
.

는 system.xml과 동일해야합니다.

vendor/magento/module-user/Block/Role/Tab/edit.php

로 이동하십시오.

라인 205

에 직접 이동하십시오.

로 바꿉니다.
isset($resources[2]['children']) ? $resources[2]['children'] : []
.

문제 해결.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top