Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors during compilation #2

Open
MurKit opened this issue Jul 3, 2017 · 4 comments
Open

Errors during compilation #2

MurKit opened this issue Jul 3, 2017 · 4 comments

Comments

@MurKit
Copy link

MurKit commented Jul 3, 2017

I'm on Magento CE 2.1.7.

After I download this extension and copy it to my Magento installation I run some cli commands.

sudo rm -rf var/di/*
sudo rm -rf var/cache/*
sudo rm -rf var/generation/*
sudo rm -rf var/page_cache/*

sudo chmod -R 777 pub/*
sudo chmod -R 777 var/*

php -f bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:di:compile

And on the last step there are errors:

Errors during compilation:
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Edit.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
Total Errors Count: 3
Errors during compilation:
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Edit.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
Total Errors Count: 3
Errors during compilation:
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Edit.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
Total Errors Count: 3
Errors during compilation:
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Edit.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
Total Errors Count: 3
Errors during compilation:
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Edit.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
Total Errors Count: 3
Errors during compilation:
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Edit.php
\Magento\Backend\Model\Session already exists in context object
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
	Mageplaza\HelloWorld\Controller\Adminhtml\Post
		Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
\Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
Total Errors Count: 3
@irinikp
Copy link

irinikp commented Jul 11, 2017

I get the exact same error

@NagarajuKasa
Copy link

Yes I am also facing the same issues http://prntscr.com/g3ubke

@tarungupta051
Copy link

tarungupta051 commented May 8, 2018

Hello You need to below changes into files.

  1. Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post.php
    \Magento\Backend\Model\View\Result\RedirectFactory already exists in context object

Reply : $this->redirectFactory = $context->getRedirectFactory();

comment below code : //\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,

use below code 👍
public function __construct(
\Mageplaza\HelloWorld\Model\Upload $uploadModel,
\Mageplaza\HelloWorld\Model\Post\File $fileModel,
\Mageplaza\HelloWorld\Model\Post\Image $imageModel,
//\Magento\Backend\Model\Session $backendSession,
\Mageplaza\HelloWorld\Model\PostFactory $postFactory,
\Magento\Framework\Registry $registry,
//\Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory,
/// \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory ,
\Magento\Backend\App\Action\Context $context
//Phpexcel_PHPExcel $xlsx
//\PHPExcel\IOFactory $iOFactory;
//Phpexcel_PHPExcel $xlsx

)
{
    $this->_uploadModel    = $uploadModel;
    $this->_fileModel      = $fileModel;
    $this->_imageModel     = $imageModel;
  //  $this->_backendSession = $backendSession;
	$this->redirectFactory =  $context->getRedirectFactory();
	//$this->_iOFactory = $iOFactory;
	//$this->excelFactory = $excelFactory;
	//$this->excelFactory = $excelFactory;
    parent::__construct($postFactory, $registry,$context);
}

@tarungupta051
Copy link

Hello ,

  1. Incorrect dependency in class Mageplaza\HelloWorld\Controller\Adminhtml\Post\Save in /var/www/mage2/app/code/Mageplaza/HelloWorld/Controller/Adminhtml/Post/Save.php
    \Magento\Backend\Model\Session already exists in context object
    \Magento\Backend\Model\View\Result\RedirectFactory already exists in context object
    Mageplaza\HelloWorld\Controller\Adminhtml\Post\Edit

Reply : use below code 👍
public function __construct(
// \Magento\Backend\Model\Session $backendSession,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Mageplaza\HelloWorld\Model\PostFactory $postFactory,
\Magento\Framework\Registry $registry,
//\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
\Magento\Backend\App\Action\Context $context
)
{
//$this->_backendSession = $backendSession;
$this->_resultPageFactory = $resultPageFactory;
$this->_resultJsonFactory = $resultJsonFactory;
$this->redirectFactory = $context->getRedirectFactory();
parent::__construct($postFactory,$registry,$context);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants