BaseExtension
abstract class BaseExtension implements ExtensionInterface (View source)
BaseWidget can be used as easy starter pack or as a base for your own extensions.
Traits
Properties
protected EntityManagerInterface | $entityManager | from ServicesTrait | |
protected ContainerInterface | $container | from ServicesTrait | |
protected Query | $query | from ServicesTrait | |
protected Config | $boltConfig | from ServicesTrait |
Methods
Injects commonly used objects into the extension, for use by the extension. Called from the listener.
This bit of code allows us to get services from the container, even if they are not marked public. We need to be able to do this, because we can't anticipate which services an extension's author will want to get, and neither should we want to make them all public. So, we resort to this, regardless of them being private / public. With great power comes great responsibility.
Returns the descriptive name of the Extension
Returns the slugified name of the Extension
Called when initialising the Extension. Use this to register widgets or do other tasks after boot.
Shortcut method to register a widget and inject the extension into it
Shortcut method to add a namespace to the current Twig Environment.
No description
Get the ComposerPackage, that contains information about the package, version, etc.
Details
void
injectObjects(array $objects)
Injects commonly used objects into the extension, for use by the extension. Called from the listener.
getService(string $name)
This bit of code allows us to get services from the container, even if they are not marked public. We need to be able to do this, because we can't anticipate which services an extension's author will want to get, and neither should we want to make them all public. So, we resort to this, regardless of them being private / public. With great power comes great responsibility.
Note: We wouldn't have to do this, if we could Autowire services in our own code. If you have good ideas on how to accomplish that, we'd be happy to hear from your ideas.
Collection
getAllServiceNames()
Widgets|null
getWidgets()
Config
getBoltConfig()
Environment
getTwig()
Session
getSession()
EventDispatcherInterface
getEventDispatcher()
EntityManagerInterface
getObjectManager()
Stopwatch
getStopwatch()
LoggerInterface
getLogger()
ContainerInterface
getContainer()
Query
getQuery()
Request
getRequest()
string
getClass()
Returns the classname of the Extension
Collection
getConfig()
array
getConfigFilenames()
array
hasConfigFilenames()
string
getName()
Returns the descriptive name of the Extension
string
getSlug()
Returns the slugified name of the Extension
void
initialize()
Called when initialising the Extension. Use this to register widgets or do other tasks after boot.
void
addWidget(WidgetInterface $widget)
Shortcut method to register a widget and inject the extension into it
void
addTwigExtension(ExtensionInterface $extension)
deprecated
deprecated
void
addTwigNamespace(string $namespace = '', string $foldername = '')
Shortcut method to add a namespace to the current Twig Environment.
void
addListener($event, $callback)
void
registerWidget(WidgetInterface $widget)
deprecated
deprecated
void
registerTwigExtension(ExtensionInterface $extension)
deprecated
deprecated
void
registerListener($event, $callback)
deprecated
deprecated
CompletePackage|null
getComposerPackage()
Get the ComposerPackage, that contains information about the package, version, etc.