a-digital / cookie-consent-banner

Add a configurable cookie consent banner to the website.
MIT License
11 stars 14 forks source link

Error on Schematic export #1

Closed wouter-vs closed 6 years ago

wouter-vs commented 6 years ago

When exporting the configuration with Schematic an error is thrown.

Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: craft\console\Request::getIsAjax()'

in /vagrant/htdocs/vendor/yiisoft/yii2/base/Component.php:300

Stack trace:
#0 /vagrant/htdocs/vendor/adigital/cookie-consent-banner/src/CookieConsentBanner.php(84): yii\base\Component->__call('getIsAjax', Array)
#1 /vagrant/htdocs/vendor/yiisoft/yii2/base/BaseObject.php(109): adigital\cookieconsentbanner\CookieConsentBanner->init()
#2 /vagrant/htdocs/vendor/yiisoft/yii2/base/Module.php(158): yii\base\BaseObject->__construct(Array)
#3 /vagrant/htdocs/vendor/craftcms/cms/src/base/Plugin.php(97): yii\base\Module->__construct('cookie-consent-...', Object(craft\console\Application), Array)
#4 [internal function]: craft\base\Plugin->__construct('cookie-consent-...', Object(craft\console\Application), Array)
#5 /vagrant/htdocs/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#6 /vagrant/htdocs/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('adigital\\cookie...', Array, Array)
#7 /vagrant/htdocs/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('adigital\\cookie...', Array, Array)
#8 /vagrant/htdocs/vendor/craftcms/cms/src/services/Plugins.php(782): yii\BaseYii::createObject(Array, Array)
#9 /vagrant/htdocs/vendor/craftcms/cms/src/services/Plugins.php(199): craft\services\Plugins->createPlugin('cookie-consent-...', Array)
#10 /vagrant/htdocs/vendor/craftcms/cms/src/base/ApplicationTrait.php(1148): craft\services\Plugins->loadPlugins()
#11 /vagrant/htdocs/vendor/craftcms/cms/src/console/Application.php(64): craft\console\Application->_postInit()
#12 /vagrant/htdocs/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\console\Application->init()
#13 /vagrant/htdocs/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)
#14 /vagrant/htdocs/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#15 /vagrant/htdocs/vendor/craftcms/cms/src/console/Application.php(53): yii\console\Application->__construct(Array)
#16 [internal function]: craft\console\Application->__construct(Array)
#17 /vagrant/htdocs/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#18 /vagrant/htdocs/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('craft\\console\\A...', Array, Array)
#19 /vagrant/htdocs/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('craft\\console\\A...', Array, Array)
#20 /vagrant/htdocs/vendor/craftcms/cms/bootstrap/bootstrap.php(252): yii\BaseYii::createObject(Array)
#21 /vagrant/htdocs/vendor/craftcms/cms/bootstrap/console.php(31): require('/vagrant/htdocs...')
#22 /vagrant/htdocs/craft(21): require('/vagrant/htdocs...')
#23 {main}
mark-adigital commented 6 years ago

Hi,

This issue seems to be due to the fact that the web request class has the getIsAjax() method but the console request class does not. I've just made a new release to hopefully address this by checking if the request has come from the console and whether the getIsAjax() method exists.

Please can you try this and let me know if it has resolved your issue with Schematic?

Thanks,

Mark

wouter-vs commented 6 years ago

That did it.

Tnx for the quick fix.