您尝试注册的课程不可用[TYPO3 8.7.26] [英] The class you are trying to register is not available [TYPO3 8.7.26]

查看:77
本文介绍了您尝试注册的课程不可用[TYPO3 8.7.26]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在TYPO3中安装自己创建的扩展程序。我的composer.json文件ar位置/ var / www / html / typo3看起来像:

I'm installing self created extensions in TYPO3. My composer.json file ar location /var/www/html/typo3 looks like:

{
        "repositories": [{
                        "type": "composer",
                        "url": "https://composer.typo3.org/"
                },
                {
                        "type": "package",
                        "package": {
                                "name": "Bm/ah-content-api",
                                "version": "0.0.1",
                                "type": "typo3-cms-extension",
                                "source": {
                                        "url": "https://user@bitbucket.org/company/ah_config_typo3.git",
                                        "type": "git",
                                        "reference": "master"
                                },
                                "autoload": {
                                        "psr-4": {
                                                "bm\\ah-content-api\\": "typo3conf/ext/ah-contentapi/Classes"
                                        }
                                }
                        }
                },

                {
                        "type": "package",
                        "package": {
                                "name": "Bm/ah-contentelements",
                                "version": "0.0.1",
                                "type": "typo3-cms-extension",
                                "source": {
                                        "url": "https://user@bitbucket.org/company/ah_contentelements_typo3.git",
                                        "type": "git",
                                        "reference": "master"
                                },
                                "autoload": {
                                        "psr-4": {
                                                "bm\\ah-contentelements\\": "typo3conf/ext/ah-contentelements/Classes",
                                        }
                                }
                        }
                }
        ],
"name": "typo3/cms-base-distribution",
        "description": "TYPO3 CMS Base Distribution",
        "license": "GPL-2.0-or-later",
        "require": {
                "helhum/typo3-console": "^4.9.3 || ^5.2",
                "typo3/cms-about": "^8.7.10",
                "typo3/cms-belog": "^8.7.10",
                "typo3/cms-beuser": "^8.7.10",
                "typo3/cms-context-help": "^8.7.10",
                "typo3/cms-documentation": "^8.7.10",
                "typo3/cms-felogin": "^8.7.10",
                "typo3/cms-fluid-styled-content": "^8.7.10",
                "typo3/cms-form": "^8.7.10",
                "typo3/cms-func": "^8.7.10",
                "typo3/cms-impexp": "^8.7.10",
                "typo3/cms-info": "^8.7.10",
                "typo3/cms-info-pagetsconfig": "^8.7.10",
                "typo3/cms-rte-ckeditor": "^8.7.10",
                "typo3/cms-setup": "^8.7.10",
                "typo3/cms-sys-note": "^8.7.10",
                "typo3/cms-t3editor": "^8.7.10",
                "typo3/cms-tstemplate": "^8.7.10",
                "typo3/cms-viewpage": "^8.7.10",
                "typo3/cms-wizard-crpages": "^8.7.10",
                "typo3/cms-wizard-sortpages": "^8.7.10",
                "dmitryd/typo3-realurl": "2.*",
                "GridElementsTeam/Gridelements": "8.2.*",
                "clickstorm/cs_seo": "3.*",
                "Bm/ah-content-api": "0.0.1",
                "Bm/ah-contentelements": "0.0.1"
        },
        "scripts": {
                "typo3-cms-scripts": [
                        "typo3cms install:fixfolderstructure",
                        "typo3cms install:generatepackagestates"
                ],
                "post-autoload-dump": [
                        "@typo3-cms-scripts"
                ]
        },
        "extra": {
                "typo3/cms": {
                        "web-dir": "public"
                },
                "helhum/typo3-console": {
                        "comment": "This option is not needed ay more for helhum/typo3-console 5.x",
                        "install-extension-dummy": false
                }
        }
}

扩展的数据存储在git repos中。在根目录中有一个composer.json文件:

The data for the extensions are stored in the git repos. With each a composer.json file in the root:

{
  "name": "Bm/ah-contentelements",
  "type": "typo3-cms-extension",
  "description": "descr,
  "homepage": "http://www.company.de/",
  "suggest": {
  },
  "require": {
    "typo3/cms-core": ">=8.0.0,<9.0"
  },
  "author": [
    {
      "name": "name",
      "email": "sdsd@company.de"
    }
  ],
  "autoload": {
    "psr-4": {
      "Bm\\AhContentelements\\": "Classes/"
    }
  }
}

 {
    "name": "bm/ah-content-api",
    "type": "typo3-cms-extension",
    "description": "Content API Extension",
    "homepage": "http://www.company.de/",
    "license": [
        "GPL-2.0+"
    ],
    "require": {
        "typo3/cms-core": ">=7.5.0,<9.0"
    },
    "autoload": {
        "psr-4": {
            "Bm\\AhContentapi\\": "Classes/"
        }
    },
    "replace": {
        "ah_contentapi": "self.version",
        "typo3-ter/ah_contentapi" : "self.version"
    }
}

我运行以下命令:

sudo作曲家更新

sudo composer dump-autoload

在TYPO3中仍然没有可用的类。

出现错误消息我尝试运行:

Still there are classes not available in TYPO3.
Error message when I try to run:

#1411840171: The class "Bm\AhContentelements\Rendering\VideoTagRenderer" you are trying to register is not available

我正在使用 TYPO3 8.7.26

VideoTagRenderer:

VideoTagRenderer:

<?php
namespace Bm\AhContentelements\Rendering;


/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\FileReference;

