#StackBounty: #magento2 #error #compilation Incompatible argument type error in Magento 2.2.2

Bounty: 50

I have installed Magento 2.2.2.

Running php bin/magento setup:di:compile result in this error:

MagentoBackendModelViewLayoutGeneratorPool
Incompatible argument type: Required type: MagentoFrameworkViewLayoutConditionConditionFactory.

Actual type: MagentoFrameworkAppConfigScopeConfigInterface; File: 
vendor/magento/module-backend/Model/View/Layout/GeneratorPool.php

In

vendor/magento/framework/View/Layout/Condition/ConditionFactory.php:

<?php

namespace MagentoFrameworkViewLayoutCondition;

use MagentoFrameworkObjectManagerInterface;

/**
 * Factory for composite.
 */
class ConditionFactory
{
    /**
     * @var ObjectManagerInterface
     */
    private $objectManager;

    /**
     * @param ObjectManagerInterface $objectManager
     */
    public function __construct(ObjectManagerInterface $objectManager)
    {
        $this->objectManager = $objectManager;
    }

    /**
     * @param array $elementVisibilityConditions
     *
     * @return Condition
     */
    public function create(array $elementVisibilityConditions)
    {
        $conditions = [];
        foreach ($elementVisibilityConditions as $condition) {
            $conditions[] = $this->objectManager->create($condition['name']);
        }
        return $this->objectManager->create(Condition::class, ['conditions' => $conditions]);
    }
}

In

vendor/magento/module-backend/Model/View/Layout/GeneratorPool.php:

<?php
namespace MagentoBackendModelViewLayout;

use MagentoFrameworkViewLayoutScheduledStructure;
use MagentoFrameworkViewLayoutDataStructure;

/**
 * Pool of generators for structural elements
 */
class GeneratorPool extends MagentoFrameworkViewLayoutGeneratorPool
{
    /**
     * @var FilterAcl
     */
    protected $aclFilter;

    /**
     * @param ScheduledStructureHelper $helper
     * @param MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
     * @param MagentoFrameworkAppScopeResolverInterface $scopeResolver
     * @param PsrLogLoggerInterface $logger
     * @param FilterAcl $aclFilter
     * @param array $generators
     */
    public function __construct(
        ScheduledStructureHelper $helper,
        MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
        MagentoFrameworkAppScopeResolverInterface $scopeResolver,
        PsrLogLoggerInterface $logger,
        FilterAcl $aclFilter,
        array $generators = null
    ) {
        $this->aclFilter = $aclFilter;
        parent::__construct(
            $helper,
            $scopeConfig,
            $scopeResolver,
            $logger,
            $generators
        );
    }

    /**
     * Build structure that is based on scheduled structure
     *
     * @param ScheduledStructure $scheduledStructure
     * @param Structure $structure
     * @return $this
     */
    protected function buildStructure(ScheduledStructure $scheduledStructure, Structure $structure)
    {
        parent::buildStructure($scheduledStructure, $structure);
        $this->aclFilter->filterAclElements($scheduledStructure, $structure);
        return $this;
    }
}

What is the fix?


Get this bounty!!!

Leave a Reply