Created
March 25, 2014 20:07
-
-
Save discordier/9770210 to your computer and use it in GitHub Desktop.
DcGeneral - retrieve a single model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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