Get all of the assets of the type $assetTypes that are used in the Entry
that matches the $url

@param string   $url
@param array    $assetTypes
@param int|null $siteId

@return Response
767048
public function actionGetUrlAssetUrls($url, array $assetTypes = ['image'], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId));
    }
906632
public function assetsTagsList($assetId, $limit = 25, $offset = 0)
    {
        return $this->auth->request(
            'GET',
            '/assets/' . $assetId . '/tags.json',
            array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
        );
    }
801666
public function contentTypeToResponseFormat($contentType, $url = null)
    {
        if (!empty($url)) {
            $url = parse_url($url, PHP_URL_PATH);
        }

        $contentTypeClean = strstr($contentType, ';') ? substr($contentType, 0,
                strpos($contentType, ';')) : $contentType;

        switch ($url) {
            case '/login-logout/login';
                $responseFormat = 'json';
                break;
            default :
                switch ($contentTypeClean) {
                    case 'text/javascript':
                        $responseFormat = 'js';
                        break;

                    default:
                        $responseFormat = Formats::contentTypeToSuffix($contentTypeClean);
                        break;
                }
                break;
        }

        return $responseFormat;
    }
665382
public function getActiveRuleByWebsiteAndType($type, $websiteId)
    {
        $collection = $this->addFieldToFilter('type', ['eq' => $type])
            ->addFieldToFilter('status', ['eq' => 1])
            ->addFieldToFilter('website_ids', ['finset' => $websiteId])
            ->setPageSize(1);

        if ($collection->getSize()) {
            return $collection->getFirstItem();
        }

        return [];
    }
275350
public function getRedirectEntityList($siteId)
    {
        try {
            $result = $this->getRedirectQuery($siteId)->getResult();
        } catch (NoResultException $e) {
            $result = [];
        }

        return $result;
    }
1357030
public static function toAsset($url, $https = null)
    {
        if (static::valid($url) || static::valid('http:' . $url)) {
            return $url;
        }

        $app = Config::get('app');
        $root = ($app['asset_url'] != '') ? $app['asset_url'] : false;

        // shoot us through a different server or third-party content delivery network.
        if ($root) {
            return rtrim($root, '/') . '/' . ltrim($url, '/');
        }

        $url = static::to($url, $https, true);

        // we do not need to come through the front controller.
        if ($app['index'] !== '') {
            $url = str_replace($app['index'] . '/', '', $url);
        }

        return $url;
    }
254332
def lookup_asset_types(self, sids):
        
        found = {}
        missing = set()

        for sid in sids:
            try:
                found[sid] = self._asset_type_cache[sid]
            except KeyError:
                missing.add(sid)

        if not missing:
            return found

        router_cols = self.asset_router.c

        for assets in group_into_chunks(missing):
            query = sa.select((router_cols.sid, router_cols.asset_type)).where(
                self.asset_router.c.sid.in_(map(int, assets))
            )
            for sid, type_ in query.execute().fetchall():
                missing.remove(sid)
                found[sid] = self._asset_type_cache[sid] = type_

            for sid in missing:
                found[sid] = self._asset_type_cache[sid] = None

        return found
554380
public static Package getAssetPackage(Long assetId) throws CachingException {
        for (Package pkg : getPackageList()) {
            if (pkg.containsAsset(assetId))
                return pkg;
        }
        return null;
    }
428761
public function getElementUrls($elementType, array $criteria = [], $siteId = null): array
    {
        $devMode = Craft::$app->getConfig()->getGeneral()->devMode;
        $cache = Craft::$app->getCache();

        // Merge in the $criteria passed in
        $criteria = array_merge([
            'siteId' => $siteId,
            'limit'  => null,
        ], $criteria);
        // Set up our cache criteria
        $elementClass = \is_object($elementType) ? \get_class($elementType) : $elementType;
        $cacheKey = $this->getCacheKey($this::ROUTEMAP_ELEMENT_URLS, [$elementClass, $criteria, $siteId]);
        $duration = $devMode ? $this::DEVMODE_ROUTEMAP_CACHE_DURATION : $this::ROUTEMAP_CACHE_DURATION;
        $dependency = new TagDependency([
            'tags' => [
                $this::ROUTEMAP_CACHE_TAG,
            ],
        ]);

        // Just return the data if it's already cached
        $urls = $cache->getOrSet($cacheKey, function () use ($elementClass, $criteria) {
            Craft::info(
                'Route Map cache miss: '.$elementClass,
                __METHOD__
            );
            $resultingUrls = [];

            // Get all of the entries in the section
            $query = $this->getElementQuery($elementClass, $criteria);
            $elements = $query->all();

            // Iterate through the elements and grab their URLs
            foreach ($elements as $element) {
                if ($element instanceof Element
                    && $element->uri !== null
                    && !\in_array($element->uri, $resultingUrls, true)
                ) {
                    $uri = $this->normalizeUri($element->uri);
                    $resultingUrls[] = $uri;
                }
            }

            return $resultingUrls;
        }, $duration, $dependency);

        return $urls;
    }
