I am creating a playground external PHP script in Magento 2, trying to output a static block. It works but the block output always has template path hints -- how can I get rid of the red? Template hints are disabled everywhere in config and Mage mode is set to "developer".
Block class
/app/code/Ont/Ax/Block/Aif/Agreements.php
<?php
namespace Ont\Ax\Block\Aif;
use Magento\Framework\View\Element\Template;
class Agreements extends Template {
function __construct(Template\Context $context) {
parent::__construct($context);
}
public function foo() {
return "bar";
}
}
Block template
/app/code/Ont/Ax/view/frontend/templates/aif/agreements.phtml
<h1>Agreements</h1>
<h2>Foo? <?php echo $this->foo() ?></h2>
Test file
/__local.test.brief.php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
/* @var Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager = $obj->create("\Magento\Store\Model\StoreManagerInterface");
$storeManager->setCurrentStore(1);
/* @var \Magento\Framework\View\LayoutInterface $layout */
$layout = $obj->create("\Magento\Framework\View\LayoutInterface");
$block = $layout->createBlock("Ont\Ax\Block\Aif\Agreements");
$block->setTemplate("aif/agreements.phtml");
echo $block->toHtml();