protected function fillObject()
 {
     $this->setValuesByPost();
     if (!$this->checkInput()) {
         return false;
     }
     /** @var srCertificatePlaceholderValue $pl_value */
     foreach ($this->definition->getPlaceholderValues() as $pl_value) {
         if (!$pl_value->isEditable()) {
             continue;
         }
         foreach ($this->definition->getType()->getLanguages() as $lang) {
             $value = $this->getInput("placeholder_" . $pl_value->getId() . "_" . $lang);
             $pl_value->setValue($value, $lang);
         }
     }
     $this->definition->setSignatureId($this->getInput('signature'));
     return true;
 }
 /**
  * Clone/copy this definition for a new course
  *
  * @param int $ref_id ref-ID of new course
  * @return srCertificateDefinition
  */
 public function copy($ref_id)
 {
     $this->log('Certificate: copy definitions from ' . $this->getRefId() . ' to ' . $ref_id);
     $new_definition = srCertificateDefinition::where(array("ref_id" => $ref_id))->first();
     if (!$new_definition) {
         $this->log('there is no existing definition for ' . $ref_id . ', generating a new one.');
         $new_definition = new srCertificateDefinition();
         $new_definition->setRefId($ref_id);
         $new_definition->setTypeId($this->getTypeId());
         $new_definition->create();
     } else {
         $this->log('used existing definition for ' . $ref_id . '.');
     }
     $this->log('ID of clone: ' . $new_definition->getId());
     $new_definition->setRefId($ref_id);
     $new_definition->setTypeId($this->getTypeId());
     // Clone Signature setting
     if ($this->getSignatureId()) {
         $new_definition->setSignatureId($this->getSignatureId());
     }
     $new_definition->setTypeChanged(false);
     $new_definition->update();
     // Settings and placeholder values now contain default values inherited from type.
     // We overwrite them with the values from this definition
     /** @var $setting srCertificateDefinitionSetting */
     $this->log('copy srCertificateDefinitionSetting');
     foreach ($this->getSettings() as $setting) {
         $s = $new_definition->getSettingByIdentifier($setting->getIdentifier());
         $this->log($setting->getIdentifier());
         if (!$s instanceof srCertificateDefinitionSetting) {
             $this->log('not found, generating new one');
             $s = new srCertificateDefinitionSetting();
             $s->setDefinitionId($new_definition->getId());
             $s->setIdentifier($setting->getIdentifier());
             $s->create();
         }
         $s->setValue($setting->getValue());
         $s->update();
     }
     /** @var $ph_value srCertificatePlaceholderValue */
     $this->log('copy srCertificatePlaceholderValue');
     foreach ($this->getPlaceholderValues() as $ph_value) {
         $ph = $new_definition->getPlaceholderValueByPlaceholderId($ph_value->getPlaceholderId());
         $this->log($ph_value->getPlaceholderId());
         if (!$ph instanceof srCertificatePlaceholderValue) {
             $this->log('not found, generating new one');
             $ph = new srCertificatePlaceholderValue();
             $ph->setDefinitionId($new_definition->getId());
             $ph->setPlaceholderId($ph_value->getPlaceholderId());
             $ph->create();
         }
         $ph->setValue($ph_value->getValue());
         // This does set the values for each language
         $ph->update();
     }
     /** @var $cust_setting srCertificateCustomDefinitionSetting */
     foreach ($this->getCustomSettings() as $cust_setting) {
         $cs = $new_definition->getCustomSettingByIdentifier($cust_setting->getIdentifier());
         $this->log($cust_setting->getIdentifier());
         if (!$cs instanceof srCertificateCustomDefinitionSetting) {
             $this->log('not found, generating new one');
             $cs = new srCertificateCustomDefinitionSetting();
             $cs->setDefinitionId($new_definition->getId());
             $cs->setIdentifier($cust_setting->getIdentifier());
             $cs->create();
         }
         $cs->setValue($cust_setting->getValue());
         // This does set the values for each language
         $cs->update();
         $this->log('old value: ' . $cust_setting->getValue());
         $this->log('cloned value: ' . $cs->getValue());
     }
     $this->log('finished');
     return $new_definition;
 }