/**
 * Class VideoTagRenderer
 */
class VideoTagRenderer extends \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer
{
    /**
     * Mime types that can be used in the HTML Video tag
     *
     * @var array
     */
    protected $possibleMimeTypes = ['video/mp4', 'video/webm', 'video/quicktime', 'video/ogg', 'application/ogg'];

    /**
     * Returns the priority of the renderer
     * This way it is possible to define/overrule a renderer
     * for a specific file type/context.
     * For example create a video renderer for a certain storage/driver type.
     * Should be between 1 and 100, 100 is more important than 1
     *
     * @return int
     */
    public function getPriority()
    {
        return 2;
    }

    /**
     * Check if given File(Reference) can be rendered
     *
     * @param FileInterface $file File or FileReference to render
     * @return bool
     */
    public function canRender(FileInterface $file)
    {
        return in_array($file->getMimeType(), $this->possibleMimeTypes, true);
    }

    /**
     * Render for given File(Reference) HTML output
     *
     * @param FileInterface $file
     * @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
     * @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
     * @param array $options controls = TRUE/FALSE (default TRUE), autoplay = TRUE/FALSE (default FALSE), loop = TRUE/FALSE (default FALSE)
     * @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
     * @return string
     */
    public function render(FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript = false)
    {

        // If autoplay isn't set manually check if $file is a FileReference take autoplay from there
        if (!isset($options['autoplay']) && $file instanceof FileReference) {
            $autoplay = $file->getProperty('autoplay');
            if ($autoplay !== null) {
                $options['autoplay'] = $autoplay;
            }
        }

        $attributes = [];
        if ((int)$width > 0) {
            $attributes[] = 'width="' . (int)$width . '"';
        }
        if ((int)$height > 0) {
            $attributes[] = 'height="' . (int)$height . '"';
        }
        if (!isset($options['controls']) || !empty($options['controls'])) {
            $attributes[] = 'controls';
        }
        if (!empty($options['autoplay'])) {
            $attributes[] = 'autoplay';
        }
        if (!empty($options['muted'])) {
            $attributes[] = 'muted';
        }
        if (!empty($options['loop'])) {
            $attributes[] = 'loop';
        }
        foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick'] as $key) {
            if (!empty($options[$key])) {
                $attributes[] = $key . '="' . htmlspecialchars($options[$key]) . '"';
            }
        }

        $extension = $file->getExtension();
        if ('ogv' == $extension) {
            $extension = 'ogg';
        }

        $useMimetype = 'video/'.$extension;


        return sprintf(
            '<video%s><source src="%s" type="%s"></video>',
            empty($attributes) ? '' : ' ' . implode(' ', $attributes),
            htmlspecialchars($file->getPublicUrl($usedPathsRelativeToCurrentScript)),
            $useMimetype
        );
    }
}


推荐答案

As在链接的文章中提到:问题是您软件包中的composer.json被忽略。

As mentioned in the linked article: The problem is that the composer.json in you packages are ignored.

相反,您必须设置正确的psr在您的主要composer.json文件中为-4。我修复了提供的代码段以使其匹配:

Instead you have to set the correct psr-4 in your main composer.json file. I fixed the provided snippet to match it:

    "autoload": {
      "psr-4": {
        "Bm\\AhContentapi\\": "typo3conf/ext/ah-contentapi/Classes"
      }
    }

    "autoload": {
      "psr-4": {
        "Bm\\AhContentelements\\": "typo3conf/ext/ah-contentelements/Classes"
      }
    }

> http://blog.pepa.info/php-html-css/composer/composer-not-autoloading-your-package/

侧边注:删除多余的> helhum / typo3-console部分||

Sidenote: Remove the extra > helhum/typo3-console part || It's not needed anymore

编辑1:

,只要扩展名已经是您vcs代码的一部分(选中)在)中,您可以简单地避开存储库部分,只需将以下内容添加到您的主要composer.json文件中:

Edit 1:
As long as the extensions are already part of your vcs code (checked in) you can simply avoid the repository part and simply add the following to your main composer.json file:

"autoload": {
  "psr-4": {
    "Bm\\AhContentelements\\": "typo3conf/ext/ah-contentelements/Classes",
    "Bm\\AhContentapi\\": "typo3conf/ext/ah-contentapi/Classes"
  }
}

如果扩展名不是vcs / git回购的一部分,您可以简单地使用版本9中的约定,并将自己的扩展名提取到Packages / TYPO3根目录下目录。然后,添加以下存储库条目,而不是当前的软件包条目:

If the extensions are NOT part of your vcs/git repo you can simply use a convention from version 9 and extract your own extensions in a folder named Packages/ your TYPO3 root directory. Then you add the following "repository" entry instead of your current package entries:

    {
        "type": "path",
        "url": "Packages/*",
        "options": {
            "symlink": true
        }
    }

在下一个作曲家运行后,您应该现在看到扩展名已链接。

记住三件事:

After the next composer run you should see your extensions linked now.
Remember three things:


  1. 基于Windows文件系统的符号链接行为 CAN 在compsoer链接期间创建了错误的链接。然后正确地重新创建它们。

  2. 重新检查路径,并注意由于路径错误而引起的任何问题

  3. composer的区别安装作曲者更新

  1. Symlink behavior based on a windows-filesystem CAN create incorrect symlinks during compsoer symlinking. Recreate them correctly afterwards.
  2. Recheck the paths and be aware of any problems due to incorrect paths
  3. The differences of composer install and composer update

这篇关于您尝试注册的课程不可用[TYPO3 8.7.26]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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