2015-05-09 16:33:12 +02:00
|
|
|
<?php
|
|
|
|
|
2016-12-15 04:41:49 +01:00
|
|
|
namespace SilverStripe\Blog\Model;
|
|
|
|
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
|
2015-05-09 16:33:12 +02:00
|
|
|
/**
|
|
|
|
* A blog tag for keyword descriptions of a blog post.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @method Blog Blog()
|
|
|
|
*
|
|
|
|
* @property string $Title
|
|
|
|
* @property string $URLSegment
|
|
|
|
* @property int $BlogID
|
|
|
|
*/
|
2015-11-21 07:17:29 +01:00
|
|
|
class BlogTag extends DataObject implements CategorisationObject
|
|
|
|
{
|
2016-06-02 03:11:05 +02:00
|
|
|
use BlogObject;
|
2016-02-05 01:33:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-12-15 04:41:49 +01:00
|
|
|
const DUPLICATE_EXCEPTION = 'DUPLICATE';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private static $table_name = 'BlogTag';
|
2016-02-05 01:33:40 +01:00
|
|
|
|
2015-11-21 07:17:29 +01:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-14 00:59:01 +02:00
|
|
|
private static $db = [
|
2016-12-15 04:41:49 +01:00
|
|
|
'Title' => 'Varchar(255)',
|
|
|
|
'URLSegment' => 'Varchar(255)'
|
2017-09-14 00:59:01 +02:00
|
|
|
];
|
2015-11-21 07:17:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-14 00:59:01 +02:00
|
|
|
private static $has_one = [
|
2017-01-26 09:28:42 +01:00
|
|
|
'Blog' => Blog::class
|
2017-09-14 00:59:01 +02:00
|
|
|
];
|
2015-11-21 07:17:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-14 00:59:01 +02:00
|
|
|
private static $belongs_many_many = [
|
2017-01-26 09:28:42 +01:00
|
|
|
'BlogPosts' => BlogPost::class
|
2017-09-14 00:59:01 +02:00
|
|
|
];
|
2015-11-21 07:17:29 +01:00
|
|
|
|
2016-02-05 01:33:40 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-06-02 03:11:05 +02:00
|
|
|
protected function getListUrlSegment()
|
2015-11-21 07:17:29 +01:00
|
|
|
{
|
2017-01-13 03:55:48 +01:00
|
|
|
return 'tag';
|
2015-11-21 07:17:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-01 07:28:59 +02:00
|
|
|
* {@inheritdoc}
|
2015-11-21 07:17:29 +01:00
|
|
|
*/
|
2016-06-02 03:11:05 +02:00
|
|
|
protected function getDuplicateError()
|
2015-11-21 07:17:29 +01:00
|
|
|
{
|
2017-09-14 00:27:40 +02:00
|
|
|
return _t(__CLASS__ . '.Duplicate', 'A blog tag already exists with that name.');
|
2015-11-21 07:17:29 +01:00
|
|
|
}
|
2015-05-09 16:33:12 +02:00
|
|
|
}
|