mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
89c87ddbf8
* NEW: Static validation for relationships. * Unit tests added. * PR fixes * PR feedback: Execute validation on flush. * PR fixes. * PR fixes.
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Dev\Tests\Validation;
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
use SilverStripe\ORM\DataObject;
|
|
use SilverStripe\ORM\HasManyList;
|
|
use SilverStripe\ORM\ManyManyList;
|
|
use SilverStripe\ORM\ManyManyThroughList;
|
|
|
|
/**
|
|
* Class Team
|
|
*
|
|
* @property string $Title
|
|
* @method HasManyList|Member[] Members()
|
|
* @method HasManyList|Freelancer[] FreelancerMembers()
|
|
* @method ManyManyThroughList|Member[] Freelancers()
|
|
* @method ManyManyList|Hat[] ReserveHats()
|
|
*/
|
|
class Team extends DataObject implements TestOnly
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private static $table_name = 'RelationValidationTest_Team';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private static $db = [
|
|
'Title' => 'Varchar(255)',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private static $has_many = [
|
|
'Members' => Member::class . '.HomeTeam',
|
|
'FreelancerMembers' => Freelancer::class . '.TemporaryTeam',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private static $many_many = [
|
|
'ReserveHats' => Hat::class,
|
|
'Freelancers' => [
|
|
'through' => Freelancer::class,
|
|
'from' => 'TemporaryTeam',
|
|
'to' => 'TemporaryMember',
|
|
],
|
|
];
|
|
}
|