Populate stopPoint from navitia

@param  string $externalCoverageId External coverage id

@return StopPoint The populated StopPoint
541199
private function initStopPoint($externalCoverageId)
    {
        $navitiaStopPoint = $this->navitia->getStopPoint(
            $externalCoverageId,
            $this->stopPoint->getExternalId(),
            array('depth' => 1, 'show_codes' => 'true')
        );

        $this->stopPoint->setTitle($navitiaStopPoint->stop_points[0]->name);
        $this->stopPoint->setCodes($navitiaStopPoint->stop_points[0]->codes);

        $administrativeRegion = isset($navitiaStopPoint->stop_points[0]->administrative_regions)
            ? $navitiaStopPoint->stop_points[0]->administrative_regions[0]->name
            : null;
        $this->stopPoint->setCity($administrativeRegion);
    }
246904
public function get($id_or_external_id) {
    $key = is_int($id_or_external_id) ? 'id' : 'external_id';
    foreach ($this as $item) {
      if ($item->{$key} === $id_or_external_id) {
        return $item;
      }
    }
    return null;
  }
617727
public function getLineTitle($coverageId, $networkId, $lineId)
    {
        $response = $this->navitia_sam->getLine($coverageId, $networkId, $lineId);

        return ($response->lines[0]->name);
    }
1232305
public function getExternalIds($id)
    {
        $data   = $this->getApi()->getExternalIds($id);
        $person = $this->getFactory()->create(['external_ids' => $data]);

        return $person->getExternalIds();
    }
1149186
public static function get_participant_parameters() {
        return new external_function_parameters(
            array(
                'assignid' => new external_value(PARAM_INT, 'assign instance id'),
                'userid' => new external_value(PARAM_INT, 'user id'),
                'embeduser' => new external_value(PARAM_BOOL, 'user id', VALUE_DEFAULT, false),
            )
        );
    }
100783
private function getPayload($perimeter, $season, $lineConfig, $externalRouteId, $stopPoint)
    {
        $payload = array();
        $payload['pdfHash'] = isset($stopPoint->pdfHash) ? $stopPoint->pdfHash : '';
        $payload['layoutParams'] = array(
            'orientation' => $lineConfig->getLayoutConfig()->getLayout()->getOrientationAsString(),
            'pageSize' => $lineConfig->getLayoutConfig()->getLayout()->getPageSize(),
        );
        $payload['cssVersion'] = $lineConfig->getLayoutConfig()->getLayout()->getCssVersion();
        $payload['url'] = $this->generatePayloadUrl();
        $payload['url'] .= $this->router->generate(
            'canal_tp_mtt_timetable_view',
            array(
                'externalNetworkId'     => $perimeter->getExternalNetworkId(),
                'externalLineId'        => $lineConfig->getExternalLineId(),
                'externalRouteId'       => $externalRouteId,
                'seasonId'              => $season->getId(),
                'externalStopPointId'   => $stopPoint->id,
                'customerId'            => $this->co->get('security.context')->getToken()->getUser()->getCustomer()->getId(),
                'timetableOnly'         => true
            )
        );
        $payload['timetableParams'] = array(
            'seasonId'              => $season->getId(),
            'externalNetworkId'     => $perimeter->getExternalNetworkId(),
            'externalRouteId'       => $externalRouteId,
            'externalLineId'        => $lineConfig->getExternalLineId(),
            'externalStopPointId'   => $stopPoint->id,
        );

        return $payload;
    }
252918
public function export($externalCoverageId, array $calendars)
    {
        if (!is_dir($folder = $this->archiveFolder.'/'.$externalCoverageId)) {
            mkdir($folder, 0777, true);
        }

        $location = $folder.'/'.static::EXPORT_FILENAME;

        $calendarArchiveGenerator = new CalendarArchiveGenerator($location);
        $calendarArchiveGenerator->addCsv(new CalendarCsv\GridCalendarsCsv($calendars));
        $calendarArchiveGenerator->addCsv(new CalendarCsv\GridPeriodsCsv($calendars));
        $calendarArchiveGenerator->addCsv(new CalendarCsv\GridNetworksAndLinesCsv($calendars));
        $calendarArchiveGenerator->getArchive()->close();

        $response = $this->sendCalendar($externalCoverageId, $location);

        unlink($location);

        return $response;
    }
