Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use DoctrineCommonCollectionsArrayCollection;
- /**
- * @Entity @Table(name="servers")
- */
- class Server
- {
- /** @Id @Column(type="integer") @GeneratedValue **/
- protected $id;
- /** @Column(type="string") **/
- protected $server_name;
- /** @Column(type="string") **/
- protected $guid;
- /** @Column(type="string") **/
- protected $server_role;
- /**
- * Many Server have One Domain.
- * @ManyToOne(targetEntity="Domain", inversedBy="servers", cascade={"refresh", "persist"})
- */
- protected $domain;
- /**
- * Many Server have One agent_Settings.
- * @ManyToOne(targetEntity="AgentSettings", inversedBy="servers", cascade={"refresh", "persist"})
- */
- protected $agent_settings;
- /**
- * Owning Side
- *
- * @ManyToMany(targetEntity="Job", inversedBy="servers")
- * @JoinTable(name="server_jobs")
- */
- protected $jobs;
- public function __construct()
- {
- $this->jobs = new ArrayCollection();
- }
- public function getJobs()
- {
- return $this->jobs;
- }
- public function addJob(Job $job)
- {
- $job->addServer($this);
- $this->jobs[] = $job;
- }
- public function removeJob(Job $job)
- {
- if(!$this->jobs->contains($job))
- {
- return;
- }
- $this->jobs->removeElement($job);
- $job->removeServer($this);
- }
- public function getId(){ return $this->id; }
- public function getName(){ return $this->server_name; }
- public function setName($name) { $this->server_name = $name; }
- public function getGuid(){ return $this->guid; }
- public function setGuid($guid) { $this->guid = $guid; }
- public function getServerRole() { return $this->server_role; }
- public function setServerRole($role) { $this->server_role = $role; }
- public function getDomain() { return $this->domain; }
- public function setDomain($domain) { $this->domain = $domain; }
- public function getAgentSettings() { return $this->agent_settings; }
- public function setAgentSettings($agent_settings) { $this->agent_settings = $agent_settings; }
- }
- ?>
- <?php
- use DoctrineCommonCollectionsArrayCollection;
- /**
- * @Entity @Table(name="domains")
- */
- class Domain
- {
- /** @Id @Column(type="integer") @GeneratedValue **/
- protected $id;
- /** @Column(type="string") **/
- protected $domain_name;
- /** @Column(type="string") **/
- protected $domain_description;
- /**
- * One Domain has many Server.
- * @OneToMany(targetEntity="Server", mappedBy="domain", cascade={"refresh"})
- */
- private $servers;
- public function __construct() {
- $this->servers = new ArrayCollection();
- }
- public function addServers($servers)
- {
- foreach ($servers as $server) {
- $this->addServer($server);
- }
- return $this;
- }
- public function addServer(Server $server)
- {
- $server->setDomain($this);
- $this->servers->add($server);
- }
- public function getId() { return $this->id; }
- public function getName() { return $this->domain_name; }
- public function addName($name) { $this->domain_name = $name; }
- public function getServers() { return $this->servers; }
- public function getDescription() { return $this->domain_description; }
- public function addDescription($description) { $this->domain_description = $description; }
- }
- targetEntity="Server"
- mappedBy="domain"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement