@param string $companyUserKey

@throws \Pyz\Zed\DataImport\Business\Exception\EntityNotFoundException

@return int
8065
protected function getIdCompanyUserByKey(string $companyUserKey): int
    {
        if (!isset($this->idCompanyUserListCache[$companyUserKey])) {
            $idCompanyUser = $this->getCompanyUserQuery()
                ->filterByKey($companyUserKey)
                ->select(SpyCompanyUserTableMap::COL_ID_COMPANY_USER)
                ->findOne();

            if (!$idCompanyUser) {
                throw new EntityNotFoundException(sprintf('Could not find company user by key "%s"', $companyUserKey));
            }

            $this->idCompanyUserListCache[$companyUserKey] = $idCompanyUser;
        }

        return $this->idCompanyUserListCache[$companyUserKey];
    }
290383
public function execute(DataSetInterface $dataSet): void
    {
        $companyUserKey = $dataSet[ShoppingListCompanyUserDataSetInterface::COLUMN_COMPANY_USER_KEY];
        if (!isset($this->idCompanyUserCache[$companyUserKey])) {
            $companyUserQuery = new SpyCompanyUserQuery();
            $idCompanyUser = $companyUserQuery
                ->select([SpyCompanyUserTableMap::COL_ID_COMPANY_USER])
                ->findOneByKey($companyUserKey);

            if (!$idCompanyUser) {
                throw new EntityNotFoundException(sprintf('Could not find company user by key "%s"', $companyUserKey));
            }

            $this->idCompanyUserCache[$companyUserKey] = $idCompanyUser;
        }

        $dataSet[ShoppingListCompanyUserDataSetInterface::ID_COMPANY_USER] = $this->idCompanyUserCache[$companyUserKey];
    }
785034
public function getUserdata($key, $namespace)
    {
        $ret = $this->read($key, $namespace);

        list(,, $userdata) = $ret;
        return $userdata;
    }
132067
protected function getIdCategoryByKey(string $categoryKey): int
    {
        if (!isset($this->idCategoryCache[$categoryKey])) {
            /** @var \Orm\Zed\Category\Persistence\SpyCategoryQuery $categoryQuery */
            $categoryQuery = SpyCategoryQuery::create()
                ->select(SpyCategoryTableMap::COL_ID_CATEGORY);

            /** @var int|null $idCategory */
            $idCategory = $categoryQuery->findOneByCategoryKey($categoryKey);

            if (!$idCategory) {
                throw new EntityNotFoundException(sprintf('Could not find Category by key "%s"', $categoryKey));
            }
            $this->idCategoryCache[$categoryKey] = $idCategory;
        }

        return $this->idCategoryCache[$categoryKey];
    }
895603
public function loadUserByUsername($clientKey): TenantInterface
    {
        $tenant = $this->findTenant($clientKey);
        if (!$tenant) {
            throw new UsernameNotFoundException('Can\'t find tenant with such username');
        }

        return $this->findTenant($clientKey);
    }
1286669
public static List<CommercePriceListUserSegmentEntryRel> findByUuid_C(
		String uuid, long companyId) {
		return getPersistence().findByUuid_C(uuid, companyId);
	}
870400
public function Synchronize($UserKey, $Data) {
      $UserID = 0;
      
      $Attributes = ArrayValue('Attributes', $Data);
      if (is_string($Attributes))
         $Attributes = @unserialize($Attributes);

      if (!is_array($Attributes))
         $Attributes = array();

      // If the user didnt log in, they won't have a UserID yet. That means they want a new
      // account. So create one for them.
      if (!isset($Data['UserID']) || $Data['UserID'] <= 0) {
      
         // Prepare the user data.
         $UserData['Name'] = $Data['Name'];
         $UserData['Password'] = RandomString(16);
         $UserData['Email'] = ArrayValue('Email', $Data, 'no@email.com');
         $UserData['Gender'] = strtolower(substr(ArrayValue('Gender', $Data, 'u'), 0, 1));
         $UserData['HourOffset'] = ArrayValue('HourOffset', $Data, 0);
         $UserData['DateOfBirth'] = ArrayValue('DateOfBirth', $Data, '');
         $UserData['CountNotifications'] = 0;
         $UserData['Attributes'] = $Attributes;
         $UserData['InsertIPAddress'] = Gdn::Request()->IpAddress();
         if ($UserData['DateOfBirth'] == '')
            $UserData['DateOfBirth'] = '1975-09-16';
            
         // Make sure there isn't another user with this username.
         if ($this->ValidateUniqueFields($UserData['Name'], $UserData['Email'])) {
            if (!BanModel::CheckUser($UserData, $this->Validation, TRUE))
               throw PermissionException('Banned');
            
            // Insert the new user.
            $this->AddInsertFields($UserData);
            $UserID = $this->_Insert($UserData);
         }

         if ($UserID) {
            $NewUserRoleIDs = $this->NewUserRoleIDs();
            
            // Save the roles.
            $Roles = GetValue('Roles', $Data, FALSE);
            if (empty($Roles))
               $Roles = $NewUserRoleIDs;
            
            $this->SaveRoles($UserID, $Roles, FALSE);
         }
      } else {
         $UserID = $Data['UserID'];
      }
      
      // Synchronize the transientkey from the external user data source if it is present (eg. WordPress' wpnonce).
      if (array_key_exists('TransientKey', $Attributes) && $Attributes['TransientKey'] != '' && $UserID > 0)
         $this->SetTransientKey($UserID, $Attributes['TransientKey']);

      return $UserID;
   }
