2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\ORM\Tests\DataObjectTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $db = array(
|
|
|
|
'Title' => 'Varchar',
|
|
|
|
'DatabaseField' => 'HTMLVarchar'
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $has_one = array(
|
|
|
|
"Captain" => Player::class,
|
|
|
|
"Founder" => Player::class,
|
|
|
|
'HasOneRelationship' => Player::class,
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $has_many = array(
|
|
|
|
'SubTeams' => SubTeam::class,
|
|
|
|
'Comments' => TeamComment::class,
|
|
|
|
'Fans' => 'SilverStripe\\ORM\\Tests\\DataObjectTest\\Fan.Favourite', // Polymorphic - Team fans
|
|
|
|
'PlayerFans' => 'SilverStripe\\ORM\\Tests\\DataObjectTest\\Player.FavouriteTeam'
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $many_many = array(
|
|
|
|
'Players' => Player::class
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $many_many_extraFields = array(
|
|
|
|
'Players' => array(
|
|
|
|
'Position' => 'Varchar(100)'
|
|
|
|
)
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $belongs_many_many = array(
|
|
|
|
'Sponsors' => 'SilverStripe\\ORM\\Tests\\DataObjectTest\\EquipmentCompany.SponsoredTeams',
|
|
|
|
'EquipmentSuppliers' => 'SilverStripe\\ORM\\Tests\\DataObjectTest\\EquipmentCompany.EquipmentCustomers'
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $summary_fields = array(
|
|
|
|
'Title' => 'Custom Title',
|
|
|
|
'Title.UpperCase' => 'Title',
|
|
|
|
'Captain.ShirtNumber' => 'Captain\'s shirt number',
|
|
|
|
'Captain.FavouriteTeam.Title' => 'Captain\'s favourite team'
|
|
|
|
);
|
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';
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|