You are here

public static function Asset::loadByUri in Mini site 8

Load asset by URI location.

Note that this function does not check if the asset file at provided URI actually exists.

Parameters

string $uri: URI of the asset to load by.

Return value

\Drupal\minisite\Asset|null Class instance or NULL if asset cannot be loaded.

Overrides AssetInterface::loadByUri

3 calls to Asset::loadByUri()
AssetContainer::add in src/AssetContainer.php
Add asset to the list.
AssetTest::testAssetInstance in tests/src/Functional/AssetTest.php
Test working with Asset class instance.
MinisiteTestBase::assertMinisiteRemoved in tests/src/Functional/MinisiteTestBase.php
Assert that a Minisite archive and assets were removed.

File

src/Asset.php, line 198

Class

Asset
Class Asset.

Namespace

Drupal\minisite

Code

public static function loadByUri($uri) {
  if (!LegacyWrapper::isValidUri($uri)) {
    return NULL;
  }
  $values = Database::getConnection()
    ->select('minisite_asset', 'ma')
    ->fields('ma')
    ->condition('source', $uri)
    ->orderBy('id', 'DESC')
    ->execute()
    ->fetchAssoc();
  if (empty($values)) {
    return NULL;
  }
  return self::fromValues($values);
}