@param LtiResource $ltiResource

@return array
328446
private function serializeLtiData(LtiResource $ltiResource)
    {
        $data = new \stdClass();
        $app = $ltiResource->getLtiApp();

        if ($app) {
            $workspace = $ltiResource->getResourceNode()->getWorkspace();
            $user = $this->tokenStorage->getToken()->getUser();
            $isAnon = 'anon.' === $user;
            $anonymous = $this->translator->trans('anonymous', [], 'platform');
            $isWorkspaceManager = $this->workspaceManager->isManager($workspace, $this->tokenStorage->getToken());
            $now = new \DateTime();

            $data = [
                'user_id' => !$isAnon ? $user->getUsername() : $anonymous,
                'roles' => $isWorkspaceManager ? 'Instructor' : 'Learner',
                'resource_link_id' => $workspace->getId(),
                'resource_link_title' => $app->getTitle(),
                'resource_link_description' => $app->getDescription(),
                'lis_person_name_full' => !$isAnon ? $user->getFirstname().' '.$user->getLastname() : $anonymous,
                'lis_person_name_family' => !$isAnon ? $user->getLastname() : $anonymous,
                'lis_person_name_given' => !$isAnon ? $user->getFirstname() : $anonymous,
                'lis_person_contact_email_primary' => !$isAnon ? $user->getEmail() : $anonymous,
                'lis_person_sourcedid' => !$isAnon ? $user->getUsername() : $anonymous,
                'context_id' => $workspace->getId(),
                'context_title' => $workspace->getName(),
                'context_label' => $workspace->getCode(),
                'tool_consumer_instance_guid' => $this->requestStack->getMasterRequest()->getSchemeAndHttpHost(),
                'tool_consumer_instance_description' => $this->requestStack->getMasterRequest()->getSchemeAndHttpHost(),
                'launch_presentation_locale' => $this->requestStack->getMasterRequest()->getLocale(),
            ];
            $data['lti_version'] = 'LTI-1p0';
            $data['lti_message_type'] = 'basic-lti-launch-request';

            //Basic LTI uses OAuth to sign requests
            //OAuth Core 1.0 spec: http://oauth.net/core/1.0/

            $data['oauth_callback'] = 'about:blank';
            $data['oauth_consumer_key'] = $app->getAppkey();
            $data['oauth_version'] = '1.0';
            $data['oauth_nonce'] = uniqid('', true);
            $data['oauth_timestamp'] = $now->getTimestamp();
            $data['oauth_signature_method'] = 'HMAC-SHA1';

            //In OAuth, request parameters must be sorted by name
            $launch_data_keys = array_keys($data);
            sort($launch_data_keys);

            $launch_params = [];

            foreach ($launch_data_keys as $key) {
                array_push($launch_params, $key.'='.rawurlencode($data[$key]));
            }

            $base_string = 'POST&'.rawurlencode($app->getUrl()).'&'.rawurlencode(implode('&', $launch_params));
            $secret = rawurlencode($app->getSecret()).'&';
            $signature = base64_encode(hash_hmac('sha1', $base_string, $secret, true));

            $data['oauth_signature'] = $signature;
        }

        return $data;
    }
1132820
private function _getTranslation($languageSource)
    {
        $languageId = Yii::$app->request->post('language_id', '');
        $languageTranslate = $languageSource
            ->getLanguageTranslates()
            ->andWhere(['language' => $languageId])
            ->one();

        if (!$languageTranslate) {
            $languageTranslate = new LanguageTranslate([
                'id' => $languageSource->id,
                'language' => $languageId,
            ]);
        }

        return $languageTranslate;
    }
156655
private function getReviewSource($top_area, $bottom_area)
    {
        $source_area = $top_area->find('.mb8', 1);

        return [
            'type' => $this->getSourceType($source_area),
            'id'   => $this->getSourceId($source_area),
            'title'=> $this->getSourceTitle($source_area),
            'image'=> $this->getSourceImage($bottom_area),
        ];
    }
829430
protected function visitSirelNodeJoinSource(Node\JoinSource $joinSource)
    {
        $right = $joinSource->getRight();

        return
            "FROM "
            . $this->visit($joinSource->getLeft())
            . ($right ? ' ' . join(' ', $this->visitEach($right)) : null);
    }
548134
protected function findDataSource($source)
    {
        foreach ($this->dataSources as $dataSource) {
            if ($dataSource->supports($source)) {
                return $dataSource;
            }
        }

        throw new \RuntimeException('Unknown source type');
    }
822282
private function sourceOptions(Source $source): array
    {
        $name = strip_tags($source->fullName());

        return [
            'only'   => strip_tags($source->fullName()),
            'linked' => I18N::translate('%s and the individuals that reference it.', $name),
        ];
    }
798334
public function getFilterOptions($idList, $usedOnly, &$arrCount = null)
    {
        if (!$this->isFilterOptionRetrievingPossible($idList)) {
            return [];
        }

        $strDisplayValue    = $this->getValueColumn();
        $strSortingValue    = $this->getSortingColumn();
        $strCurrentLanguage = null;

        // Change language.
        if (TL_MODE == 'BE') {
            $strCurrentLanguage     = $GLOBALS['TL_LANGUAGE'];
            $GLOBALS['TL_LANGUAGE'] = $this->getMetaModel()->getActiveLanguage();
        }

        $filter = $this->getSelectMetaModel()->getEmptyFilter();

        $this->buildFilterRulesForFilterSetting($filter);

        // Add some more filter rules.
        if ($usedOnly || ($idList && \is_array($idList))) {
            $this->buildFilterRulesForUsedOnly($filter, $idList ?: []);
        }

        $objItems = $this->getSelectMetaModel()->findByFilter($filter, $strSortingValue);

        // Reset language.
        if (TL_MODE == 'BE') {
            $GLOBALS['TL_LANGUAGE'] = $strCurrentLanguage;
        }

        return $this->convertItemsToFilterOptions(
            $objItems,
            $strDisplayValue,
            $this->getAliasColumn(),
            $arrCount,
            $idList
        );
    }
