Source of file NewsCategory.php
Size: 3,321 Bytes - Last Modified: 2021-12-23T10:37:01+00:00
/var/www/docs.ssmods.com/process/src/src/Pages/NewsCategory.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 | <?php /** * This file is part of SilverWare. * * PHP version >=5.6.0 * * For full copyright and license information, please view the * LICENSE.md file that was distributed with this source code. * * @package SilverWare\News\Pages * @author Colin Tucker <colin@praxis.net.au> * @copyright 2017 Praxis Interactive * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/praxisnetau/silverware-news */ namespace SilverWare\News\Pages; use SilverStripe\ORM\DataList; use SilverWare\Extensions\Lists\ListViewExtension; use SilverWare\Extensions\Model\ImageDefaultsExtension; use SilverWare\Lists\ListSource; use Page; /** * An extension of the page class for a news category. * * @package SilverWare\News\Pages * @author Colin Tucker <colin@praxis.net.au> * @copyright 2017 Praxis Interactive * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/praxisnetau/silverware-news */ class NewsCategory extends Page implements ListSource { /** * Human-readable singular name. * * @var string * @config */ private static $singular_name = 'News Category'; /** * Human-readable plural name. * * @var string * @config */ private static $plural_name = 'News Categories'; /** * Description of this object. * * @var string * @config */ private static $description = 'A category within a news archive which holds a series of articles'; /** * Icon file for this object. * * @var string * @config */ private static $icon = 'silverware/news: admin/client/dist/images/icons/NewsCategory.png'; /** * Defines the table name to use for this object. * * @var string * @config */ private static $table_name = 'SilverWare_NewsCategory'; /** * Defines the default child class for this object. * * @var string * @config */ private static $default_child = NewsArticle::class; /** * Determines whether this object can exist at the root level. * * @var boolean * @config */ private static $can_be_root = false; /** * Defines the default values for the fields of this object. * * @var array * @config */ private static $defaults = [ 'ListInherit' => 1, 'HideFromMainMenu' => 1 ]; /** * Defines the allowed children for this object. * * @var array|string * @config */ private static $allowed_children = [ NewsArticle::class ]; /** * Defines the extension classes to apply to this object. * * @var array * @config */ private static $extensions = [ ListViewExtension::class, ImageDefaultsExtension::class ]; /** * Answers a list of articles within the news category. * * @return DataList */ public function getArticles() { return NewsArticle::get()->filter('ParentID', $this->ID); } /** * Answers a list of articles within the receiver. * * @return DataList */ public function getListItems() { return $this->getArticles(); } } |