Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adrian-martinez-interactiv4/38bca4531085093f3c99553ff936d478 to your computer and use it in GitHub Desktop.
Save adrian-martinez-interactiv4/38bca4531085093f3c99553ff936d478 to your computer and use it in GitHub Desktop.
Test Proxy generation return type
<?php
use Magento\Framework\App\Area;
require __DIR__ . '/app/bootstrap.php';
/**
* Class Hello
*/
class Hello
{
/**
* @return string
*/
public function sayHello(): string
{
return "Hello !!";
}
}
/**
* Class ProxyTestApp
*/
class ProxyTestApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface
{
public function launch()
{
$this->_state->setAreaCode(Area::AREA_GLOBAL);
$this->_objectManager->configure($this->_configLoader->load(Area::AREA_GLOBAL));
/** @var Hello $helloProxy */
$helloProxy = $this->_objectManager->get(\Hello::class . '\Proxy');
$this->_response->setBody($helloProxy->sayHello());
//the method must end with this line
return $this->_response;
}
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception)
{
return false;
}
}
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('ProxyTestApp');
$bootstrap->run($app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment