Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'MageComp_Catalog::product/view/extra.phtml' in module: 'MageComp_Catalog' block's name: 'product.view.extra' code example

Example: Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file:

> protected function isPathInDirectories($path, $directories) {
>     if (!is_array($directories)) {
>         $directories = (array)$directories;
>     }
>     $realPath = $this->fileDriver->getRealPath($path);
>     $realPath = str_replace('\\', '/', $realPath); // extra code added
>     foreach ($directories as $directory) {
>         if (0 === strpos($realPath, $directory)) {
>             return true;
>         }
>     }
>     return false; }

Tags:

Php Example