/** * {@inheritdoc} * * @return Point|null */ public function getEntity($id = null) { if ($id === null) { return new Point(); } return parent::getEntity($id); }
/** * 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); }
/** * {@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); }
/** * 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; }
/** * {@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; }
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); }
/** * 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; }
/** * {@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; }
/** * Delete an array of entities * * @param array $ids * * @return array */ public function deleteEntities($ids) { $this->getRepository()->nullParents($ids); return parent::deleteEntities($ids); }
/** * Here just so PHPStorm calms down about type hinting. * * @param null $id * * @return null|DynamicContent */ public function getEntity($id = null) { return parent::getEntity($id); }
/** * 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; }
/** * @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); }
/** * 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); }
/** * 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); }
/** * @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); }
/** * {@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); }
/** * {@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; }
/** * {@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); }
/** * 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(); }
/** * {@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); }