首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >在$many_many上扩展Blog模块错误

在$many_many上扩展Blog模块错误
EN

Stack Overflow用户
提问于 2019-03-25 06:18:01
回答 1查看 100关注 0票数 0

我使用Silverstipe/Blog模块作为我的基本博客功能。我将扩展一个与类别和标签具有相同功能的字段。

不幸的是,$many_many没有处理我的扩展文件。

这就是我正在经历的错误。

紧急情况下LogicException: belongs_many_many relation MyProject\Model\BlogIndustry.BlogPosts指向SilverStripe\Blog\Model\BlogPost而没有匹配的many_many

这是我的附加DataObject。

代码语言:javascript
代码运行次数:0
运行
复制
<?php

namespace MyProject\Model;

use SilverStripe\ORM\DataObject;
use Silverstripe\Blog\Model\BlogObject;
use Silverstripe\Blog\Model\CategorisationObject;
use SilverStripe\Blog\Model\Blog;
use SilverStripe\Blog\Model\BlogPost;

/**
 * A blog tag for keyword descriptions of a blog post.
 *
 *
 * @method Blog Blog()
 *
 * @property string $Title
 * @property string $URLSegment
 * @property int $BlogID
 */
class BlogIndustry extends DataObject implements CategorisationObject
{


    /**
     * Use an exception code so that attempted writes can continue on
     * duplicate errors.
     *
     * @const string
     * This must be a string because ValidationException has decided we can't use int
     */
    const DUPLICATE_EXCEPTION = 'DUPLICATE';

    /**
     * {@inheritDoc}
     * @var string
     */
    private static $table_name = 'EllisCo_BlogIndustry';

    /**
     * @var array
     */
    private static $db = [
        'Title'      => 'Varchar(255)',
        'URLSegment' => 'Varchar(255)'
    ];

    /**
     * @var array
     */
    private static $has_one = [
        'Blog' => Blog::class
    ];

    /**
     * @var array
     */
    private static $belongs_many_many = [
        'BlogPosts' => BlogPost::class
    ];

    /**
     * {@inheritdoc}
     */
    protected function getListUrlSegment()
    {
        return 'industry';
    }

    /**
     * {@inheritdoc}
     */
    protected function getDuplicateError()
    {
        return _t(__CLASS__ . '.Duplicate', 'A blog industry already exists with that name.');
    }
}

这就是我在扩展文件中包含的内容。

代码语言:javascript
代码运行次数:0
运行
复制
private static $many_many = [
        "Industries" => BlogIndustry::class,
];

任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-25 07:27:36

好吧,我搞定了。我错误地为我的命名空间设置了错误的路径。

感谢各位浏览此议题的人士:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55332181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档