本文整理汇总了PHP中Espo\ORM\Entity类的典型用法代码示例。如果您正苦于以下问题:PHP Entity类的具体用法?PHP Entity怎么用?PHP Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: sendInvitations
public function sendInvitations(Entity $entity)
{
$invitationManager = $this->getInvitationManager();
$users = $entity->get('users');
foreach ($users as $user) {
$invitationManager->sendInvitation($entity, $user, 'users');
}
$contacts = $entity->get('contacts');
foreach ($contacts as $contact) {
$invitationManager->sendInvitation($entity, $contact, 'contacts');
}
$leads = $entity->get('leads');
foreach ($leads as $lead) {
$invitationManager->sendInvitation($entity, $lead, 'leads');
}
return true;
}
开发者ID:naushrambo,项目名称:espocrm,代码行数:17,代码来源:Meeting.php
示例17: process
public function process(Entity $entity)
{
if ($entity->has('assignedUserId') && $entity->get('assignedUserId')) {
$assignedUserId = $entity->get('assignedUserId');
if ($assignedUserId != $this->getUser()->id && $entity->isFieldChanged('assignedUserId')) {
$notification = $this->getEntityManager()->getEntity('Notification');
$notification->set(array('type' => 'Assign', 'userId' => $assignedUserId, 'data' => array('entityType' => $entity->getEntityType(), 'entityId' => $entity->id, 'entityName' => $entity->get('name'), 'isNew' => $entity->isNew(), 'userId' => $this->getUser()->id, 'userName' => $this->getUser()->get('name'))));
$this->getEntityManager()->saveEntity($notification);
}
}
}
开发者ID:naushrambo,项目名称:espocrm,代码行数:11,代码来源:Base.php
示例18: afterUnrelateCases
protected function afterUnrelateCases(Entity $entity, $foreign)
{
$case = null;
if ($foreign instanceof Entity) {
$case = $foreign;
} else {
if (is_string($foreign)) {
$case = $this->getEntityManager()->getEntity('Case', $foreign);
}
}
if (!$case) {
return;
}
$note = $this->getEntityManager()->getRepository('Note')->where(array('type' => 'Relate', 'parentId' => $case->id, 'parentType' => 'Case', 'relatedId' => $entity->id, 'relatedType' => $entity->getEntityType()))->findOne();
if (!$note) {
return;
}
$this->getEntityManager()->removeEntity($note);
}
开发者ID:houzhenggang,项目名称:espocrm,代码行数:19,代码来源:KnowledgeBaseArticle.php
示例19: beforeSave
protected function beforeSave(Entity $entity)
{
$eaRepositoty = $this->getEntityManager()->getRepository('EmailAddress');
$from = trim($entity->get('from'));
if (!empty($from)) {
$ids = $eaRepositoty->getIds(array($from));
if (!empty($ids)) {
$entity->set('fromEmailAddressId', $ids[0]);
}
} else {
$entity->set('fromEmailAddressId', null);
}
$this->prepareAddressess($entity, 'to');
$this->prepareAddressess($entity, 'cc');
$this->prepareAddressess($entity, 'bcc');
parent::beforeSave($entity);
$parentId = $entity->get('parentId');
$parentType = $entity->get('parentType');
if (!empty($parentId) || !empty($parentType)) {
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
if (!empty($parent)) {
if ($parent->getEntityName() == 'Account') {
$accountId = $parent->id;
} else {
if ($parent->has('accountId')) {
$accountId = $parent->get('accountId');
}
}
if (!empty($accountId)) {
$entity->set('accountId', $accountId);
}
}
} else {
// TODO find account by from address
}
}
开发者ID:jdavis593,项目名称:appitechture,代码行数:36,代码来源:Email.php
示例20: beforeSave
protected function beforeSave(Entity $entity)
{
if ($entity->isNew()) {
$userName = $entity->get('userName');
if (empty($userName)) {
throw new Error();
}
$user = $this->where(array('userName' => $userName))->findOne();
if ($user) {
throw new Error();
}
} else {
if ($entity->isFieldChanged('userName')) {
$userName = $entity->get('userName');
if (empty($userName)) {
throw new Error();
}
$user = $this->where(array('userName' => $userName, 'id!=' => $entity->id))->findOne();
if ($user) {
throw new Error();
}
}
}
}
开发者ID:lucasmattos,项目名称:crm,代码行数:24,代码来源:User.php
注:本文中的Espo\ORM\Entity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论