Craft\ImportService::prepAssetsFieldType PHP Method

prepAssetsFieldType() private method

private prepAssetsFieldType ( string $data, craft\FieldModel $field ) : array
$data string
$field craft\FieldModel
return array
    private function prepAssetsFieldType($data, FieldModel $field)
    {
        // Get field settings
        $settings = $field->getFieldType()->getSettings();
        // Get folder id's for connecting
        $folderIds = array();
        $folders = $settings->getAttribute('sources');
        if (is_array($folders)) {
            foreach ($folders as $folder) {
                list(, $id) = explode(':', $folder);
                $folderIds[] = $id;
            }
        }
        // Find matching element in folders
        $criteria = craft()->elements->getCriteria(ElementType::Asset);
        $criteria->folderId = $folderIds;
        $criteria->limit = $settings->limit;
        $criteria->status = null;
        $criteria->localeEnabled = null;
        // Get search strings
        $search = ArrayHelper::stringToArray($data);
        // Ability to import multiple Assets at once
        $data = array();
        // Loop through keywords
        foreach ($search as $query) {
            // Search
            $criteria->search = $query;
            // Add to data
            $data = array_merge($data, $criteria->ids());
        }
        return $data;
    }