Skip to content

Commit

Permalink
Asset Indexing.
Browse files Browse the repository at this point in the history
  • Loading branch information
andris-sevcenko committed Mar 21, 2017
1 parent f22f0a6 commit 7ecb943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,17 @@ public function rules()
return $rules;
}

/**
* @inheritdoc
*/
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios[self::SCENARIO_INDEX] = [];

return $scenarios;
}

/**
* @inheritdoc
*/
Expand Down
5 changes: 1 addition & 4 deletions src/services/AssetIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,7 @@ private function _indexFileByIndexData(AssetIndexData $indexEntryModel, bool $ca

$asset->dateModified = $timeModified;

// Make sure there are no double spaces, if the filename had a space followed by a
// capital letter because of Yii's "word" logic.
$asset->title = str_replace(' ', ' ',StringHelper::toTitleCase(pathinfo($filename, PATHINFO_FILENAME)));
Craft::$app->getAssets()->saveAsset($asset, false);
Craft::$app->getElements()->saveElement($asset);

return $asset;
}
Expand Down

0 comments on commit 7ecb943

Please sign in to comment.