silverstripe-blog/src/Model/BlogTag.php

78 lines
1.5 KiB
PHP
Raw Normal View History

2015-05-09 16:33:12 +02:00
<?php
namespace SilverStripe\Blog\Model;
use SilverStripe\ORM\DataObject;
use SilverStripe\Blog\Model\BlogObject;
use SilverStripe\Blog\Model\CategorisationObject;
2015-05-09 16:33:12 +02:00
/**
* A blog tag for keyword descriptions of a blog post.
*
* @package silverstripe
* @subpackage blog
*
* @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
{
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 = 'BlogTag';
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' => 'SilverStripe\\Blog\\Model\\Blog'
2015-11-21 07:17:29 +01:00
);
/**
* @var array
*/
private static $belongs_many_many = array(
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost'
2015-11-21 07:17:29 +01:00
);
/**
* {@inheritdoc}
*/
protected function getListUrlSegment()
2015-11-21 07:17:29 +01:00
{
return 'tags';
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
*/
protected function getDuplicateError()
2015-11-21 07:17:29 +01:00
{
return _t('BlogTag.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
}