本文整理汇总了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;
}
示例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;
}
示例3: handlePhoneNumberSave
protected function handlePhoneNumberSave(Entity $entity)
{
if ($entity->hasRelation('phoneNumbers') && $entity->hasField('phoneNumber')) {
$emailAddressRepository = $this->getEntityManager()->getRepository('PhoneNumber')->storeEntityPhoneNumber($entity);
}
}
示例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;
}