-->

“无法分析类:可能没有加载或没有自动加载”(“Could not analyse class: ma

2019-09-29 19:04发布

我创建了(我的第一个)扩展一个视图助手。

糟糕,出现错误!

无法分析类:我\ MLV \ ViewHelpers \格式\ ReplacenewlinesViewHelper也许没有加载或没有自动加载磁带机?

在使用(新闻):

{namespace m=My\Mlv\ViewHelpers}
{newsItem.bodytext -> m:format.replacenewlines()}

扩展的目录树:

typo3conf/ext/mlv
  ext_emconf.php (copied from another ext)
  /Classes
    /ViewHelpers
      /Format
        ReplaceNewLinesViewHelper.php

ReplaceNewLinesViewHelper.php:

<?php
namespace My\Mlv\ViewHelpers\Format;

/**
 * Replaces newlines in plain text with <br> tags.
 *
 * @author johndoe33
 * @package Mlv
 * @subpackage ViewHelpers\Format
 */
class ReplaceNewLinesViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {

    /**
     * Replaces newlines in plain text with <br> tags.
     *
     * @param string $content
     * @return string
     */
    public function render($content = NULL) {
        if (NULL === $content) {
            $content = $this->renderChildren();
        }
        $content = str_replace( "\n", '<br>', $content );
        return $content;
    }
}

Answer 1:

您需要在视图助手调用使用骆驼情况:

{newsItem.bodytext -> m:format.replaceNewLines()}

此外,您可能需要在ext_emconf.php定义一个自动加载的定义,如果你正在使用TYPO3> = 7.6(重新安装这样做后的扩展名):

'autoload' => array(
  'psr-4' => array('My\\Mlv\\' => 'Classes')
)

更多信息请参见: http://insight.helhum.io/post/130876393595/how-to-configure-class-loading-for-extensions-in



文章来源: “Could not analyse class: maybe not loaded or no autoloader?”