-
Backend
-
Behaviors
-
FormController
-
ImportExportController
-
ListController
-
RelationController
- FormController
- ImportExportController
- ListController
- RelationController
- ReorderController
- UserPreferencesModel
-
-
Classes
-
Dashboard
-
NavigationManager
-
WidgetManager
- AuthManager
- BackendController
- Controller
- ControllerBehavior
- DashboardManager
- DashboardWidgetBase
- FilterScope
- FilterWidgetBase
- FormField
- FormTabs
- FormWidgetBase
- ListColumn
- LoginCustomization
- MainMenuItem
- NavigationManager
- ReportDataSourceBase
- ReportDataSourceManager
- ReportWidgetBase
- RoleManager
- RolePermission
- SettingsController
- SideMenuItem
- Skin
- StaticReportWidgetContainer
- VueComponentBase
- WidgetBase
- WidgetManager
- WildcardController
-
-
Controllers
-
Database
-
Facades
-
FilterWidgets
-
FormWidgets
-
Helpers
-
Models
-
BrandSetting
-
ExportModel
-
ImportModel
- AccessLog
- BrandSetting
- Dashboard
- EditorSetting
- ExportModel
- ImportModel
- Preference
- ReportDataCache
- User
- UserGroup
- UserPreference
- UserPreferenceModel
- UserRole
- UserThrottle
-
-
ReportWidgets
-
Skins
-
Traits
-
VueComponents
-
Widgets
-
Filter
-
Form
-
Lists
-
Table
- Filter
- Form
- Lists
- ListStructure
- ReportContainer
- RoleImpersonator
- Search
- SiteSwitcher
- Table
- Toolbar
-
- ServiceProvider
-
-
Cms
-
Classes
-
Controller
-
EditorExtension
-
Layout
-
Page
-
Partial
-
Theme
- AjaxResponse
- Asset
- CmsCompoundObject
- CmsController
- CmsDemoTrafficDataGenerator
- CmsException
- CmsObject
- CmsObjectCache
- CmsObjectCollection
- CmsReportDataSource
- CmsStatusDataSource
- CodeBase
- CodeParser
- ComponentBase
- ComponentBehavior
- ComponentHelpers
- ComponentManager
- ComponentModuleBase
- ComponentPartial
- Content
- Controller
- EditorExtension
- Layout
- LayoutCode
- Meta
- Page
- PageCode
- PageManager
- Partial
- PartialCode
- PartialStack
- PartialWatcher
- Router
- Snippet
- SnippetManager
- Theme
- ThemeManager
- ThisVariable
- TrafficLogger
-
-
Components
-
Console
-
Controllers
-
Database
-
Facades
-
FormWidgets
-
Helpers
-
Models
-
ReportWidgets
-
Traits
-
Twig
- AjaxPartialTokenParser
- ComponentNode
- ComponentTokenParser
- ContentNode
- ContentTokenParser
- DebugExtension
- DefaultNode
- DefaultTokenParser
- Extension
- FlashNode
- FlashTokenParser
- FrameworkNode
- FrameworkTokenParser
- GetAttrAdjuster
- GetAttrNode
- Loader
- MetaNode
- MetaTokenParser
- PageNode
- PageTokenParser
- PartialNode
- PartialTokenParser
- PlaceholderNode
- PlaceholderTokenParser
- PutNode
- PutTokenParser
- ScriptsNode
- ScriptsTokenParser
- StylesNode
- StylesTokenParser
-
VueComponents
-
Widgets
- ServiceProvider
-
-
Editor
-
Behaviors
-
Classes
-
Controllers
-
Traits
-
VueComponents
- ServiceProvider
-
-
Media
-
Classes
-
Controllers
-
FormWidgets
-
Helpers
-
Twig
-
Widgets
- ServiceProvider
-
-
System
-
Behaviors
-
Classes
-
PresetManager
-
SiteManager
-
UiManager
-
UpdateManager
- AppBase
- CombineAssets
- DependencyResolver
- DriverBehavior
- ErrorHandler
- MailManager
- ManifestCache
- MarkupExtensionItem
- MarkupManager
- ModelBehavior
- PagerElement
- PluginBase
- PluginManager
- PresetManager
- ProductDetail
- RateLimiter
- ResizeImageItem
- ResizeImages
- SettingsManager
- SettingsMenuItem
- SiteManager
- SystemController
- SystemReportDataSource
- UiElement
- UiManager
- UpdateManager
- VersionManager
-
-
Console
- ComposerScript
- OctoberAbout
- OctoberDown
- OctoberFresh
- OctoberMigrate
- OctoberMirror
- OctoberOptimize
- OctoberPasswd
- OctoberUp
- OctoberUpdate
- OctoberUtil
- OctoberUtilCommands
- OctoberUtilPatches
- OctoberUtilRefitLang
- PluginCheck
- PluginDisable
- PluginEnable
- PluginInstall
- PluginList
- PluginRefresh
- PluginRemove
- PluginSeed
- PluginTest
- ProjectSync
-
Controllers
-
Database
-
Facades
-
Helpers
-
Middleware
-
Models
-
ReportWidgets
-
Traits
-
Twig
-
Widgets
- ServiceProvider
-
-
Tailor
-
Behaviors
-
Classes
-
Blueprint
-
BlueprintIndexer
-
EditorExtension
-
Relations
-
SchemaBuilder
-
Scopes
- Blueprint
- BlueprintCollection
- BlueprintErrorData
- BlueprintException
- BlueprintIndexer
- BlueprintModel
- BlueprintVerifier
- ComponentVariable
- ContentFieldBase
- EditorExtension
- FieldManager
- Fieldset
- NavigationItem
- PermissionItem
- RecordIndexer
- SchemaBuilder
- SchemaPruner
-
-
Components
-
Console
-
ContentFields
-
Controllers
-
Models
-
EntryRecord
-
GlobalRecord
-
RecordImport
- ContentSchema
- EntryRecord
- GlobalRecord
- NestedFormItem
- PreviewToken
- RecordExport
- RecordImport
- RepeaterItem
-
-
Traits
-
VueComponents
- ServiceProvider
-
-
Events
-
backend
-
ajax
-
brand
-
files
-
filter
-
form
-
list
-
menu
-
page
-
roles
-
site
-
user
-
-
cms
-
ajax
-
block
-
combiner
-
component
-
internalTrafficStatistics
-
object
-
page
-
pageLookup
-
resizer
-
router
-
sitePicker
-
template
-
theme
- extendTwig
-
-
deferredBinding
-
editor
-
extension
-
-
exception
-
halcyon
-
datasource
-
-
mailer
-
media
-
model
-
auth
-
filter
-
form
-
relation
-
/docs/api/model/relation/add
-
/docs/api/model/relation/associate
- attach
-
/docs/api/model/relation/beforeadd
-
/docs/api/model/relation/beforeassociate
- beforeAttach
- beforeDetach
-
/docs/api/model/relation/beforedissociate
-
/docs/api/model/relation/beforeremove
- detach
-
/docs/api/model/relation/dissociate
-
/docs/api/model/relation/remove
-
-
/docs/api/model/afterboot
-
/docs/api/model/aftercreate
-
/docs/api/model/afterdelete
-
/docs/api/model/afterfetch
-
/docs/api/model/afterinit
- afterRelation
- afterRestore
-
/docs/api/model/aftersave
- afterTrash
-
/docs/api/model/afterupdate
- afterValidate
-
/docs/api/model/beforecreate
-
/docs/api/model/beforedelete
-
/docs/api/model/beforefetch
- beforeGetAttribute
- beforeRelation
- beforeReplicate
- beforeRestore
-
/docs/api/model/beforesave
- beforeSetAttribute
-
/docs/api/model/beforeupdate
- beforeValidate
- extendBlueprint
- getAttribute
- newInstance
- saveInternal
- setAttribute
-
-
pages
-
snippet
-
-
site
-
system
-
assets
- beforeAddAsset
-
/docs/api/system/assets/beforebundleasset
-
console
-
mirror
-
-
mail
-
reportwidgets
-
resizer
-
settings
-
site
-
updater
- extendConfigFile
- extendTwig
-
-
tailor
-
user
-
-
Library
-
Argon
-
Assetic
-
Asset
-
Cache
-
Exception
-
Factory
-
Filter
-
Traits
-
Util
- README
- AsseticServiceProvider
- AssetManager
- AssetWriter
- Combiner
- FilterManager
-
-
Auth
-
Combine
-
Composer
-
Config
-
Database
-
Attach
-
Concerns
-
Connections
-
Connectors
-
Factories
-
Models
-
Relations
-
Schema
-
Scopes
-
Traits
-
Updates
- README
- Builder
- Collection
- DatabaseServiceProvider
- Dongle
- ExpandoModel
- MigrationServiceProvider
- Model
- ModelBehavior
- ModelException
- MorphPivot
- NestedTreeScope
- Pivot
- QueryBuilder
- Replicator
- SortableScope
- TreeCollection
- Updater
-
-
Element
-
Filter
-
Form
-
Lists
-
Navigation
- ElementBase
- ElementHolder
-
-
Events
-
Exception
-
Extension
-
Filesystem
-
Flash
-
Foundation
-
Bootstrap
-
Console
-
Exception
-
Http
-
Middleware
- Kernel
-
-
Providers
- Application
-
-
Halcyon
-
Concerns
-
Datasource
-
Exception
-
Processors
-
Traits
- README
- Builder
- Collection
- HalcyonServiceProvider
- Model
-
-
Html
-
Mail
-
Network
-
Parse
-
Resize
-
Router
-
Scaffold
-
Support
-
Debug
-
Facades
-
Traits
- README
- Arr
- ClassLoader
- Collection
- Facade
- ModuleServiceProvider
- SafeCollection
- ServiceProvider
- Singleton
- Str
-
-
Translation
-
Validation
-
- Documentation
- API
- Media
- Classes
- MediaLibrary
Media\Classes\MediaLibrary
Overview
MediaLibrary provides abstraction level for the Media Library operations. Implements the library caching features and security checks.
Protected Properties
protected string $cacheKey
protected string $storageUrl
storageUrl relative or absolute URL of the Library root folder.
protected mixed $storageDisk
storageDisk is a reference to the Media Library disk.
protected array $ignoreNames
ignoreNames contains a list of files and directories to ignore. The list can be customized with media.ignore_files configuration option.
protected array $ignorePatterns
ignorePatterns contains a list of regex patterns to ignore in files and directories. The list can be customized with media.ignore_patterns configuration option.
Public Methods
public __construct()
public __construct(): void
__construct this class
public copyFolder()
public copyFolder(string $originalPath, string $newPath): bool
copyFolder copies an original path to a newly located path.
public deleteFiles()
public deleteFiles(array $paths): void
deleteFiles from the Library.
public deleteFolder()
public deleteFolder(string $path): void
deleteFolder from the Library.
public exists()
public exists(string $path): bool
exists determines if a file with the specified path exists in the library.
public findFile()
public findFile($path): Media\Classes\MediaLibraryItem|null
findFile looks up a file and returns its MediaLibraryItem object
public findFiles()
public findFiles( string $searchTerm, mixed $sortBy = 'title', string $filter = null ): array
findFiles in the Library.
public findFolder()
public findFolder($path): Media\Classes\MediaLibraryItem|null
findFolder looks up a folder and returns its MediaLibraryItem object
public folderExists()
public folderExists(string $path): bool
folderExists determines if a folder with the specified path exists in the library.
public get()
public get(string $path): string
get returns a file contents.
public getCacheKey()
public getCacheKey(): string
getCacheKey as the cache key for this instance
public getPathUrl()
public getPathUrl(string $path): string
getPathUrl returns a public file URL.
public has()
public has(string $path): bool
has checks for existence.
public static instance()
public static instance(): static
instance creates a new instance of this singleton
public listAllDirectories()
public listAllDirectories(array $exclude = []): array
listAllDirectories returns a list of all directories in the Library, optionally excluding some of them.
public listFolderContents()
public listFolderContents( string $folder = '/', mixed $sortBy = 'title', string $filter = null, bool $ignoreFolders = false ): array
listFolderContents returns a list of folders and files in a Library folder.
public makeFolder()
public makeFolder(string $path): bool
makeFolder creates a folder.
public moveFile()
public moveFile( string $oldPath, string $newPath, $isRename = false ): bool
moveFile to another location.
public moveFolder()
public moveFolder(string $originalPath, string $newPath): bool
moveFolder moves an original path to a newly located path.
public put()
public put(string $path, string $contents): bool
put a file to the library.
public putFile()
public putFile(string $path, string $file): bool
put a file to the library.
public resetCache()
public resetCache(): void
resetCache for the Library cache.
The cache stores the library table of contents locally in order to optimize the performance when working with remote storages. The default cache TTL is 10 minutes. The cache is deleted automatically when an item is added, changed or deleted. This method allows to reset the cache forcibly.
public setCacheKey()
public setCacheKey($cacheKey): void
setCacheKey as the cache key for this instance
public static url()
public static url(string $file): string
url is a helper that makes a URL for a media file. Ideally the file should be passed as a string but it will try to deal with anything.
public static validatePath()
public static validatePath( string $path, bool $normalizeOnly = false ): string
validatePath checks if file path doesn't contain any substrings that would pose a security threat. Returns a normalized path. Throws an exception if the path is not valid. An option is provided, if only normalization is needed without validation.
Protected Methods
protected filterItemList()
protected filterItemList(array &$itemList, string $filter): void
filterItemList by file type.
protected generateRandomTmpFolderName()
protected generateRandomTmpFolderName($location): void
protected getFolderItemCount()
protected getFolderItemCount(string $path): integer
getFolderItemCount returns a number of items on a folder.
protected getStorageDisk()
protected getStorageDisk(): mixed
getStorageDisk initializes and returns the Media Library disk. This method should always be used instead of trying to access the $storageDisk property directly as initializing the disc requires communicating with the remote storage.
protected initLibraryItem()
protected initLibraryItem(string $path, string $itemType): mixed
initLibraryItem from a path relative to the storage disk root and item type constant. Returns null if the item is not visible.
protected isLocalStorage()
protected isLocalStorage(): void
isLocalStorage returns true if the storage engine is local
protected isVisible()
protected isVisible(string $path): bool
isVisible determines if the path should be visible and not ignored.
protected pathMatchesSearch()
protected pathMatchesSearch(string $path, array $words): bool
pathMatchesSearch determines if file path contains all words form the search term.
protected scanFolderContents()
protected scanFolderContents(string $fullFolderPath): array
scanFolderContents fetches the contents of a folder from the Library. The full folder path relative the the storage disk root. Returns an array containing two elements
- 'files' and 'folders', each is an array of MediaLibraryItem objects.
protected sortItemList()
protected sortItemList(array &$itemList, mixed $sortSettings): void
sortItemList sorts the item list by title, size or last modified date.