Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. <?php
  2. use DoctrineCommonCollectionsArrayCollection;
  3.  
  4. /**
  5. * @Entity @Table(name="servers")
  6. */
  7. class Server
  8. {
  9. /** @Id @Column(type="integer") @GeneratedValue **/
  10. protected $id;
  11.  
  12. /** @Column(type="string") **/
  13. protected $server_name;
  14.  
  15. /** @Column(type="string") **/
  16. protected $guid;
  17.  
  18. /** @Column(type="string") **/
  19. protected $server_role;
  20.  
  21. /**
  22. * Many Server have One Domain.
  23. * @ManyToOne(targetEntity="Domain", inversedBy="servers", cascade={"refresh", "persist"})
  24. */
  25. protected $domain;
  26.  
  27. /**
  28. * Many Server have One agent_Settings.
  29. * @ManyToOne(targetEntity="AgentSettings", inversedBy="servers", cascade={"refresh", "persist"})
  30. */
  31. protected $agent_settings;
  32.  
  33.  
  34. /**
  35. * Owning Side
  36. *
  37. * @ManyToMany(targetEntity="Job", inversedBy="servers")
  38. * @JoinTable(name="server_jobs")
  39. */
  40. protected $jobs;
  41.  
  42. public function __construct()
  43. {
  44. $this->jobs = new ArrayCollection();
  45. }
  46. public function getJobs()
  47. {
  48. return $this->jobs;
  49. }
  50. public function addJob(Job $job)
  51. {
  52. $job->addServer($this);
  53. $this->jobs[] = $job;
  54. }
  55.  
  56. public function removeJob(Job $job)
  57. {
  58. if(!$this->jobs->contains($job))
  59. {
  60. return;
  61. }
  62. $this->jobs->removeElement($job);
  63. $job->removeServer($this);
  64. }
  65.  
  66. public function getId(){ return $this->id; }
  67.  
  68. public function getName(){ return $this->server_name; }
  69.  
  70. public function setName($name) { $this->server_name = $name; }
  71.  
  72. public function getGuid(){ return $this->guid; }
  73.  
  74. public function setGuid($guid) { $this->guid = $guid; }
  75.  
  76. public function getServerRole() { return $this->server_role; }
  77.  
  78. public function setServerRole($role) { $this->server_role = $role; }
  79.  
  80. public function getDomain() { return $this->domain; }
  81.  
  82. public function setDomain($domain) { $this->domain = $domain; }
  83.  
  84. public function getAgentSettings() { return $this->agent_settings; }
  85.  
  86. public function setAgentSettings($agent_settings) { $this->agent_settings = $agent_settings; }
  87. }
  88.  
  89. ?>
  90.  
  91. <?php
  92. use DoctrineCommonCollectionsArrayCollection;
  93.  
  94. /**
  95. * @Entity @Table(name="domains")
  96. */
  97. class Domain
  98. {
  99. /** @Id @Column(type="integer") @GeneratedValue **/
  100. protected $id;
  101.  
  102. /** @Column(type="string") **/
  103. protected $domain_name;
  104.  
  105. /** @Column(type="string") **/
  106. protected $domain_description;
  107.  
  108. /**
  109. * One Domain has many Server.
  110. * @OneToMany(targetEntity="Server", mappedBy="domain", cascade={"refresh"})
  111. */
  112. private $servers;
  113.  
  114. public function __construct() {
  115. $this->servers = new ArrayCollection();
  116. }
  117. public function addServers($servers)
  118. {
  119. foreach ($servers as $server) {
  120. $this->addServer($server);
  121. }
  122. return $this;
  123. }
  124. public function addServer(Server $server)
  125. {
  126. $server->setDomain($this);
  127. $this->servers->add($server);
  128. }
  129.  
  130. public function getId() { return $this->id; }
  131.  
  132. public function getName() { return $this->domain_name; }
  133.  
  134. public function addName($name) { $this->domain_name = $name; }
  135.  
  136. public function getServers() { return $this->servers; }
  137.  
  138. public function getDescription() { return $this->domain_description; }
  139.  
  140. public function addDescription($description) { $this->domain_description = $description; }
  141. }
  142.  
  143. targetEntity="Server"
  144.  
  145. mappedBy="domain"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement