Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @return Point|null
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         return new Point();
     }
     return parent::getEntity($id);
 }
Exemplo n.º 2
0
 /**
  * Get a specific entity or generate a new one if id is empty.
  *
  * @param $id
  *
  * @return null|object
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         return new LeadNote();
     }
     return parent::getEntity($id);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  *
  * @return null|Client|Consumer
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         return $this->apiMode == 'oauth2' ? new Client() : new Consumer();
     }
     return parent::getEntity($id);
 }
Exemplo n.º 4
0
 /**
  * Get a specific entity or generate a new one if id is empty
  *
  * @param $id
  *
  * @return null|object
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         return new Event();
     }
     $entity = parent::getEntity($id);
     return $entity;
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  *
  * @param object $entity
  *
  * @return bool  Force browser refresh
  */
 public function togglePublishStatus($entity)
 {
     parent::togglePublishStatus($entity);
     //clear the cache
     /** @var \Mautic\CoreBundle\Helper\CacheHelper $cacheHelper */
     $cacheHelper = $this->factory->getHelper('cache');
     $cacheHelper->clearCache();
     return true;
 }
Exemplo n.º 6
0
 public function saveEntity($entity, $unlock = true)
 {
     if (!$entity instanceof Opportunity) {
         throw new \InvalidArgumentException('entity is not an instance of Opportunity');
     }
     if (!$entity->getOwnerUser()) {
         $entity->setOwnerUser($this->factory->getUser(true));
     }
     if ($leadId = $this->factory->getRequest()->get('leadId', false)) {
         $entity->setLead($this->factory->getModel('lead')->getEntity($leadId));
     }
     parent::saveEntity($entity);
 }
Exemplo n.º 7
0
 /**
  * Get a specific entity or generate a new one if id is empty
  *
  * @param $id
  * @return null|object
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         $entity = new Asset();
     } else {
         $entity = parent::getEntity($id);
     }
     return $entity;
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         return new User();
     }
     $entity = parent::getEntity($id);
     if ($entity) {
         //add user's permissions
         $entity->setActivePermissions($this->em->getRepository('MauticUserBundle:Permission')->getPermissionsByRole($entity->getRole()));
     }
     return $entity;
 }
Exemplo n.º 9
0
 /**
  * Delete an array of entities
  *
  * @param array $ids
  *
  * @return array
  */
 public function deleteEntities($ids)
 {
     $this->getRepository()->nullParents($ids);
     return parent::deleteEntities($ids);
 }
Exemplo n.º 10
0
 /**
  * Here just so PHPStorm calms down about type hinting.
  *
  * @param null $id
  *
  * @return null|DynamicContent
  */
 public function getEntity($id = null)
 {
     return parent::getEntity($id);
 }
Exemplo n.º 11
0
 /**
  * Get a specific entity or generate a new one if id is empty
  *
  * @param $id
  *
  * @return null|Email
  */
 public function getEntity($id = null)
 {
     if ($id === null) {
         $entity = new Email();
         $entity->setSessionId('new_' . hash('sha1', uniqid(mt_rand())));
     } else {
         $entity = parent::getEntity($id);
         if ($entity !== null) {
             $entity->setSessionId($entity->getId());
         }
     }
     return $entity;
 }
Exemplo n.º 12
0
 /**
  * @param object $entity
  */
 public function deleteEntity($entity)
 {
     // Delete custom avatar if one exists
     $imageDir = $this->factory->getSystemPath('images', true);
     $avatar = $imageDir . '/lead_avatars/avatar' . $entity->getId();
     if (file_exists($avatar)) {
         unlink($avatar);
     }
     parent::deleteEntity($entity);
 }
