public function delete(IEntity $entity)
 {
     $entity->clearCapabilities();
     $entity->clearHypervisors();
     $entity->clearGuests();
     parent::delete($entity);
 }
 /**
  * @param IEntity $entity
  * @return mixed
  */
 public function serialize(IEntity $entity)
 {
     if (!$entity instanceof OpenStackComponent) {
         throw new InvalidArgumentException();
     }
     $res = array('id' => $entity->ID, 'name' => $entity->Name, 'description' => $entity->Description, 'code_name' => $entity->CodeName, 'slug' => $entity->getSlug(), 'adoption' => $entity->Adoption, 'icon_css_class' => $entity->IconClass, 'age' => $entity->Age, 'maturity_points' => $entity->MaturityPoints);
     return $res;
 }
 /**
  * @param IEntity $entity
  */
 public function __construct(IEntity $entity)
 {
     if ($entity instanceof DataExtension) {
         $this->entity_class = get_class($entity->getOwner());
     } else {
         $this->entity_class = get_class($entity);
     }
 }
 /**
  * @param IEntity $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send(IEntity $subject)
 {
     if (!$subject instanceof IPresentationSpeaker) {
         return;
     }
     $subject->registerAnnouncementEmailTypeSent(IPresentationSpeaker::AnnouncementEmailRejected);
     $email = EmailFactory::getInstance()->buildEmail('*****@*****.**', $subject->getEmail());
     $email->setUserTemplate('presentation-speaker-rejected-only')->populateTemplate(array('Speaker' => $subject))->send();
 }
 /**
  * @param IEntity $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send(IEntity $subject)
 {
     if (!$subject instanceof IPresentationSpeaker) {
         return;
     }
     $subject->registerAnnouncementEmailTypeSent(IPresentationSpeaker::AnnouncementEmailAlternate);
     $email = EmailFactory::getInstance()->buildEmail('*****@*****.**', $subject->getEmail());
     $email->setUserTemplate('presentation-speaker-alternate-only')->populateTemplate(array('Speaker' => $subject, 'ConfirmationLink' => $subject->getSpeakerConfirmationLink(), 'ScheduleMainPageLink' => Summit::get_active()->SchedUrl, 'PromoCode' => $subject->getSummitPromoCode()->getCode()))->send();
 }
 /**
  * @param IEntity $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send(IEntity $subject)
 {
     if (!$subject instanceof Member) {
         return;
     }
     $sender = Member::currentUser();
     $to = $subject->getEmail();
     $from = defined('SURVEY_THANK_U_FROM_EMAIL') ? SURVEY_THANK_U_FROM_EMAIL : Config::inst()->get('Email', 'admin_email');
     $email = EmailFactory::getInstance()->buildEmail($from, $to);
     $email->setUserTemplate('survey-builder-new-team-member')->populateTemplate(array('Sender' => $sender, 'Member' => $subject, 'Link' => Director::absoluteBaseURL() . Director::makeRelative('surveys')))->send();
 }
Example #7
0
 public function __construct(IEntity $oRecordObject)
 {
     /*
      * @Todo: Inject logged in user too. Think about it.
      */
     if ($this->oDatabaseConnection == NULL) {
         $this->oDatabaseConnection = new DatabaseOps();
     }
     $this->oRecord = $oRecordObject;
     $this->aRecordProperties = $oRecordObject->getAllProperties();
 }
 /**
  * @param array $file_ids
  * @param string  $fieldname
  * @param IEntity $entity
  * @return void
  */
 public function upload(array $file_ids, $fieldname, IEntity $entity)
 {
     // assume that the file is connected via a has-one
     $relation = $entity->hasMethod($fieldname) ? $entity->{$fieldname}() : null;
     // try to create a file matching the relation
     if ($relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
         // has_many or many_many
         $relation->setByIDList($file_ids);
     } elseif ($entity->has_one($fieldname)) {
         // has_one
         $entity->{"{$fieldname}ID"} = $file_ids ? reset($file_ids) : 0;
     }
 }
 /**
  * @param IEntity $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send(IEntity $subject)
 {
     if (!$subject instanceof ISurvey) {
         return;
     }
     $current_step = $subject->currentStep();
     $template = $current_step->template();
     if (!$template instanceof ISurveyThankYouStepTemplate) {
         return;
     }
     $owner = $subject->createdBy();
     $to = $owner->getEmail();
     $from = defined('SURVEY_THANK_U_FROM_EMAIL') ? SURVEY_THANK_U_FROM_EMAIL : Config::inst()->get('Email', 'admin_email');
     $email = EmailFactory::getInstance()->buildEmail($from, $to);
     $email->setUserTemplate('survey-builder-thank-you-step')->populateTemplate(array('Member' => $owner))->send();
 }
 public function delete(IEntity $entity)
 {
     $entity->clearClients();
     $entity->clearOffices();
     $entity->clearSpokenLanguages();
     $entity->clearExpertiseAreas();
     $entity->clearServicesOffered();
     parent::delete($entity);
 }
Example #11
0
 /**
  * Check value
  * @param string $value
  * @return boolean
  */
 public function check($value)
 {
     if ($this->key === null) {
         throw new \RuntimeException('Is not set params before check');
     }
     $this->fields[$this->key] = $value;
     foreach ($this->array as $validator) {
         $label = $this->labels[$this->key];
         $stop = $validator->validateField($this->key, $this->fields, $label);
         if ($validator->hasErrors()) {
             foreach ($validator->getErrors()->all() as $error) {
                 $this->entity->addError($this->key, $error);
             }
         }
         if ($stop !== true) {
             return false;
         }
     }
     return true;
 }
