當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ORM\Entity類代碼示例

本文整理匯總了PHP中Espo\ORM\Entity的典型用法代碼示例。如果您正苦於以下問題:PHP Entity類的具體用法?PHP Entity怎麽用?PHP Entity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Entity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkIsOwner

 public function checkIsOwner(User $user, Entity $entity)
 {
     if ($user->id === $entity->get('createdById')) {
         return true;
     }
     return false;
 }
開發者ID:dispossessed,項目名稱:espocrm,代碼行數:7,代碼來源:Attachment.php

示例2: sendInvitations

 public function sendInvitations(Entity $entity)
 {
     $invitationManager = $this->getInvitationManager();
     $emailHash = array();
     $users = $entity->get('users');
     foreach ($users as $user) {
         if ($user->get('emailAddress') && !array_key_exists($user->get('emailAddress'), $emailHash)) {
             $invitationManager->sendInvitation($entity, $user, 'users');
             $emailHash[$user->get('emailAddress')] = true;
         }
     }
     $contacts = $entity->get('contacts');
     foreach ($contacts as $contact) {
         if ($contact->get('emailAddress') && !array_key_exists($contact->get('emailAddress'), $emailHash)) {
             $invitationManager->sendInvitation($entity, $contact, 'contacts');
             $emailHash[$user->get('emailAddress')] = true;
         }
     }
     $leads = $entity->get('leads');
     foreach ($leads as $lead) {
         if ($lead->get('emailAddress') && !array_key_exists($lead->get('emailAddress'), $emailHash)) {
             $invitationManager->sendInvitation($entity, $lead, 'leads');
             $emailHash[$user->get('emailAddress')] = true;
         }
     }
     return true;
 }
開發者ID:mehulsbhatt,項目名稱:espocrm,代碼行數:27,代碼來源:Meeting.php

示例3: getDuplicateWhereClause

 protected function getDuplicateWhereClause(Entity $entity)
 {
     $data = array('OR' => array(array('firstName' => $entity->get('firstName'), 'lastName' => $entity->get('lastName'))));
     if ($entity->get('emailAddress')) {
         $data['OR'][] = array('emailAddress' => $entity->get('emailAddress'));
     }
     return $data;
 }
開發者ID:sanduhrs,項目名稱:espocrm,代碼行數:8,代碼來源:Lead.php

