DNADesign\Elemental\Models\BaseElement
Class BaseElement
Synopsis
class BaseElement
extends DataObject
{
- // members
- private static string $icon = 'font-icon-block-layout';
- private static string $description = 'Base element class';
- private static array $db = ;
- private static array $has_one = ;
- private static array $extensions = ;
- private static array $casting = ;
- private static array $indexes = ;
- private static boolean $versioned_gridfield_extensions = true;
- private static string $table_name = 'Element';
- private static string $controller_class = ElementController::class;
- private static string $controller_template = 'ElementHolder';
- protected ElementController $controller;
- protected $cacheData;
- private static string $default_sort = 'Sort';
- private static string $singular_name = 'block';
- private static string $plural_name = 'blocks';
- private static array $summary_fields = ;
- private static array $styles = ;
- private static array $searchable_fields = ;
- private static boolean $disable_pretty_anchor_name = false;
- private static bool $inline_editable = true;
- private static boolean $displays_title_in_template = true;
- protected static array $used_anchors = ;
- protected $anchor = NULL;
- // methods
- public boolean canView()
- public boolean canEdit()
- public boolean canDelete()
- public boolean canCreate()
- public void onBeforeWrite()
- public void getCMSFields()
- public string getType()
- public bool inlineEditable()
- public $this setController()
- public ElementController getController()
- public $this setAreaRelationNameCache()
- public Controller Top()
- public string|null forTemplate()
- public array getRenderTemplates()
- public void updateFromFormData()
- protected string stripNamespacing()
- public string getSimpleClassName()
- public null|SiteTree getPage()
- public string getAnchor()
- public string|null AbsoluteLink()
- public string Link()
- public string PreviewLink()
- public boolean isCMSPreview()
- public null|string CMSEditLink()
- public int|string getAreaRelationName()
- public string sanitiseClassName()
- public void unsanitiseClassName()
- public null|string getEditLink()
- public DBField|null PageCMSEditLink()
- public string getMimeType()
- public string getSummary()
- public static array getBlockConfig()
- public array getBlockSchema()
- protected array provideBlockSchema()
- public null|DBHTMLText getIcon()
- public string getDescription()
- public DBField getTypeNice()
- public DBHTMLText getEditorPreview()
- public Member getAuthor()
- public string getStyleVariant()
- public mixed|null getPageTitle()
- public boolean First()
- public boolean Last()
- public int TotalItems()
- public int Pos()
- public string EvenOdd()
- public static string getGraphQLTypeName()
Hierarchy
Extends
- SilverStripe\ORM\DataObject
Members
private
- $casting
- $controller_class — string
- $controller_template — string
- $db
- $default_sort
- $description
—
string
Describe the purpose of this element - $disable_pretty_anchor_name
—
boolean
Enable for backwards compatibility - $displays_title_in_template
—
boolean
Display a show title button - $extensions
- $has_one
- $icon
—
string
Override this on your custom elements to specify a CSS icon class - $indexes
- $inline_editable
—
DNADesign\Elemental\Models\bool
Set to false to prevent an in-line edit form from showing in an elemental area. Instead the element will be clickable and a GridFieldDetailForm will be used. - $plural_name
- $searchable_fields
- $singular_name
- $styles — array
- $summary_fields
- $table_name
- $versioned_gridfield_extensions
protected
- $anchor
—
string
For caching 'getAnchor' - $cacheData
—
array
Cache various data to improve CMS load time - $controller — DNADesign\Elemental\Controllers\ElementController
- $used_anchors
—
array
Store used anchor names, this is to avoid title clashes when calling 'getAnchor'
Methods
protected
- provideBlockSchema() — Provide block schema data, which will be serialised and sent via GraphQL to the editor client.
- stripNamespacing() — Strip all namespaces from class namespace.
public
- AbsoluteLink()
- CMSEditLink()
- EvenOdd()
- First()
- Last()
- Link()
- PageCMSEditLink()
- Pos() — Returns the position of the current element.
- PreviewLink()
- Top()
- TotalItems()
- canCreate() — Basic permissions, defaults to page perms where possible.
- canDelete() — Basic permissions, defaults to page perms where possible.
- canEdit() — Basic permissions, defaults to page perms where possible.
- canView() — Basic permissions, defaults to page perms where possible.
- forTemplate() — Default way to render element in templates. Note that all blocks should be rendered through their {@link ElementController} class as this contains the holder styles.
- getAnchor() — Get a unique anchor name
- getAreaRelationName() — Retrieve a elemental area relation for creating cms links
- getAuthor()
- getBlockConfig() — The block config defines a set of data (usually set through config on the element) that will be made available in client side config. Individual element types may choose to add config variable for use in React code
- getBlockSchema() — The block actions is an associative array available for providing data to the client side to be used to describe actions that may be performed. This is available as a plain "ObjectType" in the GraphQL schema.
- getCMSFields()
- getController()
- getDescription() — Get a description for this content element, if available
- getEditLink()
- getEditorPreview()
- getGraphQLTypeName()
- getIcon() — Generate markup for element type icons suitable for use in GridFields.
- getMimeType()
- getPage()
- getPageTitle()
- getRenderTemplates()
- getSimpleClassName()
- getStyleVariant() — Get a user defined style variant for this element, if available
- getSummary() — This can be overridden on child elements to create a summary for display in GridFields.
- getType() — Get the type of the current block, for use in GridField summaries, block type dropdowns etc. Examples are "Content", "File", "Media", etc.
- getTypeNice() — Generate markup for element type, with description suitable for use in GridFields.
- inlineEditable() — Proxy through to configuration setting 'inline_editable'
- isCMSPreview()
- onBeforeWrite() — Increment the sort order if one hasn't been already defined. This ensures that new elements are created at the end of the list by default.
- sanitiseClassName() — Sanitise a model class' name for inclusion in a link.
- setAreaRelationNameCache()
- setController()
- unsanitiseClassName()
- updateFromFormData() — Given form data (wit