silverstripe-blog/src/Model/BlogCategory.php

78 lines
1.5 KiB
PHP
Raw Normal View History

2015-11-21 07:17:29 +01:00
<?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;
2015-11-21 07:17:29 +01:00
/**
* A blog category for generalising blog posts.
*
*
2015-11-21 07:17:29 +01:00
* @method Blog Blog()
*
* @property string $Title
2015-11-21 07:17:29 +01:00
* @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';
2015-11-21 07:17:29 +01:00
/**
* @var array
*/
private static $db = array(
'Title' => 'Varchar(255)',
'URLSegment' => 'Varchar(255)'
2015-11-21 07:17:29 +01:00
);
/**
* @var array
*/
private static $has_one = array(
'Blog' => Blog::class,
2015-11-21 07:17:29 +01:00
);
/**
* @var array
*/
private static $belongs_many_many = array(
'BlogPosts' => BlogPost::class,
2015-11-21 07:17:29 +01:00
);
/**
* {@inheritdoc}
*/
protected function getListUrlSegment()
2015-11-21 07:17:29 +01:00
{
return 'category';
2015-11-21 07:17:29 +01:00
}
/**
* {@inheritdoc}
*/
protected function getDuplicateError()
{
2017-09-14 00:27:40 +02:00
return _t(__CLASS__ . '.Duplicate', 'A blog category already exists with that name.');
}
2015-11-21 07:17:29 +01:00
}