Skip to content

($callback) must be a valid callback

My extension is failing varnish test over and over again and the only visible error i have found in the error reports is

call_user_func(): Argument #1 ($callback) must be a valid callback, class ” n FMEProductsListSetupPatchDataEnableProductsList” not found#0 /app/vend n or/magento/framework/Setup/Patch/PatchRegistry.php(141): call_user_func(Arr n ay) n #1 /app/vendor/magento/framework/Setup/Patch/PatchRegistry.php(207): Magent n oFrameworkSetupPatchPatchRegistry->getDependencies(‘FME\ProductsLis… n ‘)

Here is my code for Data Patch which seems to be fine

<?php
declare (strict_types = 1);
namespace FMEProductsListSetupPatchData;

use MagentoEavModelEntityAttributeScopedAttributeInterface;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupPatchDataPatchInterface;

class EnableProductsList implements DataPatchInterface
{
    private $moduleDataSetup;
    private $eavSetupFactory;
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavSetupFactory = $eavSetupFactory;
    }
    public function apply()
    {
        $this->moduleDataSetup->startSetup();
        $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
        $eavSetup->addAttribute(
            'catalog_product', 'enable_productslist', [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'label' => 'Enable Product Export',
                'input' => 'boolean',
                'class' => '',
                'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
                'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => 0,
                'note'     => 'This setting was added by FME Product List',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'unique' => false,
                'apply_to' => '',
            ]
        );
        $this->moduleDataSetup->endSetup();
    }
    public static function getDependencies()
    {
        return [];
    }
    public function getAliases()
    {
        return [];
    }
}