PHP code example of modera / config-bundle
1. Go to this page and download the library: Download modera/config-bundle library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
modera / config-bundle example snippets php
// config/bundles.php
return [
// ...
Modera\ConfigBundle\ModeraConfigBundle::class => ['all' => true],
];
php
namespace MyCompany\SiteBundle\Contributions;
use Modera\ConfigBundle\Config\ConfigurationEntryDefinition as CED;
use Sli\ExpanderBundle\Ext\ContributorInterface;
class ConfigEntriesProvider implements ContributorInterface
{
private $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
/**
* {@inheritdoc}
*/
public function getItems()
{
$serverConfig = array(
'id' => 'modera_config.entity_repository_handler'
);
$admin = $this->em->find('MyCompany\SecurityBundle\Entity\User', 1);
return array(
new CED('admin_user', 'Site administrator', $admin)
);
}
}
php
/* @var \Modera\ConfigBundle\Manager\ConfigurationEntriesManagerInterface $service */
$service = $container->get('modera_config.configuration_entries_manager');
/* @var \Modera\ConfigBundle\Config\ConfigurationEntryInterface $entry */
$entry = $service->findOneByNameOrDie('admin_user');
// will yield "MyCompany\SecurityBundle\Entity\User"
echo get_class($property->getValue());
php
$bob = new \Modera\SecurityBundle\Entity\User();
// ... configure and persist $bob
$ce = new ConfigurationEntry();
$ce->setOwner($myUser);
$manager->save($ce);