This is one of the greatest Diem features.
Every part of Diem is called a service. And you can replace and extend each of them.
Learn about the Symfony Dependency Injection Container
You can take advantage of Diem services, and create your own ones.
To get a service instance, you need the service container.
$this->getService('service_name');
$this->getService('service_name');
The service container is available in your models.
In some rare cases, like during symfony tasks that don't create a context instance,
the service container may not be loaded. That's why you should use this syntax
to verify the service you try to use is available:
if($service = $this->getService('service_name')) { // use the service }
Like for the model:
if($service = $this->getService('service_name')) { // use the service }
From the project configuration, as well as the application configuration or a plugin configuration,
you don't have access to the service container. But you can listen to an event
that is fired when the service container is loaded, and get it at this time:
public function configure() { $this->dispatcher->connect('dm.context.loaded', array($this, 'listenToContextLoadedEvent')); } // when the context is loaded public function listenToContextLoadedEvent(sfEvent $event) { // get the service container from the context $serviceContainer = $event->getSubject()->getServiceContainer(); $service = $serviceContainer->getService('service_name'); }
Let's suppose we want to change the way Diem detects browsers. This is done with the browser_detection service. We will tell Diem to use another class for the browser detection service in
config/dm/services.yml
parameters:
browser_detection.class: myBrowserDetection
Then we create the myBrowserDetection class in
lib/myBrowserDetection.php
class myBrowserDetection extends dmBrowserDetection { public function execute($userAgent) { // your own way to detect browser based on USER_AGENT } }
The core services can be used in both admin and front application.
To extend them, use the config/dm/services.yml file.
The original services.yml can be found in dmCorePlugin/config/dm/services.yml.
Responsible for parsing markdown text and generating HTML.
Responsible for saving a copy of files edited. All files modified with a Diem code editor are backuped.
Responsible for generating visual text diffs
Responsible for rendering diffs between two versions of a record
Responsible for building an email from a DmMailTemplate and a data array, then pass it to Swift.
This service is not yet ready for usage
Responsible for launching background tasks using an internal shell.
Responsible for adding, updating and removing pages when the site content changes.
Responsible for updating pages metas when the site content changes.
Responsible for clearing the cache automatically when the site content changes.
Represents a field in a form. Allows chainability in form template helpers.
Responsible for finding applications bootstrap urls. Allows to make a link to the site from the admin, and a link to admin from the site.
Responsible for listening the "application.throw_exception" events and make something with the errors.
Responsible for rendering img tags with the _media helper. Configurable from the graphical configuration panel.
Responsible for rendering flash objects with the _media helper. Not ready yet, you should extend it if you need it.
Responsible for rendering video with the _media helper. Not ready yet, you should extend it if you need it.
Responsible for rendering audio with the _media helper. Not ready yet, you should extend it if you need it.
Ressource for a media_tag_*
Responsible for rendering HTML tables with the _table helper
Responsible for managing search indices and provide a handfull programming interface.
Responsible for maintaining and querying an index ( for example, the "en" index )
Responsible for indexing a page
Single search result
Responsible for managing a CSS theme
Responsible for minifying, merging and compressing stylesheets
Responsible for minifying, merging and compressing javascripts
Responsible for rendering the authentication page layout
Responsible for managing cache
Extension of sfFilesystem
Responsible for logging all notable events
An entry of the event log
Responsible for logging all requests
An entry of the request log
Represents a user browser
Responsible for detecting user browser depending on its user agent
Responsible for listening all events that may require a page synchronization, and launch the synchronization if any before redirections.
Object oriented template helper.
Responsible for managing widget types.
Multilingual sites only. When a page is created in a culture, this service will generate missing page translations for other cultures.
Detects mime types from file names.
Fills the project with random records.
Fills a table with random records.
Fills the record fields with random values.
Responsible for paginating doctrine collections
Basic HTTP client. Overrides sfWebBrowser.
Responsible for loading default data in the project
Responsible for rendering admin & front toolbar. Implemented by dmAdminToolBarView on admin app, and by dmFrontToolBarView on front app. Use your apps/admin/config/dm/services.yml or apps/front/config/dm/services.yml file to change the class and modify the tool bar.
The admin services can only be used in admin application.
To extend them, use the apps/admin/config/dm/services.yml file.
The original services.yml can be found in dmAdminPlugin/config/dm/services.yml.
Responsible for managing and rendering windows on admin homepage.
See the related dm.admin_homepage.filter_windows event.
Responsible for building and rendering the admin automatic breadcrumbs.
Responsible for rendering the log chart.
Responsible for rendering the week chart.
Responsible for rendering the visit chart.
Responsible for rendering the content chart.
Responsible for rendering the browser chart.
Responsible for fetching data from google analytics.
Responsible for rendering admin link tags with the _link helper.
Responsible for loading required assets.
Generic form to sort a table.
Generic form to sort table's referers.
Responsible for rendering the admin layout.
Responsible for building and rendering the admin menu.
Responsible for generating and saving automatic sitemap.xml files.
Shows a list of records related to another one.
Responsible for rendering a dmLog instance.
Responsible for rendering the admin tool bar
The front services can only be used in front application.
To extend them, use the apps/front/config/dm/services.yml file.
The original services.yml can be found in dmFrontPlugin/config/dm/services.yml.
deprecated: Please use sitemap_menu instead.
Responsible for building and rendering an HTML sitemap. Not to be confused with the xml sitemap, the HTML one is intended to be displayed on the site.
Responsible for building and rendering an HTML sitemap. Not to be confused with the xml sitemap, the HTML one is intended to be displayed on the site.
Responsible to redirect or forward the user when the request page is not found.
Responsible for creating and managing front forms.
Responsible for rendering a link tag to a record with the _link helper. Configurable from the graphical configuration panel.
Responsible for rendering a link tag to a DmPage instance with the _link helper. Configurable from the graphical configuration panel.
Responsible for rendering a link tag to a DmMedia instance with the _link helper. Configurable from the graphical configuration panel.
Responsible for rendering a link tag to a symfony action with the _link helper. Configurable from the graphical configuration panel.
Responsible for rendering a link tag to an external uri with the _link helper. Configurable from the graphical configuration panel.
Responsible for rendering a link tag to an exception with the _link helper. Configurable from the graphical configuration panel.
Ressource for a link_tag_*.
Responsible for loading required assets.
Responsible for managing available themes.
Responsible for rendering a widget.
Responsible for rendering the front layout.
Responsible for rendering the front content. Displays Areas, Zones and Widgets. This service has two implementations : page_helper.view_class and page_helper.edit_class. The implementation to use it chosen at runtime depending on the user permissions.
Responsible for rendering widgets.
Form used when displaying a zone edition dialog
Responsible for building a page_route from a slug
Wraps a page and a culture that match a slug
Responsible for building and rendering the front add menu
Responsible for building and rendering the front code editor file menu
Responsible for rendering a sfPager with pagination links
Responsible for rendering the front tool bar
Questions and Feedback
If you need support or have a technical question, you can
The documentation is hosted on GitHub. Feel free to submit issues and patches!