Skip to content

Instantly share code, notes, and snippets.

@discordier
Created March 25, 2014 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save discordier/9770210 to your computer and use it in GitHub Desktop.
Save discordier/9770210 to your computer and use it in GitHub Desktop.
DcGeneral - retrieve a single model.
<?php
use ContaoCommunityAlliance\DcGeneral\Factory\DcGeneralFactory;
// Create the DcGeneral.
$factory = new DcGeneralFactory();
$dcGeneral = $factory->setContainerName('tl_data')->createDcGeneral();
// Fetch the correct data provider.
$dataProvider = $dcGeneral->getEnvironment()->getDataProvider(/* 'tl_data' is not required here but possible as it is the default */);
// Get a data config.
$config = $dataProvider->getEmptyConfig();
// Tell the config that we want to rettrieve model with id 10.
$config->setId(10);
// Finally retrieve the model.
$model = $dataProvider->fetch($config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment