本文整理汇总了PHP中Espo\ORM\Entity::isFieldChanged方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::isFieldChanged方法的具体用法?PHP Entity::isFieldChanged怎么用?PHP Entity::isFieldChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Espo\ORM\Entity
的用法示例。
在下文中一共展示了Entity::isFieldChanged方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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);
}
}
}
示例3: 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();
}
}
}
}
示例4: isPermittedAssignedUser
public function isPermittedAssignedUser(Entity $entity)
{
if (!$entity->hasField('assignedUserId')) {
return true;
}
$assignedUserId = $entity->get('assignedUserId');
if (empty($assignedUserId)) {
return true;
}
$assignmentPermission = $this->getAcl()->get('assignmentPermission');
if (empty($assignmentPermission) || $assignmentPermission === true || !in_array($assignmentPermission, ['team', 'no'])) {
return true;
}
$toProcess = false;
if (!$entity->isNew()) {
if ($entity->isFieldChanged('assignedUserId')) {
$toProcess = true;
}
} else {
$toProcess = true;
}
if ($toProcess) {
if ($assignmentPermission == 'no') {
if ($this->getUser()->id != $assignedUserId) {
return false;
}
} else {
if ($assignmentPermission == 'team') {
$teamIds = $this->getUser()->get('teamsIds');
if (!$this->getEntityManager()->getRepository('User')->checkBelongsToAnyOfTeams($assignedUserId, $teamIds)) {
return false;
}
}
}
}
return true;
}