Source of file BlogCategory.php

Size: 1,566 Bytes - Last Modified: 2017-09-25T23:16:42+00:00

/var/www/docs.ssmods.com/process/src/src/Model/BlogCategory.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
<?php

namespace SilverStripe\Blog\Model;

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

/**
 * A blog category for generalising blog posts.
 *
*
 * @method Blog Blog()
 *
 * @property string $Title
 * @property string $URLSegment
 * @property int $BlogID
 */
class BlogCategory extends DataObject implements CategorisationObject
{
    use BlogObject;

    /**
     * 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 = 'BlogCategory';

    /**
     * @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 'category';
    }

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