|
@@ -89,20 +89,32 @@ class Host implements WorkflowInterface
|
|
protected $fixedIP = false;
|
|
protected $fixedIP = false;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @ORM\ManyToOne(targetEntity="Host", fetch="EXTRA_LAZY")
|
|
|
|
|
|
+ * @ORM\ManyToOne(targetEntity="Host", inversedBy="associatedHosts", fetch="EXTRA_LAZY")
|
|
* @ORM\JoinColumn(name="host_id", referencedColumnName="id", onDelete="SET NULL")
|
|
* @ORM\JoinColumn(name="host_id", referencedColumnName="id", onDelete="SET NULL")
|
|
*
|
|
*
|
|
* @JMS\MaxDepth(1)
|
|
* @JMS\MaxDepth(1)
|
|
*/
|
|
*/
|
|
protected $host;
|
|
protected $host;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @ORM\OneToMany(targetEntity="Host", mappedBy="host", fetch="EXTRA_LAZY")
|
|
|
|
+ *
|
|
|
|
+ * @JMS\MaxDepth(1)
|
|
|
|
+ */
|
|
|
|
+ protected $associatedHosts;
|
|
|
|
|
|
|
|
|
|
|
|
+ public function __construct()
|
|
|
|
+ {
|
|
|
|
+ $this->associatedHosts = new \Doctrine\Common\Collections\ArrayCollection();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return string
|
|
* @return string
|
|
*/
|
|
*/
|
|
public function __toString()
|
|
public function __toString()
|
|
{
|
|
{
|
|
- return strval($this->mac);
|
|
|
|
|
|
+ return $this->mac ? strval($this->mac) : sprintf('%s - %s', $this->id, $this->hostType->__toString());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -130,7 +142,7 @@ class Host implements WorkflowInterface
|
|
*/
|
|
*/
|
|
public function getMac()
|
|
public function getMac()
|
|
{
|
|
{
|
|
- return $this->mac;
|
|
|
|
|
|
+ return $this->mac ?: ($this->host ? $this->host->getMac() : '');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -233,6 +245,14 @@ class Host implements WorkflowInterface
|
|
return $this;
|
|
return $this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @return array<Host>
|
|
|
|
+ */
|
|
|
|
+ public function getAssociatedHosts()
|
|
|
|
+ {
|
|
|
|
+ return $this->associatedHosts;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @param ExecutionContextInterface $context
|
|
* @param ExecutionContextInterface $context
|
|
*/
|
|
*/
|