本文整理汇总了PHP中Espo\ORM\Entity::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::get方法的具体用法?PHP Entity::get怎么用?PHP Entity::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Espo\ORM\Entity
的用法示例。
在下文中一共展示了Entity::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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);
}
}
}
示例4: getIscContents
protected function getIscContents(Entity $entity)
{
$user = $entity->get('assignedUser');
$who = '';
$email = '';
if ($user) {
$who = $user->get('name');
$email = $user->get('emailAddress');
}
$ics = new Ics('//EspoCRM//EspoCRM Calendar//EN', array('startDate' => strtotime($entity->get('dateStart')), 'endDate' => strtotime($entity->get('dateEnd')), 'uid' => $entity->id, 'summary' => $entity->get('name'), 'who' => $who, 'email' => $email, 'description' => $entity->get('description')));
return $ics->get();
}
示例5: checkIsOwner
public function checkIsOwner(User $user, Entity $entity)
{
if ($entity->has('assignedUserId')) {
if ($user->id === $entity->get('assignedUserId')) {
return true;
}
}
if ($user->id === $entity->get('createdById')) {
return true;
}
return false;
}
示例6: 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;
}
示例7: 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);
}
示例8: 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;
}
示例9: handleCreateRelated
protected function handleCreateRelated(Entity $entity)
{
$linkDefs = $this->getMetadata()->get("entityDefs." . $entity->getEntityName() . ".links", array());
$scopeNotifiedList = array();
foreach ($linkDefs as $link => $defs) {
if ($defs['type'] == 'belongsTo') {
if (empty($defs['foreign']) || empty($defs['entity'])) {
continue;
}
$foreign = $defs['foreign'];
$scope = $defs['entity'];
$entityId = $entity->get($link . 'Id');
if (!empty($scope) && !empty($entityId)) {
if (in_array($scope, $scopeNotifiedList) || !$this->isLinkObservableInStream($scope, $foreign)) {
continue;
}
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId);
$scopeNotifiedList[] = $scope;
}
} else {
if ($defs['type'] == 'belongsToParent') {
$foreign = $defs['foreign'];
if (empty($defs['foreign'])) {
continue;
}
$scope = $entity->get($link . 'Type');
$entityId = $entity->get($link . 'Id');
if (!empty($scope) && !empty($entityId)) {
if (in_array($scope, $scopeNotifiedList) || !$this->isLinkObservableInStream($scope, $foreign)) {
continue;
}
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId);
$scopeNotifiedList[] = $scope;
}
} else {
if ($defs['type'] == 'hasMany') {
if (empty($defs['foreign']) || empty($defs['entity'])) {
continue;
}
$foreign = $defs['foreign'];
$scope = $defs['entity'];
$entityIds = $entity->get($link . 'Ids');
if (!empty($scope) && is_array($entityIds) && !empty($entityIds)) {
if (in_array($scope, $scopeNotifiedList) || !$this->isLinkObservableInStream($scope, $foreign)) {
continue;
}
$entityId = $entityIds[0];
$this->getStreamService()->noteCreateRelated($entity, $scope, $entityId);
$scopeNotifiedList[] = $scope;
}
}
}
}
}
}
示例10: storeEntity
protected function storeEntity(Entity $entity)
{
$assignedUserId = $entity->get('assignedUserId');
if ($assignedUserId && $entity->has('usersIds')) {
$usersIds = $entity->get('usersIds');
if (!is_array($usersIds)) {
$usersIds = array();
}
if (!in_array($assignedUserId, $usersIds)) {
$usersIds[] = $assignedUserId;
$entity->set('usersIds', $usersIds);
$hash = $entity->get('usersNames');
if ($hash instanceof \stdClass) {
$hash->assignedUserId = $entity->get('assignedUserName');
$entity->set('usersNames', $hash);
}
}
}
return parent::storeEntity($entity);
}
示例11: 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);
}
}
}
示例12: 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);
}
}
}
示例13: afterSave
public function afterSave(Entity $entity)
{
if ($entity->isNew()) {
$parentType = $entity->get('parentType');
$parentId = $entity->get('parentId');
$superParentType = $entity->get('superParentType');
$superParentTypeId = $entity->get('superParentTypeId');
$userIdList = [];
if ($parentType && $parentId) {
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($parentType, $parentId));
}
if ($superParentType && $superParentTypeId) {
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($superParentType, $superParentTypeId));
}
//$userIdList = array_merge($userIdList, $this->getMentionedUserIdList($entity));
$userIdList = array_unique($userIdList);
if (!empty($userIdList)) {
$this->getNotificationService()->notifyAboutNote($userIdList, $entity);
}
}
}
示例14: 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;
}
示例15: 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();
}
}
}
}