Skip to content

AssetIndexer ​

Type
Class
Namespace
craft\services
Inherits
craft\services\AssetIndexer » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.0.0

Asset Indexer service.

An instance of the service is available via Craft::$app->assetIndexer.

View source

Public Properties ​

PropertyDescription
behaviorsyii\base\Behavior – List of behaviors attached to this component.
indexingSessionIdstring

indexingSessionId ​

Type
string
Default value
null
Access
Read-only

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
deleteStaleIndexingData()Clean up stale asset indexing data. Stale indexing data is all session data for sessions that have all the recordIds set.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
extractFolderItemsFromIndexList()Remove folder items from an index list and return their paths.
extractSkippedItemsFromIndexList()Remove skipped items from an index list and return their paths.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getIndexListOnVolume()Returns a sorted list of files on a volume.
getIndexingSessionId()Returns a unique indexing session ID.
getMissingFiles()Return a list of missing files for an indexing session.
getNextIndexEntry()Returns the next item to index in an indexing session.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
indexFile()Index a single file by its volume and path.
indexFileByEntry()Indexes a file by its index entry.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
prepareIndexList()Gets the index list for a volume.
processIndexForVolume()Process index for a volume.
storeIndexList()Store the index list in the index data table.
trigger()Triggers an event.
updateIndexEntry()Update indexing-process related data on an index entry.

deleteStaleIndexingData() ​

Clean up stale asset indexing data. Stale indexing data is all session data for sessions that have all the recordIds set.

View source

Throws ​

extractFolderItemsFromIndexList() ​

Remove folder items from an index list and return their paths.

View source

Arguments ​

  • $indexList (array) – Index list generated by AssetIndexer::getIndexListOnVolume()

Returns ​

array

extractSkippedItemsFromIndexList() ​

Remove skipped items from an index list and return their paths.

View source

Arguments ​

  • $indexList (array) – Index list generated by AssetIndexer::getIndexListOnVolume()

Returns ​

array

getIndexListOnVolume() ​

Returns a sorted list of files on a volume.

View source

Arguments ​

Returns ​

array

getIndexingSessionId() ​

Returns a unique indexing session ID.

View source

Returns ​

string

getMissingFiles() ​

Return a list of missing files for an indexing session.

View source

Arguments ​

  • $sessionId (string) – Session ID.
  • $path (string) – Path to a folder

Returns ​

array

getNextIndexEntry() ​

Returns the next item to index in an indexing session.

View source

Arguments ​

  • $sessionId (string) – The indexing session ID.
  • $volumeId (integer) – The volume ID.

Returns ​

craft\models\AssetIndexData, null

indexFile() ​

Index a single file by its volume and path.

View source

Arguments ​

  • $volume (craft\base\VolumeInterface)
  • $path (string)
  • $sessionId (string) – The indexing session ID (optional).
  • $cacheImages (boolean) – Whether remotely-stored images should be downloaded and stored locally, to speed up transform generation.
  • $createIfMissing (boolean) – Whether the asset record should be created if it doesn't exist yet

Returns ​

boolean, craft\elements\Asset

Throws ​

indexFileByEntry() ​

Indexes a file by its index entry.

View source

Arguments ​

  • $indexEntry (craft\models\AssetIndexData)
  • $cacheImages (boolean) – Whether remotely-stored images should be downloaded and stored locally, to speed up transform generation.
  • $createIfMissing (boolean) – Whether the asset record should be created if it doesn't exist yet

Returns ​

boolean, craft\elements\Asset

Throws ​

prepareIndexList() ​

Gets the index list for a volume.

View source

Arguments ​

  • $sessionId (string) – The indexing session ID.
  • $volumeId (integer) – The volume ID.
  • $directory (string) – Optional path to get index list on a subfolder.

Returns ​

array

processIndexForVolume() ​

Process index for a volume.

View source

Arguments ​

  • $sessionId (string) – The indexing session ID.
  • $volumeId (integer) – The volume ID.
  • $cacheImages (boolean) – Whether remotely-stored images should be downloaded and stored locally, to speed up transform generation.

Returns ​

mixed

storeIndexList() ​

Store the index list in the index data table.

View source

Arguments ​

  • $indexList (array) – Index list generated by AssetIndexer::getIndexListOnVolume()
  • $sessionId (string) – The indexing session ID.
  • $volumeId (integer) – The volume ID.

updateIndexEntry() ​

Update indexing-process related data on an index entry.

View source

Arguments ​

  • $entryId (integer) – Index entry ID.
  • $data (array) – Key=>value array of data to update.