本文整理汇总了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')));
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}