Exemplo n.º 13
0
 /**
  * Delete an entity
  *
  * @param  $entity
  * @return null|object
  */
 public function deleteEntity($entity)
 {
     $bundle = $entity->getBundle();
     //if it doesn't have a dot, then assume the model will be $bundle.$bundle
     $modelName = strpos($bundle, '.') === false ? $bundle . '.' . $bundle : $bundle;
     $model = $this->factory->getModel($modelName);
     $repo = $model->getRepository();
     $tableAlias = $repo->getTableAlias();
     $entities = $model->getEntities(array('filter' => array('force' => array(array('column' => $tableAlias . '.category', 'expr' => 'eq', 'value' => $entity->getId())))));
     if (!empty($entities)) {
         foreach ($entities as $e) {
             $e->setCategory(null);
         }
         $model->saveEntities($entities, false);
     }
     parent::deleteEntity($entity);
 }
Exemplo n.º 14
0
 /**
  * Create/edit entity
  *
  * @param object $entity
  * @param bool   $unlock
  */
 public function saveEntity($entity, $unlock = true)
 {
     // Set widget name from widget type if empty
     if (!$entity->getName()) {
         $entity->setName($this->translator->trans('mautic.widget.' . $entity->getType()));
     }
     parent::saveEntity($entity, $unlock);
 }
Exemplo n.º 15
0
 /**
  * @param object $entity
  */
 public function deleteEntity($entity)
 {
     // Null all the event parents for this campaign to avoid database constraints
     $this->getEventRepository()->nullEventParents($entity->getId());
     parent::deleteEntity($entity);
 }
Exemplo n.º 16
0
 /**
  * {@inheritdoc}
  *
  * @param Lead $entity
  * @param bool   $unlock
  */
 public function saveEntity($entity, $unlock = true)
 {
     //check to see if we can glean information from ip address
     if (!$entity->imported && count($ips = $entity->getIpAddresses())) {
         $fields = $entity->getFields();
         $details = $ips->first()->getIpDetails();
         if (!empty($details['city']) && empty($fields['core']['city']['value'])) {
             $entity->addUpdatedField('city', $details['city']);
         }
         if (!empty($details['region']) && empty($fields['core']['state']['value'])) {
             $entity->addUpdatedField('state', $details['region']);
         }
         if (!empty($details['country']) && empty($fields['core']['country']['value'])) {
             $entity->addUpdatedField('country', $details['country']);
         }
     }
     parent::saveEntity($entity, $unlock);
 }
Exemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 public function deleteEntities($ids)
 {
     $entities = parent::deleteEntities($ids);
     $schemaHelper = $this->factory->getSchemaHelper('table');
     foreach ($entities as $id => $entity) {
         //delete the associated results table
         $schemaHelper->deleteTable("form_results_" . $id . "_" . $entity->getAlias());
     }
     $schemaHelper->executeChanges();
     return $entities;
 }
Exemplo n.º 18
0
 /**
  * {@inheritdoc}
  *
  * @var \MauticPlugin\MauticSocialBundle\Entity\Monitoring
  */
 public function saveEntity($monitoringEntity, $unlock = true)
 {
     // we're editing an existing record
     if (!$monitoringEntity->isNew()) {
         //increase the revision
         $revision = $monitoringEntity->getRevision();
         ++$revision;
         $monitoringEntity->setRevision($revision);
     } else {
         $now = new \DateTime();
         $monitoringEntity->setDateAdded($now);
     }
     parent::saveEntity($monitoringEntity, $unlock);
 }
Exemplo n.º 19
0
 /**
  * Delete an array of entities
  *
  * @param array $ids
  *
  * @return array
  */
 public function deleteEntities($ids)
 {
     $entities = parent::deleteEntities($ids);
     //remove the column from the leads table
     $leadsSchema = $this->factory->getSchemaHelper('column', 'leads');
     foreach ($entities as $e) {
         $leadsSchema->dropColumn($e->getAlias());
     }
     $leadsSchema->executeChanges();
 }
Exemplo n.º 20
0
 /**
  * {@inheritdoc}
  *
  * @param Focus      $entity
  * @param bool|false $unlock
  */
 public function saveEntity($entity, $unlock = true)
 {
     parent::saveEntity($entity, $unlock);
     // Generate cache after save to have ID available
     $content = $this->generateJavascript($entity);
     $entity->setCache($content);
     $this->getRepository()->saveEntity($entity);
 }