Laravel错误调用未定义的方法Pelago \ Emogrifier :: disableInvisibleNodeRemoval()

问题描述 投票:0回答:1

我正在gitlab中克隆laravel Web-api项目。然后,我想迁移并服务以便在邮递员中测试api。但是,当我进行迁移或服务时,会出现错误

In CssInlinerPlugin.php line 18:

Call to undefined method Pelago\Emogrifier::disableInvisibleNodeRemoval()

有人可以帮我吗?我不知道如何解决这个问题,因为即使Google也没有答案。预先感谢。

CssInlinerPlugin.php

<?php

namespace Snowfire\Beautymail;

class CssInlinerPlugin implements \Swift_Events_SendListener
{
    /**
     * @var \Pelago\Emogrifier
     */
    protected $inliner;

    /**
     * Initialize the CSS inliner.
     */
    public function __construct()
    {
        $this->inliner = new \Pelago\Emogrifier();
        $this->inliner->disableInvisibleNodeRemoval();
    }

    /**
     * Inline the CSS before an email is sent.
     *
     * @param \Swift_Events_SendEvent $evt
     */
    public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
    {
        $message = $evt->getMessage();

        $properTypes = [
            'text/html',
            'multipart/alternative',
            'multipart/mixed',
        ];

        if ($message->getBody() && in_array($message->getContentType(), $properTypes)) {
            $this->inliner->setHtml($message->getBody());
            $message->setBody($this->inliner->emogrify());
        }

        foreach ($message->getChildren() as $part) {
            if (strpos($part->getContentType(), 'text/html') === 0) {
                $this->inliner->setHtml($part->getBody());
                $message->setBody($this->inliner->emogrify());
            }
        }
    }

    /**
     * Do nothing.
     *
     * @param \Swift_Events_SendEvent $evt
     */
    public function sendPerformed(\Swift_Events_SendEvent $evt)
    {
        // Do Nothing
    }
}

Composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "5.5.*",
        "laravel/passport": "^4.0",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "^5.5",
        "maatwebsite/excel": "~2.1.0",
        "nexmo/laravel": "^1.0",
        "pusher/pusher-http-laravel": "^4.0",
        "pusher/pusher-php-server": "^3.0",
        "pusher/pusher-push-notifications": "1.0",
        "snowfire/beautymail": "dev-master"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

当我安装作曲家时

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Package phpoffice/phpexcel is abandoned, you should avoid using it. Use phpoffice/phpspreadsheet instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run ".\vendor\bin\upgrade-carbon" to get help in updating carbon and other frameworks and libraries that depend on it.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In CssInlinerPlugin.php line 18:

  Call to undefined method Pelago\Emogrifier::disableInvisibleNodeRemoval()


Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
php laravel
1个回答
1
投票

似乎该软件包对此有未解决的问题:https://github.com/Snowfire/Beautymail/issues/111他们在这里列出了几个解决方案。也许尝试将版本更改为2.2.0?

© www.soinside.com 2019 - 2024. All rights reserved.