本文整理汇总了PHP中Espo\ORM\Entity::loadLinkMultipleField方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::loadLinkMultipleField方法的具体用法?PHP Entity::loadLinkMultipleField怎么用?PHP Entity::loadLinkMultipleField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Espo\ORM\Entity
的用法示例。
在下文中一共展示了Entity::loadLinkMultipleField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadBccField
public function loadBccField(Entity $entity)
{
$entity->loadLinkMultipleField('bccEmailAddresses');
$names = $entity->get('bccEmailAddressesNames');
if (!empty($names)) {
$arr = array();
foreach ($names as $id => $address) {
$arr[] = $address;
}
$entity->set('bcc', implode(';', $arr));
}
}
示例2: loadLinkMultipleFields
protected function loadLinkMultipleFields(Entity $entity)
{
$fieldDefs = $this->getMetadata()->get('entityDefs.' . $entity->getEntityType() . '.fields', array());
foreach ($fieldDefs as $field => $defs) {
if (isset($defs['type']) && in_array($defs['type'], ['linkMultiple', 'attachmentMultiple']) && empty($defs['noLoad'])) {
$columns = null;
if (!empty($defs['columns'])) {
$columns = $defs['columns'];
}
$entity->loadLinkMultipleField($field, $columns);
}
}
}
示例3: createQueue
public function createQueue(Entity $massEmail, $isTest = false, $additionalTargetList = [])
{
if (!$isTest && $massEmail->get('status') !== 'Pending') {
throw new Error("Mass Email '" . $massEmail->id . "' should be 'Pending'.");
}
if (!$isTest) {
$existingQueueItemList = $this->getEntityManager()->getRepository('EmailQueueItem')->where(array('status' => ['Pending', 'Failed'], 'massEmailId' => $massEmail->id))->find();
foreach ($existingQueueItemList as $existingQueueItem) {
$this->getEntityManager()->getMapper('RDB')->deleteFromDb('EmailQueueItem', $existingQueueItem->id);
}
}
$targetHash = array();
$entityList = [];
$pdo = $this->getEntityManager()->getPDO();
if (!$isTest) {
if (!$massEmail->has('excludingTargetListsIds')) {
$massEmail->loadLinkMultipleField('excludingTargetLists');
}
$excludingTargetListIdList = $massEmail->get('excludingTargetListsIds');
$targetListCollection = $massEmail->get('targetLists');
foreach ($targetListCollection as $targetList) {
$accountList = $targetList->get('accounts', array('additionalColumnsConditions' => array('optedOut' => false)));
foreach ($accountList as $account) {
$hashId = $account->getEntityType() . '-' . $account->id;
if (!empty($targetHash[$hashId])) {
continue;
}
$toExclude = false;
foreach ($excludingTargetListIdList as $excludingTargetListId) {
$sql = "\n SELECT id FROM account_target_list\n WHERE\n account_id = " . $pdo->quote($account->id) . " AND\n target_list_id = " . $pdo->quote($excludingTargetListId) . " AND\n deleted = 0\n ";
$sth = $pdo->prepare($sql);
$sth->execute();
if ($sth->fetch()) {
$toExclude = true;
break;
}
}
if ($toExclude) {
continue;
}
$entityList[] = $account;
$targetHash[$hashId] = true;
}
$contactList = $targetList->get('contacts', array('additionalColumnsConditions' => array('optedOut' => false)));
foreach ($contactList as $contact) {
$hashId = $contact->getEntityType() . '-' . $contact->id;
if (!empty($targetHash[$hashId])) {
continue;
}
$toExclude = false;
foreach ($excludingTargetListIdList as $excludingTargetListId) {
$sql = "\n SELECT id FROM contact_target_list\n WHERE\n contact_id = " . $pdo->quote($contact->id) . " AND\n target_list_id = " . $pdo->quote($excludingTargetListId) . " AND\n deleted = 0\n ";
$sth = $pdo->prepare($sql);
$sth->execute();
if ($sth->fetch()) {
$toExclude = true;
break;
}
}
if ($toExclude) {
continue;
}
$entityList[] = $contact;
$targetHash[$hashId] = true;
}
$leadList = $targetList->get('leads', array('additionalColumnsConditions' => array('optedOut' => false)));
foreach ($leadList as $lead) {
$hashId = $lead->getEntityType() . '-' . $lead->id;
if (!empty($targetHash[$hashId])) {
continue;
}
$toExclude = false;
foreach ($excludingTargetListIdList as $excludingTargetListId) {
$sql = "\n SELECT id FROM lead_target_list\n WHERE\n lead_id = " . $pdo->quote($lead->id) . " AND\n target_list_id = " . $pdo->quote($excludingTargetListId) . " AND\n deleted = 0\n ";
$sth = $pdo->prepare($sql);
$sth->execute();
if ($sth->fetch()) {
$toExclude = true;
break;
}
}
if ($toExclude) {
continue;
}
$entityList[] = $lead;
$targetHash[$hashId] = true;
}
$userList = $targetList->get('users', array('additionalColumnsConditions' => array('optedOut' => false)));
foreach ($userList as $user) {
$hashId = $user->getEntityType() . '-' . $user->id;
if (!empty($targetHash[$hashId])) {
continue;
}
$toExclude = false;
foreach ($excludingTargetListIdList as $excludingTargetListId) {
$sql = "\n SELECT id FROM target_list_user\n WHERE\n user_id = " . $pdo->quote($user->id) . " AND\n target_list_id = " . $pdo->quote($excludingTargetListId) . " AND\n deleted = 0\n ";
$sth = $pdo->prepare($sql);
$sth->execute();
if ($sth->fetch()) {
$toExclude = true;
//.........这里部分代码省略.........
示例4: beforeSave
protected function beforeSave(Entity $entity, array $options)
{
$eaRepositoty = $this->getEntityManager()->getRepository('EmailAddress');
if ($entity->has('attachmentsIds')) {
$attachmentsIds = $entity->get('attachmentsIds');
if (!empty($attachmentsIds)) {
$entity->set('hasAttachment', true);
}
}
if ($entity->has('from') || $entity->has('to') || $entity->has('cc') || $entity->has('bcc') || $entity->has('replyTo')) {
if (!$entity->has('usersIds')) {
$entity->loadLinkMultipleField('users');
}
if ($entity->has('from')) {
$from = trim($entity->get('from'));
if (!empty($from)) {
$ids = $eaRepositoty->getIds(array($from));
if (!empty($ids)) {
$entity->set('fromEmailAddressId', $ids[0]);
$this->setUsersIdsByEmailAddressId($entity, $ids[0]);
}
} else {
$entity->set('fromEmailAddressId', null);
}
}
if ($entity->has('to')) {
$this->prepareAddressess($entity, 'to');
}
if ($entity->has('cc')) {
$this->prepareAddressess($entity, 'cc');
}
if ($entity->has('bcc')) {
$this->prepareAddressess($entity, 'bcc');
}
if ($entity->has('replyTo')) {
$this->prepareAddressess($entity, 'replyTo');
}
$usersIds = $entity->get('usersIds');
$assignedUserId = $entity->get('assignedUserId');
if (!empty($assignedUserId) && !in_array($assignedUserId, $usersIds)) {
$usersIds[] = $assignedUserId;
}
$entity->set('usersIds', $usersIds);
}
parent::beforeSave($entity, $options);
$parentId = $entity->get('parentId');
$parentType = $entity->get('parentType');
if (!empty($parentId) || !empty($parentType)) {
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
if (!empty($parent)) {
if ($parent->getEntityType() == 'Account') {
$accountId = $parent->id;
} else {
if ($parent->has('accountId')) {
$accountId = $parent->get('accountId');
}
}
if (!empty($accountId)) {
$account = $this->getEntityManager()->getEntity('Account', $accountId);
if ($account) {
$entity->set('accountId', $accountId);
$entity->set('accountName', $account->get('name'));
}
}
}
}
}
示例5: loadLinkMultipleFields
protected function loadLinkMultipleFields(Entity $entity)
{
$fieldDefs = $this->getMetadata()->get('entityDefs.' . $entity->getEntityName() . '.fields', array());
foreach ($fieldDefs as $field => $defs) {
if ($defs['type'] == 'linkMultiple') {
$columns = null;
if (!empty($defs['columns'])) {
$columns = $defs['columns'];
}
$entity->loadLinkMultipleField($field, $columns);
}
}
}
示例6: checkInTeam
public function checkInTeam(User $user, Entity $entity)
{
$userTeamIds = $user->get('teamsIds');
if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) {
return false;
}
if (!$entity->has('teamsIds')) {
$entity->loadLinkMultipleField('teams');
}
$teamIds = $entity->get('teamsIds');
if (empty($teamIds)) {
return false;
}
foreach ($userTeamIds as $id) {
if (in_array($id, $teamIds)) {
return true;
}
}
return false;
}