“无法分析类:可能未加载或没有自动加载器?" [英] "Could not analyse class: maybe not loaded or no autoloader?"

查看:85
本文介绍了“无法分析类:可能未加载或没有自动加载器?"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个viewhelper创建了(我的第一个)扩展程序.

I created (my first) extension with one viewhelper.

糟糕,发生了错误!

Oops, an error occurred!

无法分析类:My \ Mlv \ ViewHelpers \ Format \ ReplacenewlinesViewHelper可能未加载或没有自动加载器?

Could not analyse class:My\Mlv\ViewHelpers\Format\ReplacenewlinesViewHelper maybe not loaded or no autoloader?

正在使用(带有新闻):

In use (with news):

{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:

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;
    }
}

推荐答案

您需要在视图帮助程序调用中使用驼峰式大小写:

You need to use camel case in the view helper invocation:

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

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

Furthermore you may need to define an autoload definition in your ext_emconf.php if you're using TYPO3 >=7.6 (reinstall the extension after doing so):

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

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

For more information see: http://insight.helhum.io/post/130876393595/how-to-configure-class-loading-for-extensions-in

这篇关于“无法分析类:可能未加载或没有自动加载器?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