/** * Get the name of an event depending on the title field of the category. * If no title field is set, returns the event's id * * @param * $event */ public function getName(AbstractEvent $event) { if ($event instanceof \Application\Entity\PredefinedEvent) { if ($event->getParent() == null && $event->getName()) { return $event->getName(); } } $name = $event->getId(); $category = $event->getCategory(); if ($category instanceof \Application\Entity\FrequencyCategory) { $freqid = 0; $otherfreqid = 0; foreach ($event->getCustomFieldsValues() as $value) { if ($value->getCustomField()->getId() == $category->getFrequencyField()->getId()) { $freqid = $value->getValue(); } if ($value->getCustomField()->getId() == $category->getOtherFrequencyField()->getId()) { $otherfreqid = $value->getValue(); } } if ($freqid != 0) { $freq = $this->em->getRepository('Application\\Entity\\Frequency')->find($freqid); if ($freq) { if ($otherfreqid != 0) { $otherfreq = $this->em->getRepository('Application\\Entity\\Frequency')->find($otherfreqid); if ($otherfreq) { $name = $freq->getName() . ' → ' . $otherfreq->getName() . ' ' . $otherfreq->getValue(); } } else { $name = $freq->getName() . ' ' . $freq->getValue(); } } } } else { if ($category instanceof \Application\Entity\MilCategory) { $namefield = $event->getCustomFieldValue($category->getFieldname()); $name = "???"; // TODO $namefield ne peut jamais être vide !! if ($namefield) { $name = $this->sm->get('CustomFieldService')->getFormattedValue($namefield->getCustomField(), $namefield->getValue()); } $plancherfield = $event->getCustomFieldValue($category->getLowerLevelField()); $plafondfield = $event->getCustomFieldValue($category->getUpperLevelField()); $name .= ' (' . ($plancherfield !== null ? str_pad($plancherfield->getValue(), 3, '0', STR_PAD_LEFT) : '--') . '/' . ($plafondfield !== null ? str_pad($plafondfield->getValue(), 3, '0', STR_PAD_LEFT) : '--') . ')'; } else { $titlefield = $category->getFieldname(); if ($titlefield) { foreach ($event->getCustomFieldsValues() as $fieldvalue) { if ($fieldvalue->getCustomField()->getId() == $titlefield->getId()) { $tempname = $this->sm->get('CustomFieldService')->getFormattedValue($fieldvalue->getCustomField(), $fieldvalue->getValue()); if ($tempname) { $name = ($category->getParent() != null ? $category->getShortName() : '') . ' ' . $tempname; } } } } } } return $name; }
public function __construct() { parent::__construct(); }
public function getArrayCopy() { $object_vars = array_merge(get_object_vars($this), parent::getArrayCopy()); $object_vars['status'] = $this->status ? $this->status->getId() : null; $object_vars['author'] = $this->author ? $this->author->getId() : null; $object_vars['recurrence'] = $this->recurrence ? $this->recurrence->getId() : null; return $object_vars; }