1101634
public function find($storageName, $key)
    {
        $qb = $this->conn->createQueryBuilder();

        $qb->select('s.' . $this->dataColumn)
            ->from($this->table, 's')
            ->where($this->keyColumn . ' = ?')
            ->setParameters([$key]);

        $stmt = $qb->execute();

        $data = $stmt->fetchColumn();

        if (! $data) {
            throw new NotFoundException();
        }

        return unserialize($data);
    }
147509
public function getEntity($entityId)
    {
        //test the entity name
        if ($entityId == null) {
            throw new \Exception('The businessEntityId is not defined for the entityProxy with the id:'.$this->getId());
        }

        $functionName = 'get'.ucfirst($entityId);
        $entity = call_user_func([$this, $functionName]);

        return $entity;
    }
1121751
private function updateUserRole(UserRole $userRole, $userRoleData)
    {
        $role = $this->roleRepository->findRoleById($userRoleData['role']['id']);

        if (!$role) {
            throw new EntityNotFoundException($this->roleRepository->getClassName(), $userRole['role']['id']);
        }

        $userRole->setRole($role);
        if (array_key_exists('locales', $userRoleData)) {
            $userRole->setLocale(json_encode($userRoleData['locales']));
        } else {
            $userRole->setLocale($userRoleData['locale']);
        }

        return true;
    }
190521
public function count($key)
    {
        $key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;

        return (int) $this->getRedisClient()->bitcount($key);
    }
1070601
public function deleteFromFlexiBee($company = null)
    {
        if (is_null($company)) {
            $company = $this->getDataValue('dbNazev');
        }
        $this->performRequest('/c/'.$company.'.'.$this->format, 'DELETE');
        return $this->lastResponseCode == 200;
    }
822937
public function load(string $company, string $key, string $useragent = ''): array
    {
        $loaderFactory = $this->loaderFactory;

        /** @var \BrowserDetector\Loader\DeviceLoader $loader */
        $loader = $loaderFactory($company);

        return $loader->load($key, $useragent);
    }
427581
protected function getForeignKeyReferenceCount($fkey, $max = null)
    {
        $count = 0;
        $tablename = $fkey->getReferencedTable()->getRawTableName();
        $columns = array();
        foreach ($this->getColumns() as $column) {
            foreach ($column->getForeignKeys() as $foreignKey) {
                // process only unique foreign key
                if (in_array($foreignKey->getId(), $columns)) {
                    continue;
                }
                $columns[] = $foreignKey->getId();
                if ($this->checkForeignKeyOwnerTableName($foreignKey, $tablename)) {
                    $count++;
                }
                if ($max && $count == $max) {
                    break;
                }
            }
        }

        return $count;
    }
104705
protected function assertHaveProductMeasurementSalesUnit(string $productSku): void
    {
        $this->addProductMeasurementSalesUnitCheckToHeap($productSku);

        if (static::$productMeasurementSalesUnitHeap[$productSku]) {
            return;
        }

        throw new EntityNotFoundException(sprintf("Product measurement sales unit was not found for SKU '%s'", $productSku));
    }
675243
protected function getUser($userKey)
    {
        $userKey = $this->referenceResolver->resolveReference($userKey);
        return $this->userMatcher->matchOneByKey($userKey);
    }
687599
public function unsetSessionUser($sessionKey = NULL) {
		
		$sessionKey = $sessionKey ?: SessionUser::DEFAULT_KEY_NAME;
		
		$user = Session::getSessionDataBag()->get($sessionKey);
		
		if($user) {
			
			if(!$user instanceof SessionUser) {
				throw new UserException(sprintf("Session key '%s' doesn't hold a SessionUser instance.", $sessionKey));
			}
			Session::getSessionDataBag()->remove($sessionKey);
			
		}
		
		return $user;
		
	}