1235183
public function getNetworkModes($coverageId, $networkId, $commercial = true)
    {
        $query = array(
            'api' => 'coverage',
            'parameters' => array(
                'region' => $coverageId,
                'action' => $commercial ? 'commercial_modes' : 'physical_modes',
                'path_filter' => 'networks/'.$networkId,
            ),
        );

        return $this->navitia_component->call($query);
    }
468877
public function getStopPoint($coverageId, $stopPointId, $params)
    {
        $pathFilter = 'stop_points/'.$stopPointId;
        $parameters = http_build_query($params);

        $query = array(
            'api' => 'coverage',
            'parameters' => array(
                'region' => $coverageId,
                'path_filter' => $pathFilter,
                'parameters' => $parameters,
            ),
        );

        return $this->navitia_component->call($query);
    }
497746
public function getEndpoint($endpoint, $withHost = false, $forceReload = false)
    {
        $this->loadApiDefinition($forceReload);
        $url = "";
        if ($withHost) {
            $url = empty($this->options['host']) ? $this->definition->getHost() : $this->options['host'];
        }

        // If the base path is not already included, we need to add it.
        $url .= (empty($this->options['includeBasePath']) ? $this->definition->getBasePath() : '') . $endpoint;

        return $url;
    }
1131505
public String createPolicyRuleForExternalId(ComponentService componentService, ExternalId externalId, String policyName) throws IntegrationException {
        Optional<ComponentVersionView> componentVersionView = componentService.getComponentVersion(externalId);
        if (!componentVersionView.isPresent()) {
            throw new BlackDuckIntegrationException(String.format("The external id (%s) provided could not be found, so no policy can be created for it.", externalId.createExternalId()));
        }

        PolicyRuleExpressionSetBuilder builder = new PolicyRuleExpressionSetBuilder();
        builder.addComponentVersionCondition(PolicyRuleConditionOperatorType.EQ, componentVersionView.get());
        PolicyRuleExpressionSetView expressionSet = builder.createPolicyRuleExpressionSetView();

        PolicyRuleView policyRuleView = new PolicyRuleView();
        policyRuleView.setName(policyName);
        policyRuleView.setEnabled(true);
        policyRuleView.setOverridable(true);
        policyRuleView.setExpression(expressionSet);

        return createPolicyRule(policyRuleView);
    }
552565
private function assertExternalReferenceHasKnownContainer(ExternalReference $externalReference): void
    {
        if (!isset($this->containerAccessors[$externalReference->containerIdentifier()])) {
            throw new \DomainException(sprintf(
                'External container with identifier "%s" does not exist.',
                $externalReference->containerIdentifier()
            ));
        }
    }
379972
public static function get_policy_version_returns() {
        return new external_single_structure([
            'result' => new external_single_structure([
                            'policy' => new external_single_structure([
                                    'name' => new external_value(PARAM_RAW, 'The policy version name', VALUE_OPTIONAL),
                                    'versionid' => new external_value(PARAM_INT, 'The policy version id', VALUE_OPTIONAL),
                                    'content' => new external_value(PARAM_RAW, 'The policy version content', VALUE_OPTIONAL)
                                    ], 'Policy information', VALUE_OPTIONAL)
                            ]),
            'warnings' => new external_warnings()
        ]);
    }
692916
public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
    {
        return self::_retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
    }
134999
public function mapExternalAssociation(
        ExternalAssociation $externalAssociation
    ) {
        // @See https://github.com/doctrine/common/issues/336
        //if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) {
        if (!(method_exists($externalAssociation->getReferenceManager(), 'getReference'))) {
            $msg = '$referenceManager needs to implements a `getReference` method';
            throw new \InvalidArgumentException($msg);
        }

        $this->eventListener->addExternalAssoctiation($externalAssociation);


        $externalAssociation->getObjectManager()
            ->getEventManager()
            ->addEventListener(['postLoad'], $this->eventListener);
        // todo switch to doctrine event when https://github.com/doctrine/common/pull/335 is merged
    }
831510
public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
    {
        return self::_updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
    }
367285
public function getStopPoint($coverageId, $stopPointId)
    {
        $pathFilter = 'stop_points/'.$stopPointId;

        $query = array(
            'api' => 'coverage',
            'parameters' => array(
                'region' => $coverageId,
                'path_filter' => $pathFilter,
                'parameters' => '?depth=0',
            ),
        );

        return $this->navitia_component->call($query);
    }