Translate old ebre-escool study id to scool id.

@param $oldStudyId
@return mixed
@throws StudyNotFoundByNameException
166401
protected function translateStudyId($oldStudyId)
    {
        $study = ScoolStudy::where('name',Study::findOrFail($oldStudyId)->name)->first();
        if ( $study != null ) {
            return $study->id;
        }
        throw new StudyNotFoundByNameException();
    }
759876
protected function get_course_gradetopass($courseid) {
        if (!isset($this->coursesgradetopass[$courseid])) {
            // Get course grade_item.
            $courseitem = \grade_item::fetch_course_item($courseid);

            $ci = array();
            $ci['courseitemid'] = $courseitem->id;

            if ($courseitem->gradetype == GRADE_TYPE_VALUE && grade_floats_different($courseitem->gradepass, 0.0)) {
                $ci['gradetopass'] = $courseitem->gradepass;
            } else {
                $ci['gradetopass'] = null;
            }
            $this->coursesgradetopass[$courseid] = $ci;
        }

        return $this->coursesgradetopass[$courseid];
    }
2361
public function getSubscriptionByExtUid($subscriptionExtUid)
    {
        /** @var SubscriptionFbApi $response */
        $response = $this->call(new Request('subscription.get', array('subscription_ext_uid' => $subscriptionExtUid)), 'DVelopment\FastBill\Model\SubscriptionFbApi');
        $subscriptions = $response->getResponse()->getSubscriptions();

        return reset($subscriptions);
    }
1370860
private function getPasswordResetToken($base64EncodedId)
    {
        $passwordResetToken = $this->getPasswordResetTokenRepository()->getOneNonExpiredByBase64EncodedId($base64EncodedId);

        if (empty($passwordResetToken)) {
            throw $this->createNotFoundException(
                sprintf('Unable to find non-expired password reset token by ID "%s".', base64_decode($base64EncodedId))
            );
        }

        return $passwordResetToken;
    }
396310
protected function translateSubmoduleId($oldSubModuleId)
    {
        $submodule = Submodule::where('name',StudySubModule::findOrFail($oldSubModuleId)->name)->first();
        if ( $submodule != null ) {
            return $submodule->id;
        }
        throw new SubmoduleNotFoundByNameException();
    }
1373075
public function getUnique( $name, $countryId, $provinceId ) {

		$modelClass	= self::$modelClass;

		return $modelClass::findUnique( $name, $countryId, $provinceId );
	}
29035
public static function getEnumById($enumId, $ignoreNotFound = false)
    {
        if ($enumId instanceof EnumId) {
            $enumId = $enumId->toString();
        }

        if (isset(self::$enums[$enumId])) {
            return self::$enums[$enumId];
        }

        if (!$ignoreNotFound) {
            throw new \RuntimeException(sprintf('Enum with id "%s" is invalid.', $enumId));
        }

        return null;
    }
42979
protected function retrieveOr404($entityId, $loaderId)
    {
        if (!$this->container->has($loaderId)) {
            throw new NotFoundHttpException(sprintf('Unknow required loader : "%s"',
                $loaderId
            ));
        }

        if (!$entity = $this->container->get($loaderId)->retrieve($entityId)) {
            throw $this->create404($entityId, $loaderId);
        }

        return $entity;
    }
24098
protected function actionBasedOnTTL($executionId)
    {
        try {
            $deliveryExecution = $this->getServiceProxy()->getDeliveryExecution($executionId);
            $lastInteraction   = $this->getLastInteractionDateTime($deliveryExecution);

            if ($lastInteraction === null){
                $this->report->add(Report::createFailure('Execution last interaction cannot be found: '. $executionId));
                return false;
            }

            $ttl = $this->getTtlAsActive();
            if ($ttl === null) {
                $this->report->add(Report::createFailure('Execution ttl not set: '. $executionId));
                return false;
            }

            $timeUntilToLive = clone $lastInteraction;
            $timeUntilToLive = $timeUntilToLive->add(new DateInterval($ttl));

            if ((new DateTimeImmutable('now')) >= $timeUntilToLive) {
                $this->action($deliveryExecution, $executionId);
                return true;
            } else {
                $this->report->add(Report::createInfo('Execution not expired yet:'. $executionId .
                    ' Last Interaction: '.$lastInteraction->format('Y-m-d H:i:s') .
                    ' Time when will expire: '.$timeUntilToLive->format('Y-m-d H:i:s')
                ));
            }

        } catch (\common_exception_NotFound $e) {
            $this->report->add(Report::createFailure('Execution cannot be found: '. $executionId));
            $this->report->add(Report::createFailure($e->getMessage()));

        }

        return false;
    }
897651
public function transformEntityId($entityId) {
        if (0 === strpos($entityId, 'HLBLOCK_')) {
            $hlblockId = substr($entityId, 8);
            $hlhelper = new HlblockHelper();
            $hlblock = $hlhelper->getHlblock($hlblockId);
            if (empty($hlblock)) {
                $this->throwException(__METHOD__, '%s not found', $entityId);
            }
            $entityId = 'HLBLOCK_' . $hlblock['NAME'];
        }
        return $entityId;
    }
1059871
public function get_mappingid($itemname, $oldid, $ifnotfound = false) {
        $mapping = $this->get_mapping($itemname, $oldid);
        return $mapping ? $mapping->newitemid : $ifnotfound;
    }
352121
public function getTrainingInputsByVersion(string $modelId, string $versionId)
    {
        $inputResult = $this->getRequest()->request(
            'GET',
            $this->getRequestUrl(sprintf('models/%s/versions/%s/inputs', $modelId, $versionId))
        );

        return $this->getInputsFromResult($inputResult);
    }
893032
public static function getByID($btID)
    {
        $result = null;
        $btID = (int) $btID;
        if ($btID !== 0) {
            $app = Application::getFacadeApplication();
            $em = $app->make(EntityManagerInterface::class);
            $result = $em->find(BlockTypeEntity::class, $btID);
            if ($result !== null) {
                $result->loadController();
            }
        }

        return $result;
    }
1146757
public function convert($id)
    {
        if (null === $application = $this->repository->find((int) $id)) {
            throw new NotFoundHttpException(sprintf('Application %s not found.', $id));
        }

        return $application;
    }
588038
public function revertEntityId($entityId) {
        if (0 === strpos($entityId, 'HLBLOCK_')) {
            $hlblockName = substr($entityId, 8);
            $hlhelper = new HlblockHelper();
            $hlblock = $hlhelper->getHlblock($hlblockName);
            if (empty($hlblock)) {
                $this->throwException(__METHOD__, '%s not found', $entityId);
            }

            $entityId = 'HLBLOCK_' . $hlblock['ID'];
        }

        return $entityId;
    }
199946
protected function getCopiedLocationsMap($oldParentId, $newParentId)
    {
        $originalLocations = $this->locationGateway->getSubtreeContent($oldParentId);
        $copiedLocations = $this->locationGateway->getSubtreeContent($newParentId);

        $map = array();
        foreach ($originalLocations as $index => $originalLocation) {
            $map['eznode:' . $originalLocation['node_id']] = 'eznode:' . $copiedLocations[$index]['node_id'];
        }

        return $map;
    }
981428
public function modulesActiveOn($periodId)
    {
        $courses = $this->coursesActiveOn($periodId)->pluck('course_id');
        return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses)  {
            $query->whereIn('course_id',$courses);
        });
    }