0

I have errors validating my module in Marketplace Magento 2.4

Direct use of $_GET Superglobal detected. Direct use of $_POST Superglobal detected. Direct use of $_REQUEST Superglobal detected.

how should I use those methods correctly?

2 Answers 2

1

You need to use magento method like this :

<?php namespace Vendor\Extension\Yourcontrollerfolder; 

class Yourcontrollerclass
{ 

      protected $request; 

      public function __construct( \Magento\Framework\App\RequestInterface $request) 
     { 
           $this->request = $request; 
     } 

     public function Yourfunction() 
     { 
          //POST VALUE USE THIS CODE
          $postData = $this->request->getPost();
          
     } 
}
1
  • $_GET = $request->getParams() $_POST = $request->getPost() $_REQUEST = $request
    – Miguel
    Jul 21, 2021 at 9:55
1
 <?php namespace Vendor\Extension\Yourcontrollerfolder;     

 class Yourcontrollerclass
 { 

  protected $request; 

  public function __construct( \Magento\Framework\App\RequestInterface $request) 
 { 
       $this->request = $request; 
 } 

 public function Yourfunction() 
 { 
      $GET = $request->getParams();
      $POST = $request->getPost();
      $REQUEST = $request;
      
   } 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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