Example #12
0
 /**
  * @param IEntity
  * @param array id => id
  * @param array id => id {@see ManyToMany::$injectedValue}
  * @return array id => id
  */
 public function load(IEntity $parent, $injectedValue)
 {
     $mapped = $this->meta->getWhereIsMapped();
     if ($mapped === RelationshipMetaDataToMany::MAPPED_THERE or $mapped === RelationshipMetaDataToMany::MAPPED_BOTH) {
         $childRepo = $parent->getModel()->{$this->meta->getChildRepository()};
         $childParam = $this->meta->getChildParam();
         $pid = $parent->id;
         $value = array();
         if ($mapped === RelationshipMetaDataToMany::MAPPED_BOTH) {
             $value = $injectedValue;
         }
         foreach ($childRepo->mapper->findAll() as $child) {
             $childInjectedValue = $child->{$childParam}->getInjectedValue();
             if ($childInjectedValue and isset($childInjectedValue[$pid])) {
                 $value[$child->id] = $child->id;
             }
         }
         return $value;
     } else {
         return $injectedValue;
     }
 }
 /**
  * @param IEntity $entity
  * @return int
  */
 public function add(IEntity $entity)
 {
     //supported components
     foreach ($entity->getOpenStackComponents(true) as $component) {
         $entity->getManyManyComponents('Components')->Add($component);
     }
     //supported versions
     foreach ($entity->getSupportedApiVersions(true) as $supported_version) {
         $entity->getComponents('SupportedApiVersions')->add($supported_version);
     }
     return $entity->write();
 }
 /**
  * @param IEntity $entity
  * @return void
  */
 public function delete(IEntity $entity)
 {
     $entity->clearVideos();
     $entity->clearResources();
     parent::delete($entity);
 }
 public function delete(IEntity $entity)
 {
     $entity->clearDataCenterRegions();
     $entity->clearDataCentersLocations();
     parent::delete($entity);
 }
Example #16
0
 /**
  * Pokud v entitě existuje primární klíč a nemá hodnotu nula, aktualizuje daný záznam v databázi.
  * @param IEntity $baseEntity
  */
 public function update(IEntity $baseEntity)
 {
     $pk = $this->getTablePk();
     if (isset($baseEntity->{$pk}) && $baseEntity->{$pk} == 0) {
         return;
     }
     $this->getConnection()->update($this->getTableName(), $baseEntity->getValues())->where("[{$pk}] = %i", $baseEntity->{$pk})->execute();
 }
 /**
  * @param IEntity $entity
  * @return void
  */
 public function delete(IEntity $entity)
 {
     $entity->clearRegionalSupports();
     parent::delete($entity);
 }
Example #18
0
 /**
  * Fires event.
  * @param int one event (e.g. Events::HYDRATE_BEFORE)
  * @param IEntity|NULL
  * @param array reference
  * @return Events $this
  * @see EventArguments
  */
 public function fireEvent($type, IEntity $entity = NULL, array &$arguments = array())
 {
     if (!isset(self::$instructions[$type])) {
         throw new InvalidArgumentException(array($this, 'fireEvent() $type', 'valid event type', $type));
     }
     $hasEntityEvent = self::$instructions[$type][2];
     if ($hasEntityEvent or $this->listeners[$type]) {
         $args = new EventArguments($type, $this->repository, $entity, $arguments);
         foreach ($this->listeners[$type] as $k => $event) {
             if ($event[0] === false) {
                 $this->handleLazy($event[1]);
                 $event = $this->listeners[$type][$k];
             }
             call_user_func($event[1], $args);
             $args->check();
             // srozumitelna chyba na ukor vykonu
         }
         $arguments = $args->getArguments();
     }
     if ($hasEntityEvent) {
         $more = NULL;
         if ($hasEntityEvent === 'onLoad') {
             $more = $args->data;
         } else {
             if ($hasEntityEvent === 'onPersist') {
                 $more = $args->id;
             }
         }
         $entity->fireEvent($hasEntityEvent, $this->repository, $more);
     }
     return $this;
 }
Example #19
0
 /**
  * Check if entity is not attached to another repository.
  * @param IEntity
  * @param bool
  * @return bool
  * @throws InvalidEntityException
  */
 private function checkEntityRepository(IEntity $entity, $throw = true)
 {
     $r = $entity->getRepository(false);
     if ($r and $r !== $this->repository) {
         if ($throw) {
             throw new InvalidEntityException(EntityHelper::toString($entity) . ' is attached to another repository.');
         }
         return false;
     }
     return true;
 }
 /**
  * @param IEntity $entity
  * @return void
  */
 public function delete(IEntity $entity)
 {
     $entity->clearLocations();
     $entity->clearCoursePreRequisites();
     $entity->clearRelatedProjects();
     parent::delete($entity);
 }
Example #21
0
 public function setToCache(IEntity $entity)
 {
     $id = $entity->getIdentifier();
     $class_name = get_class($entity);
     if (!array_key_exists($class_name, $this->identity_map)) {
         $this->identity_map[$class_name] = array();
     }
     $this->identity_map[$class_name][$id] = $entity;
 }
 public function delete(IEntity $entity)
 {
     $entity->clearLocations();
     parent::delete($entity);
 }