public function getUnitsToRecruit(Location $l, $elite = true) { $units = $this->getUnits(true)->filter(function ($u) use($l) { return $u->getNation() && $u->getNation()->getDetails() == $l->getNation(); }); $types = array(); foreach ($units as $u) { if (in_array($u->getType(), $types) || !$elite && $u->isElite()) { $units->removeElement($u); } else { $types[] = $u->getType(); } } return $units; }
/** * Set source * * @param \Meldon\WotRBundle\Entity\Location $source * @return Connection */ public function setSource(\Meldon\WotRBundle\Entity\Location $source = null) { $this->source = $source; $source->addConnection($this); return $this; }
/** * Set location * * @param \Meldon\WotRBundle\Entity\Location $location * @return Unit */ public function setLocation(\Meldon\WotRBundle\Entity\Location $location = null) { if (is_a($this->getLocation(), 'Location')) { $this->getLocation()->removeUnit($this); } $this->location = $location; $location->addUnit($this); return $this; }