PHP code example of digitalstate / platform-user-bundle
1. Go to this page and download the library: Download digitalstate/platform-user-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/ */
digitalstate / platform-user-bundle example snippets
namespace Gov\Bundle\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DemoController extends Controller
{
public function demoAction()
{
$data = $this->get('ds.data.data');
$username = $data->resolve('ds.session.user.username');
}
}
namespace Gov\Bundle\DemoBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class DemoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('username', 'text', [
'data' => 'ds.session.user.username',
'resolve' => true
]);
}
}
namespace Gov\Bundle\DemoBundle\Migrations\Data\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Ds\Bundle\UserBundle\Migration\Extension\UserExtensionAwareInterface;
use Ds\Bundle\UserBundle\Migration\Extension\UserExtensionAwareTrait;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Doctrine\Common\Persistence\ObjectManager;
class LoadUserData extends AbstractFixture implements UserExtensionAwareInterface, ContainerAwareInterface
{
use UserExtensionAwareTrait;
use ContainerAwareTrait;
public function load(ObjectManager $manager)
{
// Currently extensions are not automatically injected via the *AwareInterface.
$this->setUserExtension($this->container->get('ds.user.migration.extension.user'));
//
$resource = __DIR__.'/../../../Resources/data/users.yml';
$this->userExtension->import($resource, $manager);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.