Version: current

# Class Extension

Add extension that can be added to an object with `Object::add_extension()`. For `DataObject` extensions, use `DataObjectDecorator`. Each extension instance has an "owner" instance, accessible through `Extension::getOwner()`. Every object instance gets its own set of extension instances, meaning you can set parameters specific to the "owner instance" in new Extension instances.

### Direct known subclasses

`AddressBookProfilePageExtension`, `AssetAdminQuotaExtension`, `CustomMenu`, `DataObjectDecorator`, `DataObjectFileTrackingDecorator`, `DataObjectLoggerExtension`, `DisableJSValidation`, `ExtendPageAnnouncement`, `ExtendPageCart`, `ExtendPageMember`, `ExtendPagePoll`, `ExtendPageSpecialCatalog`, `AttachedFilesExtension`, `ExtendProfilePageOrder`, `FavoriteExtention`, `GDMergeAlpha`, `HtmlEditorQuotaExtension`, `LeftAndMainDecorator`, `LeftAndMainSubsites`, `MemberLoggerExtension`, `MobileExtension`, `NearestEventExtention`, `PageHideFieldsExtension`, `BookingWidget`, `PageInformerRates`, `PageInformerWeather`, `PaymentMethodAutoHide`, `PhotoAlbumExtentions`, `ProductSearchFormExtension`, `PublicationSiteTree`, `ShowUserFromExtension`, `ShowViewedProductExtention`, `SSNController`, `SteppedCheckout`, `CalendarWidgetExtention`, `SubscribeFormAllPagesExtension`, `ViewedProductExtention`, `WatermarkImage`, `WebylonSiteSearchExtension`, `CheckoutStep`, `ContactFormAddressExtension`, `ContentControllerSearchExtension`, `ControllerRedirectExtension`, `ControllerSubsites`

### Indirect known subclasses

`AnnouncementDecorator`, `AssetManagerFolder`, `CatalogMemberDecorator`, `StaticPublisher`, `SteppedCheckout_PageMessages`, `Translatable`, `Versioned`, `VideoSiteConfig`, `WatermarkSiteConfig`, `WebylonSiteConfig`, `WidgetSortCMSActionDecorator`, `YaMoneyPaymentDecorator`, `YMLSiteConfig`, `CatalogOldFieldsDecorator`, `CatalogProductLinkedDecorator`, `CatalogRubricsHomepageWidget_CatalogDecorator`, `CheckoutStep_ContactDetails`, `CheckoutStep_Membership`, `CheckoutStep_PaymentMethod`, `CheckoutStep_ShippingMethod`, `CheckoutStep_Summary`, `ClientEmailOrderNotification`, `AssociatedFolderDecorator`, `ClientEmailOrderNotification_SiteConfig`, `ClientVKOrderNotification`, `ClientVKOrderNotification_SiteConfig`, `CommentsSiteConfig`, `CustomMenuDecorator`, `DataObjectSubsites`, `DefaultCMSActionDecorator`, `DocumentSiteConfig`, `ErrorPageSubsite`, `ExtendGroupDiscount`, `AttachedFiles`, `ExtendMemberCart`, `ExtendProductSpecialCatalog`, `FavoriteProductMemberExtention`, `FavoriteProducts`, `FileDataObjectTrackingDecorator`, `FileImportDecorator`, `FileOversizeDecorator`, `FileSubsites`, `FilesystemPublisher`, `FindCyrillicSiteConfig`, `AuthSiteConfig`, `FulltextSearchable`, `GoogleSitemapDecorator`, `GroupSubsites`, `Hierarchy`, `HouseCatalogProductDecorator`, `ImageAutoResize`, `ImportCatalogSiteConfig`, `ImportSiteConfig`, `LeftAndMainQuota`, `ManagerEmailOrderNotification`, `BaseObjectDecorator`, `ManagerEmailOrderNotification_SiteConfig`, `MemberActivation`, `MemberSubsites`, `MobileContentDecorator`, `MonumentsSiteConfig`, `NewsletterRole`, `NewsSiteConfig`, `OrderDecorator`, `OrderHandlersDecorator`, `OrderItemDecorator`, `BookingSiteConfig`, `OrderItemVariationDecorator`, `Orders1CExchange_OrdersDecorator`, `Orders1CExchange_SiteConfig`, `PageIcon`, `PageWidgets`, `PaymentMethodShippingDecorator`, `PaymentOrderExtension`, `PaymentSiteConfig`, `PhotoAlbumProductLinkDecorator`, `PhotoAlbumWidgetLinkDecorator`, `CartSiteConfig`, `Product3DDecorator`, `ProductCatalogCatalogLinkedDecorator`, `ProductCatalogSiteConfig`, `ProductOldFieldsDecorator`, `ProductProductLinkedDecorator`, `ProductShippingDecorator`, `RatingExtension`, `RealtySiteConfigDecorator`, `RsyncMultiHostPublisher`, `SberbankPaymentDecorator`, `CatalogCatalogLinkedDecorator`, `SeoOpenGraphPageDecorator`, `SeoOpenGraphSiteConfig`, `ShippingMemberDecorator`, `ShippingMethodPaymentDecorator`, `ShippingOrderDecorator`, `ShippingSiteConfig`, `SimpleOrderCatalogDecorator`, `SimpleOrderProductDecorator`, `SiteConfigDecorator`, `SiteConfigSubsites`, `CatalogCMSActionDecorator`, `SiteConfigWidgets`, `SiteTreeDecorator`, `SiteTreeImportDecorator`, `SiteTreeSubsites`, `SMSCOrderNotification`, `SMSCOrderNotification_SiteConfig`, `SMSOrderNotification`, `SMSOrderNotification_SiteConfig`, `SortableDataObject`, `SortCMSActionDecorator`

Abstract
Package: sapphire\core
Located at sapphire/core/Extension.php

## Methods summary

`public` | # `__construct( )`
`public` | # `setOwner( `Object` $owner, string $ownerBaseClass = null )` Set the owner of this decorator. Set the owner of this decorator. #### Parameters $owner Object $owner The owner object, $ownerBaseClass string $ownerBaseClass The base class that the extension is applied to; this may be the class of owner, or it may be a parent. For example, if Versioned was applied to SiteTree, and then a Page object was instantiated, $owner would be a Page object, but $ownerBaseClass would be 'SiteTree'.
`public` | # `clearOwner( )`
`public `Object`` | # `getOwner( )` Returns the owner of this decorator Returns the owner of this decorator #### Returns ``Object`` Object
`public static string` | # `get_classname_without_arguments( string $extensionStr )` Helper method to strip eval'ed arguments from a string thats passed to `Object::$extensions` or `Object::add_extension()`. Helper method to strip eval'ed arguments from a string thats passed to `Object::$extensions` or `Object::add_extension()`. #### Parameters $extensionStr string $extensionStr E.g. "Versioned('Stage','Live')" #### Returns `string` Extension classname, e.g. "Versioned"

### Magic methods summary

## Properties summary

`public static mixed` | $allowed_actions | # This is used by extensions designed to be applied to controllers. It works the same way as `Controller::$allowed_actions`. This is used by extensions designed to be applied to controllers. It works the same way as `Controller::$allowed_actions`.
`protected `DataObject`` | $owner | # The DataObject that owns this decorator. The DataObject that owns this decorator.
`protected `DataObject`` | $ownerBaseClass | # The base class that this extension was applied to; $this->owner must be one of these The base class that this extension was applied to; $this->owner must be one of these
`public mixed` | $class | #

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -