簡體   English   中英

在$ many_many上擴展Blog模塊錯誤

[英]Extending Blog Module error on $many_many

我使用Silverstipe / Blog模塊作為基本Blog功能。 我將擴展與類別和標簽具有相同功能的字段。

不幸的是, $ many_many在我的擴展文件上不起作用。

這是我遇到的錯誤。

[緊急]未捕獲到的LogicException:Relation_many_many關系MyProject \\ Model \\ BlogIndustry.BlogPosts指向SilverStripe \\ Blog \\ Model \\ BlogPost,但沒有匹配many_many

這是我的附加DataObject。

<?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.');
    }
}

這是我包含在擴展文件中的內容

private static $many_many = [
        "Industries" => BlogIndustry::class,
];

任何幫助是極大的贊賞。

好吧,我已經開始工作了。 我錯誤地為名稱空間輸入了錯誤的路徑。

感謝您查看此問題的人:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM