本文整理匯總了PHP中Mautic\CoreBundle\Model\FormModel::saveEntity方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormModel::saveEntity方法的具體用法?PHP FormModel::saveEntity怎麽用?PHP FormModel::saveEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mautic\CoreBundle\Model\FormModel
的用法示例。
在下文中一共展示了FormModel::saveEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveEntity
/**
* {@inheritdoc}
*
* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
*/
public function saveEntity($entity, $unlock = true)
{
if (!$entity instanceof User) {
throw new MethodNotAllowedHttpException(array('User'), 'Entity must be of class User()');
}
parent::saveEntity($entity, $unlock);
}
示例2: saveEntity
/**
* {@inheritdoc}
*
* @param $entity
* @param $unlock
* @return mixed
*/
public function saveEntity($entity, $unlock = true)
{
$alias = $entity->getAlias();
if (empty($alias)) {
$alias = strtolower(InputHelper::alphanum($entity->getTitle(), false, '-'));
} else {
$alias = strtolower(InputHelper::alphanum($alias, false, '-'));
}
//make sure alias is not already taken
$repo = $this->getRepository();
$testAlias = $alias;
$bundle = $entity->getBundle();
$count = $repo->checkUniqueCategoryAlias($bundle, $testAlias, $entity);
$aliasTag = $count;
while ($count) {
$testAlias = $alias . $aliasTag;
$count = $repo->checkUniqueCategoryAlias($bundle, $testAlias, $entity);
$aliasTag++;
}
if ($testAlias != $alias) {
$alias = $testAlias;
}
$entity->setAlias($alias);
parent::saveEntity($entity, $unlock);
}
示例3: saveEntity
/**
* {@inheritdoc}
*/
public function saveEntity($entity, $unlock = true)
{
if (empty($this->inConversion)) {
$alias = $entity->getAlias();
if (empty($alias)) {
$alias = strtolower(InputHelper::alphanum($entity->getTitle(), false, '-'));
} else {
$alias = strtolower(InputHelper::alphanum($alias, false, '-'));
}
//make sure alias is not already taken
$repo = $this->getRepository();
$testAlias = $alias;
$count = $repo->checkUniqueAlias($testAlias, $entity);
$aliasTag = $count;
while ($count) {
$testAlias = $alias . $aliasTag;
$count = $repo->checkUniqueAlias($testAlias, $entity);
$aliasTag++;
}
if ($testAlias != $alias) {
$alias = $testAlias;
}
$entity->setAlias($alias);
}
//set the author for new asset
if (!$entity->isNew()) {
//increase the revision
$revision = $entity->getRevision();
$revision++;
$entity->setRevision($revision);
}
parent::saveEntity($entity, $unlock);
}
示例4: saveEntity
/**
* {@inheritdoc}
*
* @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
*/
public function saveEntity($entity, $unlock = true)
{
if (!$entity instanceof Role) {
throw new MethodNotAllowedHttpException(['Role'], 'Entity must be of class Role()');
}
$isNew = $entity->getId() ? 0 : 1;
if (!$isNew) {
//delete all existing
$this->em->getRepository('MauticUserBundle:Permission')->purgeRolePermissions($entity);
}
parent::saveEntity($entity, $unlock);
}
示例5: saveEntity
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);
}
示例6: saveEntity
/**
* {@inheritdoc}
*
* @param \Mautic\PointBundle\Entity\Trigger $entity
* @param bool $unlock
*/
public function saveEntity($entity, $unlock = true)
{
$isNew = $entity->getId() ? false : true;
parent::saveEntity($entity, $unlock);
//should we trigger for existing leads?
if ($entity->getTriggerExistingLeads() && $entity->isPublished()) {
$events = $entity->getEvents();
$repo = $this->getEventRepository();
$persist = array();
$ipAddress = $this->factory->getIpAddress();
foreach ($events as $event) {
$dateTime = $this->factory->getDate($entity->getDateAdded());
$filter = array('force' => array(array('column' => 'l.date_added', 'expr' => 'lte', 'value' => $dateTime->toUtcString()), array('column' => 'l.points', 'expr' => 'gte', 'value' => $entity->getPoints())));
if (!$isNew) {
//get a list of leads that has already had this event applied
$leadIds = $repo->getLeadsForEvent($event->getId());
if (!empty($leadIds)) {
$filter['force'][] = array('column' => 'l.id', 'expr' => 'notIn', 'value' => $leadIds);
}
}
//get a list of leads that are before the trigger's date_added and trigger if not already done so
/** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
$leadModel = $this->factory->getModel('lead');
$leads = $leadModel->getEntities(array('filter' => $filter));
foreach ($leads as $l) {
if ($this->triggerEvent($event->convertToArray(), $l, true)) {
$log = new LeadTriggerLog();
$log->setIpAddress($ipAddress);
$log->setEvent($event);
$log->setLead($l);
$log->setDateFired(new \DateTime());
$event->addLog($log);
$persist[] = $event;
}
}
}
if (!empty($persist)) {
$repo->saveEntities($persist);
}
}
}
示例7: saveEntity
/**
* {@inheritdoc}
*
* @param $entity
* @param $unlock
*
* @return mixed
*/
public function saveEntity($entity, $unlock = true)
{
$alias = $entity->getAlias();
if (empty($alias)) {
$alias = $entity->getTitle();
}
$alias = $this->cleanAlias($alias, '', false, '-');
//make sure alias is not already taken
$repo = $this->getRepository();
$testAlias = $alias;
$bundle = $entity->getBundle();
$count = $repo->checkUniqueCategoryAlias($bundle, $testAlias, $entity);
$aliasTag = $count;
while ($count) {
$testAlias = $alias . $aliasTag;
$count = $repo->checkUniqueCategoryAlias($bundle, $testAlias, $entity);
++$aliasTag;
}
if ($testAlias != $alias) {
$alias = $testAlias;
}
$entity->setAlias($alias);
parent::saveEntity($entity, $unlock);
}
示例8: saveEntity
/**
* {@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']);
}
if (!empty($details['zipcode']) && empty($fields['core']['zipcode']['value'])) {
$entity->addUpdatedField('zipcode', $details['zipcode']);
}
}
parent::saveEntity($entity, $unlock);
}
示例9: saveEntity
/**
* {@inheritdoc}
*
* @param Lead $entity
* @param bool $unlock
*/
public function saveEntity($entity, $unlock = true)
{
$companyFieldMatches = [];
$fields = $entity->getFields();
$updatedFields = $entity->getUpdatedFields();
$company = null;
if (isset($updatedFields['company'])) {
$companyFieldMatches['company'] = $updatedFields['company'];
}
//check to see if we can glean information from ip address
if (!$entity->imported && count($ips = $entity->getIpAddresses())) {
$details = $ips->first()->getIpDetails();
if (!empty($details['city']) && empty($fields['core']['city']['value'])) {
$entity->addUpdatedField('city', $details['city']);
$companyFieldMatches['city'] = $details['city'];
}
if (!empty($details['region']) && empty($fields['core']['state']['value'])) {
$entity->addUpdatedField('state', $details['region']);
$companyFieldMatches['state'] = $details['region'];
}
if (!empty($details['country']) && empty($fields['core']['country']['value'])) {
$entity->addUpdatedField('country', $details['country']);
$companyFieldMatches['country'] = $details['country'];
}
if (!empty($details['zipcode']) && empty($fields['core']['zipcode']['value'])) {
$entity->addUpdatedField('zipcode', $details['zipcode']);
}
}
if (!empty($companyFieldMatches)) {
list($company, $leadAdded) = IdentifyCompanyHelper::identifyLeadsCompany($companyFieldMatches, $entity, $this->companyModel);
if ($leadAdded) {
$entity->addCompanyChangeLogEntry('form', 'Identify Company', 'Lead added to the company, ' . $company['companyname'], $company['id']);
}
unset($updatedFields['company']);
}
parent::saveEntity($entity, $unlock);
if (!empty($company)) {
// Save after the lead in for new leads created through the API and maybe other places
$this->companyModel->addLeadToCompany($company['id'], $entity, true);
}
}
示例10: saveEntity
/**
* {@inheritdoc}
*/
public function saveEntity($entity, $unlock = true)
{
$isNew = $entity->getId() ? false : true;
if ($isNew && !$entity->getAlias()) {
$alias = $this->cleanAlias($entity->getName(), '', 10);
$entity->setAlias($alias);
}
//save the form so that the ID is available for the form html
parent::saveEntity($entity, $unlock);
//now build the form table
if ($entity->getId()) {
$this->createTableSchema($entity, $isNew);
}
$this->generateHtml($entity);
}
示例11: saveEntity
/**
* {@inheritdoc}
*
* @param Page $entity
* @param bool $unlock
*/
public function saveEntity($entity, $unlock = true)
{
if (empty($this->inConversion)) {
$alias = $entity->getAlias();
if (empty($alias)) {
$alias = $entity->getTitle();
}
$alias = $this->cleanAlias($alias, '', false, '-');
//make sure alias is not already taken
$repo = $this->getRepository();
$testAlias = $alias;
$count = $repo->checkUniqueAlias($testAlias, $entity);
$aliasTag = $count;
while ($count) {
$testAlias = $alias . $aliasTag;
$count = $repo->checkUniqueAlias($testAlias, $entity);
$aliasTag++;
}
if ($testAlias != $alias) {
$alias = $testAlias;
}
$entity->setAlias($alias);
}
$now = new DateTimeHelper();
//set the author for new pages
$isNew = $entity->isNew();
if (!$isNew) {
//increase the revision
$revision = $entity->getRevision();
$revision++;
$entity->setRevision($revision);
}
// Reset the variant hit and start date if there are any changes and if this is an A/B test
// Do it here in addition to the blanket resetVariants call so that it's available to the event listeners
$changes = $entity->getChanges();
$parent = $entity->getVariantParent();
if ($parent !== null && !empty($changes) && empty($this->inConversion)) {
$entity->setVariantHits(0);
$entity->setVariantStartDate($now->getDateTime());
}
parent::saveEntity($entity, $unlock);
// If parent, add this entity as a child of the parent so that it populates the list in the tab (due to Doctrine hanging on to entities in memory)
if ($parent) {
$parent->addVariantChild($entity);
}
if ($translationParent = $entity->getTranslationParent()) {
$translationParent->addTranslationChild($entity);
}
// Reset associated variants if applicable due to changes
if ($entity->isVariant() && !empty($changes) && empty($this->inConversion)) {
$dateString = $now->toUtcString();
$parentId = !empty($parent) ? $parent->getId() : $entity->getId();
$this->getRepository()->resetVariants($parentId, $dateString);
//if the parent was changed, then that parent/children must also be reset
if (isset($changes['variantParent'])) {
$this->getRepository()->resetVariants($changes['variantParent'][0], $dateString);
}
}
}
示例12: saveEntity
/**
* {@inheritdoc}
*
* @param Page $entity
* @param bool $unlock
*/
public function saveEntity($entity, $unlock = true)
{
if (empty($this->inConversion)) {
$alias = $entity->getAlias();
if (empty($alias)) {
$alias = $entity->getTitle();
}
$alias = $this->cleanAlias($alias, '', false, '-');
//make sure alias is not already taken
$repo = $this->getRepository();
$testAlias = $alias;
$count = $repo->checkUniqueAlias($testAlias, $entity);
$aliasTag = $count;
while ($count) {
$testAlias = $alias . $aliasTag;
$count = $repo->checkUniqueAlias($testAlias, $entity);
$aliasTag++;
}
if ($testAlias != $alias) {
$alias = $testAlias;
}
$entity->setAlias($alias);
}
$now = new \DateTime();
//set the author for new pages
if (!$entity->isNew()) {
//increase the revision
$revision = $entity->getRevision();
$revision++;
$entity->setRevision($revision);
//reset the variant hit and start date if there are any changes
$changes = $entity->getChanges();
$isVariant = $entity->getVariantStartDate();
if ($isVariant !== null && !empty($changes) && empty($this->inConversion)) {
$entity->setVariantHits(0);
$entity->setVariantStartDate($now);
}
}
parent::saveEntity($entity, $unlock);
//also reset variants if applicable due to changes
if (!empty($changes) && empty($this->inConversion)) {
$parent = $entity->getVariantParent();
$children = !empty($parent) ? $parent->getVariantChildren() : $entity->getVariantChildren();
$variants = array();
if (!empty($parent)) {
$parent->setVariantHits(0);
$parent->setVariantStartDate($now);
$variants[] = $parent;
}
if (count($children)) {
foreach ($children as $child) {
$child->setVariantHits(0);
$child->setVariantStartDate($now);
$variants[] = $child;
}
}
//if the parent was changed, then that parent/children must also be reset
if (isset($changes['variantParent'])) {
$parent = $this->getEntity($changes['variantParent'][0]);
if (!empty($parent)) {
$parent->setVariantHits(0);
$parent->setVariantStartDate($now);
$variants[] = $parent;
$children = $parent->getVariantChildren();
if (count($children)) {
foreach ($children as $child) {
$child->setVariantHits(0);
$child->setVariantStartDate($now);
$variants[] = $child;
}
}
}
}
if (!empty($variants)) {
$this->saveEntities($variants, false);
}
}
}
示例13: saveEntity
/**
* {@inheritdoc}
*
* @param object $entity
* @param bool $unlock
*/
public function saveEntity($entity, $unlock = true)
{
parent::saveEntity($entity, $unlock);
$this->postTranslationEntitySave($entity);
}
示例14: saveEntity
/**
* {@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);
}
示例15: saveEntity
/**
* {@inheritdoc}
*
* @param Email $entity
* @param $unlock
*
* @return mixed
*/
public function saveEntity($entity, $unlock = true)
{
$type = $entity->getEmailType();
if (empty($type)) {
// Just in case JS failed
$entity->setEmailType('template');
}
// Ensure that list emails are published
if ($entity->getEmailType() == 'list') {
$entity->setIsPublished(true);
$entity->setPublishDown(null);
$entity->setPublishUp(null);
// Ensure that this email has the same lists assigned as the translated parent if applicable
/** @var Email $translationParent */
if ($translationParent = $entity->getTranslationParent()) {
$parentLists = $translationParent->getLists()->toArray();
$entity->setLists($parentLists);
}
}
if (!$this->updatingTranslationChildren) {
if (!$entity->isNew()) {
//increase the revision
$revision = $entity->getRevision();
$revision++;
$entity->setRevision($revision);
}
// Reset a/b test if applicable
if ($isVariant = $entity->isVariant()) {
$variantStartDate = new \DateTime();
$resetVariants = $this->preVariantSaveEntity($entity, ['setVariantSentCount', 'setVariantReadCount'], $variantStartDate);
}
parent::saveEntity($entity, $unlock);
if ($isVariant) {
$emailIds = $entity->getRelatedEntityIds();
$this->postVariantSaveEntity($entity, $resetVariants, $emailIds, $variantStartDate);
}
$this->postTranslationEntitySave($entity);
// Force translations for this entity to use the same segments
if ($entity->getEmailType() == 'list' && $entity->hasTranslations()) {
$translations = $entity->getTranslationChildren()->toArray();
$this->updatingTranslationChildren = true;
foreach ($translations as $translation) {
$this->saveEntity($translation);
}
$this->updatingTranslationChildren = false;
}
} else {
parent::saveEntity($entity, false);
}
}