82055
protected function getDataStream($dataSource, $dataSourceOptions = null)
    {
        $dataSourceOptions = array_merge([
            'schema' => $this->schema(),
            'dialect' => isset($this->descriptor()->dialect) ? $this->descriptor()->dialect : null,
        ], (array) $dataSourceOptions);

        return new TabularDataStream($this->normalizeDataSource($dataSource, $this->basePath), $dataSourceOptions);
    }
1322145
public function getWritableSources()
    {
        $returnValue = array();
        foreach ($this->getMediaSources() as $id => $source) {
            if ($source instanceof MediaManagement) {
                $returnValue[$id] = $source;
            }
        }
        return $returnValue;
    }
525732
private function getUrisFromElements(array $elements, UriInterface $baseUri): array
    {
        $uris = [];

        foreach ($elements as $element) {
            $elementUrlValue = $element->hasAttribute(self::HREF_ATTRIBUTE_NAME)
                ? $element->getAttribute(self::HREF_ATTRIBUTE_NAME)
                : $element->getAttribute(self::SRC_ATTRIBUTE_NAME);

            $uri = AbsoluteUrlDeriver::derive($baseUri, new Uri($elementUrlValue));
            $uri = Normalizer::normalize($uri);

            $uris[] = $uri;
        }

        return $uris;
    }
1055815
public function getMetadata(array $mappingSources): array
    {
        $mappingSources = $this->normalizeMappingSources($mappingSources);

        $cacheKey = $this->getCacheKey($mappingSources);

        if ($this->cache !== null && $this->cache->has($cacheKey)) {
            return $this->cache->get($cacheKey);
        }

        $metadata = \array_map(
            function (array $mappingSource) {
                return $this->driverFactory->getDriver($mappingSource)->getMetadata();
            },
            $mappingSources
        );
        $metadata = \count($metadata) > 0 ? \array_merge(...$metadata) : [];

        if ($this->cache !== null) {
            $this->cache->set($cacheKey, $metadata);
        }

        return $metadata;
    }
1324642
protected function getFreshMigrations($source, $destination)
	{
		$me = $this;

		return array_filter($this->getPackageMigrations($source), function($file) use ($me, $destination)
		{
			return ! $me->migrationExists($file, $destination);
		});
	}
949476
public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as &$item) {
                $name = $this->getData('name');
                if (isset($item['entity_id'])) {
                    $item[$name]['edit'] = [
                        'href' => $this->_urlBuilder->getUrl(
                            $this->_editUrl,
                            ['id' => $item['entity_id']]
                        ),
                        'label' => __('Edit'),
                    ];
                }
            }
        }

        return $dataSource;
    }
66829
protected function fetchSources(Task $task)
    {
        $sources = [];

        foreach ($task->getSources() as $source) {
            // locate new resource and merge them to the existing sources
            $sources = array_merge($sources, $this->locator->locate($source));
        }

        return $sources;
    }
629981
public function getSourceStrings($buildIfNotSet = false)
    {
        $result = $this->sourceStrings;
        if ($result === null && $buildIfNotSet) {
            $result = new Translations();
            $result->setLanguage($this->app->make('community_translation/sourceLocale'));
            foreach ($this->translations as $translations) {
                foreach ($translations[1] as $key => $translation) {
                    if (!$result->offsetExists($key)) {
                        $newTranslation = $result->insert($translation->getContext(), $translation->getOriginal(), $translation->getPlural());
                        foreach ($translation->getExtractedComments() as $comment) {
                            $newTranslation->addExtractedComment($comment);
                        }
                    }
                }
            }
            $this->sourceStrings = $result;
        }

        return $result;
    }
138960
public function get_resources() {

        if (empty($this->resources)) {
            $this->resources = array();
            $this->resources[] = new \ltiservice_toolsettings\local\resources\systemsettings($this);
            $this->resources[] = new \ltiservice_toolsettings\local\resources\contextsettings($this);
            $this->resources[] = new \ltiservice_toolsettings\local\resources\linksettings($this);
        }

        return $this->resources;

    }
781777
protected function updateSources(array $originalSources, array $filteredSources, array $updatedSources)
    {
        $sources = [];
        $filteredPath = [];

        foreach ($filteredSources as $filteredSource) {
            $filteredPath[] = $filteredSource->getPath();
        }
        // keep only the not filtered files
        foreach ($originalSources as $originalSource) {

            // if an original source is not used by the current filter, we keep it in the source list
            if (!in_array($originalSource->getPath(), $filteredPath)) {
                $sources[] = $originalSource;
            }
        }
        // check updated files
        foreach ($updatedSources as $index => $source) {
            if (is_string($source)) {
                $updatedSources[$index] = new SplFileInfo($source);
            } else if (!($source instanceof SplFileInfo)) {
                throw new Exception('Invalid source file type '.gettype($source));
            }
        }
        // merge with the new sources
        $sources = array_merge($sources, $updatedSources);

        return $sources;
    }