当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::getFetched方法代码示例

本文整理汇总了PHP中Espo\ORM\Entity::getFetched方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getFetched方法的具体用法?PHP Entity::getFetched怎么用?PHP Entity::getFetched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Espo\ORM\Entity的用法示例。


在下文中一共展示了Entity::getFetched方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleAfterSaveAccounts

 protected function handleAfterSaveAccounts(Entity $entity, array $options)
 {
     $accountIdChanged = $entity->has('accountId') && $entity->get('accountId') != $entity->getFetched('accountId');
     $titleChanged = $entity->has('title') && $entity->get('title') != $entity->getFetched('title');
     if ($accountIdChanged) {
         $accountId = $entity->get('accountId');
         if (empty($accountId)) {
             $this->unrelate($entity, 'accounts', $entity->getFetched('accountId'));
             return;
         }
     }
     if ($titleChanged) {
         if (empty($accountId)) {
             $accountId = $entity->getFetched('accountId');
             if (empty($accountId)) {
                 return;
             }
         }
     }
     if ($accountIdChanged || $titleChanged) {
         $pdo = $this->getEntityManager()->getPDO();
         $sql = "\n                SELECT id, role FROM account_contact\n                WHERE\n                    account_id = " . $pdo->quote($accountId) . " AND\n                    contact_id = " . $pdo->quote($entity->id) . " AND\n                    deleted = 0\n            ";
         $sth = $pdo->prepare($sql);
         $sth->execute();
         if ($row = $sth->fetch()) {
             if ($titleChanged && $entity->get('title') != $row['role']) {
                 $this->updateRelation($entity, 'accounts', $accountId, array('role' => $entity->get('title')));
             }
         } else {
             if ($accountIdChanged) {
                 $this->relate($entity, 'accounts', $accountId, array('role' => $entity->get('title')));
             }
         }
     }
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:35,代码来源:Contact.php

示例2: handleAfterSaveContacts

 protected function handleAfterSaveContacts(Entity $entity, array $options)
 {
     $contactIdChanged = $entity->has('contactId') && $entity->get('contactId') != $entity->getFetched('contactId');
     if ($contactIdChanged) {
         $contactId = $entity->get('contactId');
         if (empty($contactId)) {
             $this->unrelate($entity, 'contacts', $entity->getFetched('contactId'));
             return;
         }
     }
     if ($contactIdChanged) {
         $pdo = $this->getEntityManager()->getPDO();
         $sql = "\n                SELECT id FROM case_contact\n                WHERE\n                    contact_id = " . $pdo->quote($contactId) . " AND\n                    case_id = " . $pdo->quote($entity->id) . " AND\n                    deleted = 0\n            ";
         $sth = $pdo->prepare($sql);
         $sth->execute();
         if (!$sth->fetch()) {
             $this->relate($entity, 'contacts', $contactId);
         }
     }
 }
开发者ID:houzhenggang,项目名称:espocrm,代码行数:20,代码来源:CaseObj.php

示例3: storeAutoFollowEntityTypeList

 protected function storeAutoFollowEntityTypeList(Entity $entity)
 {
     $id = $entity->id;
     $isChanged = false;
     $was = $entity->getFetched('autoFollowEntityTypeList');
     $became = $entity->get('autoFollowEntityTypeList');
     if (!is_array($was)) {
         $was = [];
     }
     if (!is_array($became)) {
         $became = [];
     }
     if ($was == $became) {
         return;
     }
     $pdo = $this->getEntityManger()->getPDO();
     $sql = "DELETE FROM autofollow WHERE user_id = " . $pdo->quote($id) . "";
     $pdo->query($sql);
     $scopes = $this->getMetadata()->get('scopes');
     foreach ($became as $entityType) {
         if (isset($scopes[$entityType]) && !empty($scopes[$entityType]['stream'])) {
             $sql = "\n                    INSERT INTO autofollow (user_id, entity_type)\n                    VALUES (" . $pdo->quote($id) . ", " . $pdo->quote($entityType) . ")\n                ";
             $pdo->query($sql);
         }
     }
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:26,代码来源:Preferences.php

示例4: process

 public function process(Entity $entity)
 {
     if ($entity->get('status') !== 'Archived' && $entity->get('status') !== 'Sent') {
         return;
     }
     if ($entity->get('isJustSent')) {
         $previousUserIdList = [];
     } else {
         $previousUserIdList = $entity->getFetched('usersIds');
         if (!is_array($previousUserIdList)) {
             $previousUserIdList = [];
         }
     }
     $emailUserIdList = $entity->get('usersIds');
     if (is_null($emailUserIdList) || !is_array($emailUserIdList)) {
         return;
     }
     $userIdList = [];
     foreach ($emailUserIdList as $userId) {
         if (!in_array($userId, $userIdList) && !in_array($userId, $previousUserIdList) && $userId != $this->getUser()->id) {
             $userIdList[] = $userId;
         }
     }
     $data = array('emailId' => $entity->id, 'emailName' => $entity->get('name'));
     if (!$entity->has('from')) {
         $this->getEntityManager()->getRepository('Email')->loadFromField($entity);
     }
     $from = $entity->get('from');
     if ($from) {
         $person = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddress($from, null, ['User', 'Contact', 'Lead']);
         if ($person) {
             $data['personEntityType'] = $person->getEntityType();
             $data['personEntityName'] = $person->get('name');
             $data['personEntityId'] = $person->id;
         }
     }
     $userIdFrom = null;
     if ($person && $person->getEntityType() == 'User') {
         $userIdFrom = $person->id;
     }
     if (empty($data['personEntityId'])) {
         $data['fromString'] = \Espo\Services\Email::parseFromName($entity->get('fromString'));
         if (empty($data['fromString']) && $from) {
             $data['fromString'] = $from;
         }
     }
     $parent = null;
     if ($entity->get('parentId') && $entity->get('parentType')) {
         $parent = $this->getEntityManager()->getEntity($entity->get('parentType'), $entity->get('parentId'));
     }
     $account = null;
     if ($entity->get('accountId')) {
         $account = $this->getEntityManager()->getEntity('Account', $entity->get('accountId'));
     }
     foreach ($userIdList as $userId) {
         if ($userIdFrom == $userId) {
             continue;
         }
         if ($entity->get('status') == 'Archived') {
             if ($parent) {
                 if ($this->getStreamService()->checkIsFollowed($parent, $userId)) {
                     continue;
                 }
             }
             if ($account) {
                 if ($this->getStreamService()->checkIsFollowed($account, $userId)) {
                     continue;
                 }
             }
         }
         $notification = $this->getEntityManager()->getEntity('Notification');
         $notification->set(array('type' => 'EmailReceived', 'userId' => $userId, 'data' => $data));
         $this->getEntityManager()->saveEntity($notification);
     }
 }
开发者ID:blackmode,项目名称:espocrm,代码行数:75,代码来源:Email.php


注:本文中的Espo\ORM\Entity::getFetched方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。