260685
public function getPageRevisionList($siteId, $pageName, $pageType)
    {
        $publishedQueryBuilder = $this->_em->createQueryBuilder();

        $publishedQueryBuilder->select('PARTIAL page.{pageId}, published, staged ')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->leftjoin('page.publishedRevision', 'published')
            ->leftjoin('page.stagedRevision', 'staged')
            ->where('page.site = :siteId')
            ->andWhere('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->setParameter('siteId', $siteId)
            ->setParameter('pageName', $pageName)
            ->setParameter('pageType', $pageType);

        $lastDraftQueryBuilder = $this->getRevisionQuery(
            $siteId,
            $pageName,
            $pageType
        );

        $result = $publishedQueryBuilder->getQuery()->getSingleResult(
            \Doctrine\ORM\Query::HYDRATE_ARRAY
        );

        try {
            $lastDraft = $lastDraftQueryBuilder->setMaxResults(1)->getSingleResult(
                \Doctrine\ORM\Query::HYDRATE_ARRAY
            );
            $lastDraft = array_values($lastDraft['revisions']);
        } catch (NoResultException $e) {
            $lastDraft = [0 => null];
        }

        $result['lastDraft'] = $lastDraft[0];

        if ($result['lastDraft']['revisionId']
            == $result['stagedRevision']['revisionId']
        ) {
            $result['lastDraft'] = null;
        }

        return $result;
    }
713362
protected function getPage(
        Site $site,
        $pageName,
        $pageType
    ) {
        if (empty($site) || !$site->getSiteId()) {
            return null;
        }

        /* Get the Page for display */
        $page = $this->findPage->__invoke(
            $site->getSiteId(),
            $pageName,
            $pageType
        );

        return $page;
    }
657822
public function addUrl( $url, $types = NULL )
	{
		if( is_string( $types ) )
			$types	= explode( ",", $types );
		$this->types['url'][$url]	= $types;
	}
1279345
@SuppressWarnings("unchecked")
  public Query linksToAssetId(String assetId) {
    checkNotEmpty(assetId, "assetId must not be empty.");

    params.put(PARAMETER_LINKS_TO_ASSET, assetId);

    return (Query) this;
  }
148733
public function getAllUrls(array $criteria = [], $siteId = null): array
    {
        $urls = [];
        $elements = Craft::$app->getElements();
        $elementTypes = $elements->getAllElementTypes();
        foreach ($elementTypes as $elementType) {
            $urls = array_merge($urls, $this->getElementUrls($elementType, $criteria, $siteId));
        }

        return $urls;
    }
1334429
private static function uploadImageAsset(AssetService $assetService, $url)
    {
        // Creates an image asset and upload it to the server.
        $imageAsset = new ImageAsset();
        // Optional: Provide a unique friendly name to identify your asset. If
        // you specify the assetName field, then both the asset name and the
        // image being uploaded should be unique, and should not match another
        // ACTIVE asset in this customer account.
        // $imageAsset->setAssetName('Image asset #' . uniqid());
        $imageAsset->setImageData(file_get_contents($url));

        // Create an asset operation.
        $operation = new AssetOperation();
        $operation->setOperand($imageAsset);
        $operation->setOperator(Operator::ADD);

        return $assetService->mutate([$operation])->getValue()[0]->getAssetId();
    }
1365151
protected function loggingFileAsset($assets, $type = self::ASSET_CSS_FILE, array $options = [], $key = null)
    {
        if (!$assets) {
            throw new InvalidArgumentException('The 1th param [$assets] is can\'t empty.');
        }

        $pos = trim($options['position']);
        $this->checkTypeAndPosition($type, $pos);

        foreach ((array)$assets as $name => $asset) {
            $asset = trim($asset);

            // check asset url
            if (\in_array($type, [self::ASSET_JS_FILE, self::ASSET_CSS_FILE], true)) {
                $asset = AssetLoad::buildUrl($asset, $this->getBaseUrl(), $this->basePath, false);
            }

            $tag = $this->buildTag($asset, $type);

            if (!is_numeric($name)) {
                // if ( $this->lockedCheck($name, $pos) ) {
                //     # code...
                // }

                $this->assets[$pos][$name] = $tag;
            } else {
                $this->assets[$pos][] = $tag;
            }
        }

        return $this;
    }
288463
protected function getSite($siteId)
    {
        try {
            /** @var Site $site */
            $site = $this->getSiteRepo()->findOneBy(['siteId' => $siteId]);
        } catch (\Exception $e) {
            $site = null;
        }

        return $site;
    }