示例4: getDataFromEntity

 protected function getDataFromEntity(Entity $entity)
 {
     $data = $entity->toArray();
     $fieldDefs = $entity->getFields();
     $fieldList = array_keys($fieldDefs);
     foreach ($fieldList as $field) {
         $type = null;
         if (!empty($fieldDefs[$field]['type'])) {
             $type = $fieldDefs[$field]['type'];
         }
         if ($type == Entity::DATETIME) {
             if (!empty($data[$field])) {
                 $data[$field] = $this->dateTime->convertSystemDateTime($data[$field]);
             }
         } else {
             if ($type == Entity::DATE) {
                 if (!empty($data[$field])) {
                     $data[$field] = $this->dateTime->convertSystemDate($data[$field]);
                 }
             } else {
                 if ($type == Entity::JSON_ARRAY) {
                     if (!empty($data[$field])) {
                         $list = $data[$field];
                         $newList = [];
                         foreach ($list as $item) {
                             $v = $item;
                             if ($item instanceof \StdClass) {
                                 $v = get_object_vars($v);
                             }
                             foreach ($v as $k => $w) {
                                 $v[$k] = $this->format($v[$k]);
                             }
                             $newList[] = $v;
                         }
                         $data[$field] = $newList;
                     }
                 } else {
                     if ($type == Entity::JSON_OBJECT) {
                         if (!empty($data[$field])) {
                             $value = $data[$field];
                             if ($value instanceof \StdClass) {
                                 $data[$field] = get_object_vars($value);
                             }
                             foreach ($data[$field] as $k => $w) {
                                 $data[$field][$k] = $this->format($data[$field][$k]);
                             }
                         }
                     }
                 }
             }
         }
         if (array_key_exists($field, $data)) {
             $data[$field] = $this->format($data[$field]);
         }
     }
     return $data;
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:57,代碼來源:Htmlizer.php

示例5: save

 public function save(Entity $entity)
 {
     if ($entity->id) {
         $this->data[$entity->id] = $entity->toArray();
         $fileName = $this->getFilePath($entity->id);
         $this->getFileManager()->putContents($fileName, json_encode($this->data[$entity->id]));
         return $entity;
     }
 }
開發者ID:jdavis593,項目名稱:appitechture,代碼行數:9,代碼來源:Preferences.php

示例6: beforeSave

 public function beforeSave(Entity $entity)
 {
     if (!$entity->has('executeTime')) {
         $entity->set('executeTime', date('Y-m-d H:i:s'));
     }
     if (!$entity->has('attempts')) {
         $attempts = $this->getConfig()->get('cron.attempts', 0);
         $entity->set('attempts', $attempts);
     }
 }
開發者ID:mehulsbhatt,項目名稱:espocrm,代碼行數:10,代碼來源:Job.php

示例7: 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

示例8: afterSave

 public function afterSave(Entity $entity)
 {
     if ($this->getConfig()->get('assignmentEmailNotifications') && in_array($entity->getEntityName(), $this->getConfig()->get('assignmentEmailNotificationsEntityList', array()))) {
         $userId = $entity->get('assignedUserId');
         if (!empty($userId) && $userId != $this->getUser()->id && $entity->isFieldChanged('assignedUserId')) {
             $job = $this->getEntityManager()->getEntity('Job');
             $job->set(array('serviceName' => 'EmailNotification', 'method' => 'notifyAboutAssignmentJob', 'data' => json_encode(array('userId' => $userId, 'assignerUserId' => $this->getUser()->id, 'entityId' => $entity->id, 'entityType' => $entity->getEntityName())), 'executeTime' => date('Y-m-d H:i:s')));
             $this->getEntityManager()->saveEntity($job);
         }
     }
 }
開發者ID:lucasmattos,項目名稱:crm,代碼行數:11,代碼來源:AssignmentEmailNotification.php

示例9: loadUrlField

 protected function loadUrlField(Entity $entity)
 {
     $siteUrl = $this->getConfig()->get('siteUrl');
     $url = $siteUrl . '?entryPoint=portal';
     if ($entity->id === $this->getConfig()->get('defaultPortalId')) {
         $entity->set('isDefault', true);
     } else {
         $url .= '&id=' . $entity->id;
     }
     $entity->set('url', $url);
 }
開發者ID:houzhenggang,項目名稱:espocrm,代碼行數:11,代碼來源:Portal.php

示例10: save

 public function save(Entity $entity, array $options = array())
 {
     $isNew = $entity->isNew();
     $result = parent::save($entity, $options);
     if ($isNew) {
         if (!empty($entity->id) && $entity->has('contents')) {
             $contents = $entity->get('contents');
             $this->getFileManager()->putContents('data/upload/' . $entity->id, $contents);
         }
     }
     return $result;
 }
開發者ID:houzhenggang,項目名稱:espocrm,代碼行數:12,代碼來源:Attachment.php

示例11: checkIsOwner

 public function checkIsOwner(User $user, Entity $entity)
 {
     if ($user->id === $entity->get('assignedUserId')) {
         return true;
     }
     if ($user->id === $entity->get('createdById')) {
         return true;
     }
     if ($entity->hasLinkMultipleId('assignedUsers', $user->id)) {
         return true;
     }
     return false;
 }
開發者ID:disearth,項目名稱:espocrm,代碼行數:13,代碼來源:Email.php

示例12: checkInTeam

 public function checkInTeam(User $user, Entity $entity)
 {
     if ($entity->has('campaignId')) {
         $campaignId = $entity->get('campaignId');
         if (!$campaignId) {
             return;
         }
         $campaign = $this->getEntityManager()->getEntity('Campaign', $campaignId);
         if ($campaign && $this->getAclManager()->getImplementation('Campaign')->checkInTeam($user, $campaign)) {
             return true;
         }
     }
     return;
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:14,代碼來源:CampaignTrackingUrl.php

示例13: afterRemove

 protected function afterRemove(Entity $entity, array $options = array())
 {
     if ($entity->get('fileId')) {
         $attachment = $this->getEntityManager()->getEntity('Attachment', $entity->get('fileId'));
         if ($attachment) {
             $this->getEntityManager()->removeEntity($attachment);
         }
     }
     $pdo = $this->getEntityManager()->getPDO();
     $sql = "DELETE FROM import_entity WHERE import_id = :importId";
     $sth = $pdo->prepare($sql);
     $sth->bindValue(':importId', $entity->id);
     $sth->execute();
     parent::afterRemove($entity, $options);
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:15,代碼來源:Import.php

示例14: checkIsOwner

 public function checkIsOwner(User $user, Entity $entity)
 {
     if ($entity->has('parentId') && $entity->has('parentType')) {
         $parentType = $entity->get('parentType');
         $parentId = $entity->get('parentId');
         if (!$parentType || !$parentId) {
             return;
         }
         $parent = $this->getEntityManager()->getEntity($parentType, $parentId);
         if ($parent && $parent->has('assignedUserId') && $parent->get('assignedUserId') === $user->id) {
             return true;
         }
     }
     return;
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:15,代碼來源:EmailFilter.php

示例15: getEntityReminders

 public function getEntityReminders(Entity $entity)
 {
     $pdo = $this->getEntityManager()->getPDO();
     $reminders = array();
     $sql = "\n            SELECT id, `seconds`, `type`\n            FROM `reminder`\n            WHERE\n                `entity_type` = " . $pdo->quote($entity->getEntityType()) . " AND\n                `entity_id` = " . $pdo->quote($entity->id) . " AND\n                `deleted` = 0\n                ORDER BY `seconds` ASC\n        ";
     $sth = $pdo->prepare($sql);
     $sth->execute();
     $rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         $o = new \StdClass();
         $o->seconds = intval($row['seconds']);
         $o->type = $row['type'];
         $reminders[] = $o;
     }
     return $reminders;
 }
開發者ID:naushrambo,項目名稱:espocrm,代碼行數:16,代碼來源:Meeting.php


注:本文中的Espo\ORM\Entity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。