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


PHP Entity::hasAttribute方法代碼示例

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


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

示例1: isPermittedTeams

 public function isPermittedTeams(Entity $entity)
 {
     $assignmentPermission = $this->getAcl()->get('assignmentPermission');
     if (empty($assignmentPermission) || $assignmentPermission === true || !in_array($assignmentPermission, ['team', 'no'])) {
         return true;
     }
     if (!$entity->hasAttribute('teamsIds')) {
         return true;
     }
     $teamIds = $entity->get('teamsIds');
     if (empty($teamIds)) {
         return true;
     }
     $newIds = [];
     if (!$entity->isNew()) {
         $existingIds = [];
         foreach ($entity->get('teams') as $team) {
             $existingIds[] = $team->id;
         }
         foreach ($teamIds as $id) {
             if (!in_array($id, $existingIds)) {
                 $newIds[] = $id;
             }
         }
     } else {
         $newIds = $teamIds;
     }
     if (empty($newIds)) {
         return true;
     }
     $userTeamIds = $this->getUser()->get('teamsIds');
     foreach ($newIds as $id) {
         if (!in_array($id, $userTeamIds)) {
             return false;
         }
     }
     return true;
 }
開發者ID:disearth,項目名稱:espocrm,代碼行數:38,代碼來源:Record.php

示例2: checkIsOwnContact

 public function checkIsOwnContact(User $user, Entity $entity)
 {
     $contactId = $user->get('contactId');
     if ($contactId) {
         if ($entity->hasAttribute('contactId')) {
             if ($entity->get('contactId') === $contactId) {
                 return true;
             }
         }
         if ($entity->hasRelation('contacts')) {
             $repository = $this->getEntityManager()->getRepository($entity->getEntityType());
             if ($repository->isRelated($entity, 'contacts', $contactId)) {
                 return true;
             }
         }
         if ($entity->hasAttribute('parentId') && $entity->hasRelation('parent')) {
             if ($entity->get('parentType') === 'Contact') {
                 if ($entity->get('parentId') === $contactId) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
開發者ID:houzhenggang,項目名稱:espocrm,代碼行數:25,代碼來源:Base.php

示例3: checkInTeam

 public function checkInTeam(User $user, Entity $entity)
 {
     $userTeamIdList = $user->getLinkMultipleIdList('teams');
     if (!$entity->hasRelation('teams') || !$entity->hasAttribute('teamsIds')) {
         return false;
     }
     $entityTeamIdList = $entity->getLinkMultipleIdList('teams');
     if (empty($entityTeamIdList)) {
         return false;
     }
     foreach ($userTeamIdList as $id) {
         if (in_array($id, $entityTeamIdList)) {
             return true;
         }
     }
     return false;
 }
開發者ID:dispossessed,項目名稱:espocrm,代碼行數:17,代碼來源:Base.php

示例4: handlePhoneNumberSave

 protected function handlePhoneNumberSave(Entity $entity)
 {
     if ($entity->hasRelation('phoneNumbers') && $entity->hasAttribute('phoneNumber')) {
         $emailAddressRepository = $this->getEntityManager()->getRepository('PhoneNumber')->storeEntityPhoneNumber($entity);
     }
 }
開發者ID:disearth,項目名稱:espocrm,代碼行數:6,代碼來源:RDB.php


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