本文整理匯總了PHP中Espo\ORM\Entity::hasRelation方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::hasRelation方法的具體用法?PHP Entity::hasRelation怎麽用?PHP Entity::hasRelation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Espo\ORM\Entity
的用法示例。
在下文中一共展示了Entity::hasRelation方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handlePhoneNumberSave
protected function handlePhoneNumberSave(Entity $entity)
{
if ($entity->hasRelation('phoneNumbers') && $entity->hasField('phoneNumber')) {
$emailAddressRepository = $this->getEntityManager()->getRepository('PhoneNumber')->storeEntityPhoneNumber($entity);
}
}
示例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;
}
示例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;
}
示例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;
}