2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\ORM\Tests\DataObjectTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
2017-02-22 04:15:08 +01:00
|
|
|
use SilverStripe\ORM\HasManyList;
|
|
|
|
use SilverStripe\ORM\ManyManyList;
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2017-02-22 04:15:08 +01:00
|
|
|
/**
|
|
|
|
* @property string Title
|
|
|
|
* @property string DatabaseField
|
2018-12-18 04:46:56 +01:00
|
|
|
* @property array SalaryCap
|
|
|
|
* @property string FoundationYear
|
2021-08-08 14:04:42 +02:00
|
|
|
* @property bool CustomHydratedField
|
2017-02-22 04:15:08 +01:00
|
|
|
* @method Player Captain()
|
|
|
|
* @method Player Founder()
|
|
|
|
* @method Player HasOneRelationship()
|
|
|
|
* @method HasManyList SubTeams()
|
|
|
|
* @method HasManyList Comments()
|
|
|
|
* @method HasManyList Fans()
|
|
|
|
* @method HasManyList PlayerFans()
|
|
|
|
* @method ManyManyList Players()
|
|
|
|
* @method ManyManyList Sponsors()
|
|
|
|
* @method ManyManyList EquipmentSuppliers()
|
|
|
|
*/
|
2016-10-14 03:30:05 +02:00
|
|
|
class Team extends DataObject implements TestOnly
|
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $table_name = 'DataObjectTest_Team';
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $db = [
|
2016-12-16 05:34:21 +01:00
|
|
|
'Title' => 'Varchar',
|
2018-12-18 04:46:56 +01:00
|
|
|
'DatabaseField' => 'HTMLVarchar',
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $has_one = [
|
2016-12-16 05:34:21 +01:00
|
|
|
"Captain" => Player::class,
|
|
|
|
"Founder" => Player::class,
|
|
|
|
'HasOneRelationship' => Player::class,
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $has_many = [
|
2016-12-16 05:34:21 +01:00
|
|
|
'SubTeams' => SubTeam::class,
|
|
|
|
'Comments' => TeamComment::class,
|
2018-01-16 19:39:30 +01:00
|
|
|
'Fans' => Fan::class . '.Favourite', // Polymorphic - Team fans
|
|
|
|
'PlayerFans' => Player::class . '.FavouriteTeam'
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $many_many = [
|
2016-12-16 05:34:21 +01:00
|
|
|
'Players' => Player::class
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $many_many_extraFields = [
|
|
|
|
'Players' => [
|
2016-12-16 05:34:21 +01:00
|
|
|
'Position' => 'Varchar(100)'
|
2020-04-20 19:58:09 +02:00
|
|
|
]
|
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $belongs_many_many = [
|
2018-01-16 19:39:30 +01:00
|
|
|
'Sponsors' => EquipmentCompany::class . '.SponsoredTeams',
|
|
|
|
'EquipmentSuppliers' => EquipmentCompany::class . '.EquipmentCustomers'
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $summary_fields = [
|
2017-12-14 02:17:19 +01:00
|
|
|
'Title', // Overridden by Team_Extension
|
2016-12-16 05:34:21 +01:00
|
|
|
'Title.UpperCase' => 'Title',
|
|
|
|
'Captain.ShirtNumber' => 'Captain\'s shirt number',
|
|
|
|
'Captain.FavouriteTeam.Title' => 'Captain\'s favourite team'
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $default_sort = '"Title"';
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $extensions = [
|
|
|
|
Team_Extension::class
|
|
|
|
];
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function MyTitle()
|
|
|
|
{
|
|
|
|
return 'Team ' . $this->Title;
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function getDynamicField()
|
|
|
|
{
|
|
|
|
return 'dynamicfield';
|
|
|
|
}
|
2017-11-09 05:08:31 +01:00
|
|
|
|
|
|
|
public function ReturnsNull()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|