2

I have installed Magento 2.2.2.

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

Magento\Backend\Model\View\Layout\GeneratorPool
Incompatible argument type: Required type: \Magento\Framework\View\Layout\Condition\ConditionFactory.php

Actual type: \Magento\Framework\App\Config\ScopeConfigInterface; File: 
vendor/magento/module-backend/Model/View/Layout/GeneratorPool.php

In

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

<?php

namespace Magento\Framework\View\Layout\Condition;

use Magento\Framework\ObjectManagerInterface;

/**
 * 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 Magento\Backend\Model\View\Layout;

use Magento\Framework\View\Layout\ScheduledStructure;
use Magento\Framework\View\Layout\Data\Structure;

/**
 * Pool of generators for structural elements
 */
class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool
{
    /**
     * @var Filter\Acl
     */
    protected $aclFilter;

    /**
     * @param ScheduledStructure\Helper $helper
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
     * @param \Psr\Log\LoggerInterface $logger
     * @param Filter\Acl $aclFilter
     * @param array $generators
     */
    public function __construct(
        ScheduledStructure\Helper $helper,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
        \Magento\Framework\App\ScopeResolverInterface $scopeResolver,
        \Psr\Log\LoggerInterface $logger,
        Filter\Acl $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?

  • could you show your full code of php class? – Rakesh Jesadiya Apr 13 '18 at 8:50
  • I just did. Check it out. – Razvan Zamfir Apr 13 '18 at 8:56
  • Did you do php bin/magento setup:upgrade? – Evgeny Levinsky Apr 13 '18 at 14:47
  • Yes, I did. Just before php bin/magento setup:di:compile – Razvan Zamfir Apr 13 '18 at 14:49
  • did you install a fresh Magento2.2 or you upgraded from older version, If you have upgraded Magento from older version you may read this comment here [github.com/magento/magento2/issues/… – WISAM HAKIM Apr 15 '18 at 22:31
1

It used to be there but was removed. Make sure no di.xml still references it. So look for something like this:

<preference for="Magento\Framework\View\Layout\GeneratorPool"
    type="Magento\Backend\Model\View\Layout\GeneratorPool" />

On the cause: It looks like you copied Magento 2.2 over an earlier version and something botched your upgrade path. Did you follow these instructions?

0

https://github.com/magento/magento2/tree/2.2/app/code/Magento/Backend/Model/View/Layout

You can see there is no GeneratorPool.php file there

Be sure you are working with stable version, you can download from here https://magento.com/tech-resources/download

0

I removed

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

entirely which then allowed the compile command to process normally.

Got the suggestion from https://github.com/magento/magento2/issues/11190

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.