当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::hasField方法代码示例

本文整理汇总了PHP中Espo\ORM\Entity::hasField方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::hasField方法的具体用法?PHP Entity::hasField怎么用?PHP Entity::hasField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Espo\ORM\Entity的用法示例。


在下文中一共展示了Entity::hasField方法的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->hasField('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:naushrambo,项目名称:espocrm,代码行数:38,代码来源:Record.php

示例2: parseValue

 protected function parseValue(Entity $entity, $field, $value, $params = array())
 {
     $decimalMark = '.';
     if (!empty($params['decimalMark'])) {
         $decimalMark = $params['decimalMark'];
     }
     $defaultCurrency = 'USD';
     if (!empty($params['defaultCurrency'])) {
         $defaultCurrency = $params['defaultCurrency'];
     }
     $dateFormat = 'Y-m-d';
     if (!empty($params['dateFormat'])) {
         if (!empty($this->dateFormatsMap[$params['dateFormat']])) {
             $dateFormat = $this->dateFormatsMap[$params['dateFormat']];
         }
     }
     $timeFormat = 'H:i';
     if (!empty($params['timeFormat'])) {
         if (!empty($this->timeFormatsMap[$params['timeFormat']])) {
             $timeFormat = $this->timeFormatsMap[$params['timeFormat']];
         }
     }
     $fieldDefs = $entity->getFields();
     if (!empty($fieldDefs[$field])) {
         $type = $fieldDefs[$field]['type'];
         switch ($type) {
             case Entity::DATE:
                 $dt = \DateTime::createFromFormat($dateFormat, $value);
                 if ($dt) {
                     return $dt->format('Y-m-d');
                 }
                 break;
             case Entity::DATETIME:
                 $dt = \DateTime::createFromFormat($dateFormat . ' ' . $timeFormat, $value);
                 if ($dt) {
                     return $dt->format('Y-m-d H:i');
                 }
                 break;
             case Entity::FLOAT:
                 $currencyField = $field . 'Currency';
                 if ($entity->hasField($currencyField)) {
                     if (!$entity->has($currencyField)) {
                         $entity->set($currencyField, $defaultCurrency);
                     }
                 }
                 $a = explode($decimalMark, $value);
                 $a[0] = preg_replace('/[^A-Za-z0-9\\-]/', '', $a[0]);
                 if (count($a) > 1) {
                     return $a[0] . '.' . $a[1];
                 } else {
                     return $a[0];
                 }
                 break;
         }
     }
     return $value;
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:57,代码来源:Import.php

示例3: handlePhoneNumberSave

 protected function handlePhoneNumberSave(Entity $entity)
 {
     if ($entity->hasRelation('phoneNumbers') && $entity->hasField('phoneNumber')) {
         $emailAddressRepository = $this->getEntityManager()->getRepository('PhoneNumber')->storeEntityPhoneNumber($entity);
     }
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:6,代码来源:RDB.php

示例4: checkInTeam

 public function checkInTeam(User $user, Entity $entity)
 {
     $userTeamIds = $user->get('teamsIds');
     if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) {
         return false;
     }
     if (!$entity->has('teamsIds')) {
         $entity->loadLinkMultipleField('teams');
     }
     $teamIds = $entity->get('teamsIds');
     if (empty($teamIds)) {
         return false;
     }
     foreach ($userTeamIds as $id) {
         if (in_array($id, $teamIds)) {
             return true;
         }
     }
     return false;
 }
开发者ID:blackmode,项目名称:espocrm,代码行数:20,代码来源:Base.php


注:本文中的Espo\ORM\Entity::hasField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。