php static driver
This commit is contained in:
parent
f0b04375de
commit
415c2a95f2
5 changed files with 89 additions and 6 deletions
|
@ -129,4 +129,44 @@ abstract class CompanyContract
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function calculatePrice();
|
abstract public function calculatePrice();
|
||||||
|
|
||||||
|
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
|
||||||
|
{
|
||||||
|
$metadata->setInheritanceType(\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_JOINED);
|
||||||
|
$metadata->setTableName( 'company_contracts');
|
||||||
|
$metadata->setDiscriminatorColumn(array(
|
||||||
|
'name' => 'discr',
|
||||||
|
'type' => 'string',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'id' => true,
|
||||||
|
'name' => 'id',
|
||||||
|
'fieldName' => 'id',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'type' => 'boolean',
|
||||||
|
'name' => 'completed',
|
||||||
|
'fieldName' => 'completed',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->setDiscriminatorMap(array(
|
||||||
|
"fix" => "CompanyFixContract",
|
||||||
|
"flexible" => "CompanyFlexContract",
|
||||||
|
"flexultra" => "CompanyFlexUltraContract"
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,13 @@ class CompanyFixContract extends CompanyContract
|
||||||
{
|
{
|
||||||
$this->fixPrice = $fixPrice;
|
$this->fixPrice = $fixPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
|
||||||
|
{
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'name' => 'fixPrice',
|
||||||
|
'fieldName' => 'fixPrice',
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -107,4 +107,19 @@ class CompanyFlexContract extends CompanyContract
|
||||||
{
|
{
|
||||||
$this->managers->removeElement($manager);
|
$this->managers->removeElement($manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
|
||||||
|
{
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'name' => 'hoursWorked',
|
||||||
|
'fieldName' => 'hoursWorked',
|
||||||
|
));
|
||||||
|
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'name' => 'pricePerHour',
|
||||||
|
'fieldName' => 'pricePerHour',
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,27 @@ class CompanyFlexUltraContract extends CompanyFlexContract
|
||||||
{
|
{
|
||||||
$this->maxPrice = $maxPrice;
|
$this->maxPrice = $maxPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
|
||||||
|
{
|
||||||
|
$metadata->mapField(array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'name' => 'maxPrice',
|
||||||
|
'fieldName' => 'maxPrice',
|
||||||
|
));
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'ContractSubscriber', 'postPersistHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'ContractSubscriber', 'prePersistHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postUpdate, 'ContractSubscriber', 'postUpdateHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::preUpdate, 'ContractSubscriber', 'preUpdateHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postRemove, 'ContractSubscriber', 'postRemoveHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::preRemove, 'ContractSubscriber', 'preRemoveHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::preFlush, 'ContractSubscriber', 'preFlushHandler');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::postLoad, 'ContractSubscriber', 'postLoadHandler');
|
||||||
|
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler1');
|
||||||
|
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'FlexUltraContractSubscriber', 'prePersistHandler2');
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -758,9 +758,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||||
*/
|
*/
|
||||||
public function testEntityListeners()
|
public function testEntityListeners()
|
||||||
{
|
{
|
||||||
if ( ! ($this instanceof AnnotationDriverTest)
|
if ($this instanceof PHPMappingDriverTest) {
|
||||||
&& ! ($this instanceof XmlMappingDriverTest)
|
|
||||||
&& ! ($this instanceof YamlMappingDriverTest)) {
|
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,9 +816,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||||
*/
|
*/
|
||||||
public function testCallEntityListeners()
|
public function testCallEntityListeners()
|
||||||
{
|
{
|
||||||
if ( ! ($this instanceof AnnotationDriverTest)
|
if ($this instanceof PHPMappingDriverTest) {
|
||||||
&& ! ($this instanceof XmlMappingDriverTest)
|
|
||||||
&& ! ($this instanceof YamlMappingDriverTest)) {
|
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue