AssetIndexer
- Type
- Class
- Namespace
- craft\services
- Inherits
- craft\services\AssetIndexer » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
- Implements
- yii\base\Configurable (opens new window)
- Since
- 3.0.0
Asset Indexer service.
An instance of the service is available via Craft::$app->assetIndexer
.
View source (opens new window)
# Public Properties
Property | Description |
---|---|
behaviors (opens new window) | yii\base\Behavior (opens new window) – List of behaviors attached to this component. |
indexingSessionId | string (opens new window) |
# indexingSessionId
- Type
- string (opens new window)
- Default value
null
- Access
- Read-only
View source (opens new window)
# Public Methods
Method | Description |
---|---|
__call() (opens new window) | Calls the named method which is not a class method. |
__clone() (opens new window) | This method is called after the object is created by cloning an existing one. |
__construct() (opens new window) | Constructor. |
__get() (opens new window) | Returns the value of a component property. |
__isset() (opens new window) | Checks if a property is set, i.e. defined and not null. |
__set() (opens new window) | Sets the value of a component property. |
__unset() (opens new window) | Sets a component property to be null. |
attachBehavior() (opens new window) | Attaches a behavior to this component. |
attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
behaviors() (opens new window) | Returns a list of behaviors that this component should behave as. |
canGetProperty() (opens new window) | Returns a value indicating whether a property can be read. |
canSetProperty() (opens new window) | Returns a value indicating whether a property can be set. |
className() (opens new window) | 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() (opens new window) | Detaches a behavior from the component. |
detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
ensureBehaviors() (opens new window) | Makes sure that the behaviors declared in behaviors() (opens new window) 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() (opens new window) | Returns the named behavior object. |
getBehaviors() (opens new window) | 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() (opens new window) | Returns a value indicating whether there is any handler attached to the named event. |
hasMethod() (opens new window) | Returns a value indicating whether a method is defined. |
hasProperty() (opens new window) | 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() (opens new window) | Initializes the object. |
off() (opens new window) | Detaches an existing event handler from this component. |
on() (opens new window) | 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() (opens new window) | 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 (opens new window)
Throws
# extractFolderItemsFromIndexList()
Remove folder items from an index list and return their paths.
View source (opens new window)
Arguments
$indexList
(array (opens new window)) – Index list generated byAssetIndexer::getIndexListOnVolume()
Returns
# extractSkippedItemsFromIndexList()
Remove skipped items from an index list and return their paths.
View source (opens new window)
Arguments
$indexList
(array (opens new window)) – Index list generated byAssetIndexer::getIndexListOnVolume()
Returns
# getIndexListOnVolume()
Returns a sorted list of files on a volume.
View source (opens new window)
Arguments
$volume
(craft\base\VolumeInterface) – The Volume to perform indexing on.$directory
(string (opens new window)) – Optional path to get index list on a subfolder.
Returns
# getIndexingSessionId()
Returns a unique indexing session ID.
View source (opens new window)
Returns
# getMissingFiles()
Return a list of missing files for an indexing session.
View source (opens new window)
Arguments
$sessionId
(string (opens new window)) – Session ID.
Returns
# getNextIndexEntry()
Returns the next item to index in an indexing session.
View source (opens new window)
Arguments
$sessionId
(string (opens new window)) – The indexing session ID.$volumeId
(integer (opens new window)) – The volume ID.
Returns
craft\models\AssetIndexData, null (opens new window)
# indexFile()
Index a single file by its volume and path.
View source (opens new window)
Arguments
$volume
(craft\base\VolumeInterface)$path
(string (opens new window))$sessionId
(string (opens new window)) – The indexing session ID (optional).$cacheImages
(boolean (opens new window)) – Whether remotely-stored images should be downloaded and stored locally, to speed up transform generation.$createIfMissing
(boolean (opens new window)) – Whether the asset record should be created if it doesn't exist yet
Returns
boolean (opens new window), craft\elements\Asset
Throws
- craft\errors\MissingAssetException
if the asset record doesn't exist and $createIfMissing is false - craft\errors\VolumeObjectNotFoundException
If the file to be indexed cannot be found.
# indexFileByEntry()
Indexes a file by its index entry.
View source (opens new window)
Arguments
$indexEntry
(craft\models\AssetIndexData)$cacheImages
(boolean (opens new window)) – Whether remotely-stored images should be downloaded and stored locally, to speed up transform generation.$createIfMissing
(boolean (opens new window)) – Whether the asset record should be created if it doesn't exist yet
Returns
boolean (opens new window), craft\elements\Asset
Throws
- craft\errors\MissingAssetException
if the asset record doesn't exist and $createIfMissing is false - craft\errors\VolumeObjectNotFoundException
If the file to be indexed cannot be found. - craft\errors\AssetDisallowedExtensionException
If the file being indexed has a disallowed extension
# prepareIndexList()
Gets the index list for a volume.
View source (opens new window)
Arguments
$sessionId
(string (opens new window)) – The indexing session ID.$volumeId
(integer (opens new window)) – The volume ID.$directory
(string (opens new window)) – Optional path to get index list on a subfolder.
Returns
# processIndexForVolume()
Process index for a volume.
View source (opens new window)
Arguments
$sessionId
(string (opens new window)) – The indexing session ID.$volumeId
(integer (opens new window)) – The volume ID.$cacheImages
(boolean (opens new window)) – 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 (opens new window)
Arguments
$indexList
(array (opens new window)) – Index list generated byAssetIndexer::getIndexListOnVolume()
$sessionId
(string (opens new window)) – The indexing session ID.$volumeId
(integer (opens new window)) – The volume ID.
# updateIndexEntry()
Update indexing-process related data on an index entry.
View source (opens new window)
Arguments
$entryId
(integer (opens new window)) – Index entry ID.$data
(array (opens new window)) – Key=>value array of data to update.
← Api AssetTransforms →