digitalstate / platform-user-bundle

数字状态用户包

安装: 153

依赖项: 2

建议者: 0

安全性: 0

星标: 0

关注者: 4

分支: 1

类型:symfony-bundle

0.3.0 2017-02-21 00:36 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:47:53 UTC


README

用户包扩展了OroUserBundle,为开发者提供了额外的核心用户功能。

Code Climate Test Coverage

目录

数据解析器

本包引入了一种基于当前会话数据而不是数据库的另一种类型的数据解析器。

示例:

<?php

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');
    }
}

一个典型的用例是在您希望使用会话数据预先填充表单时。

示例:

<?php

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
        ]);
    }
}

迁移扩展

本包引入了一组方便的迁移扩展,以帮助加载基于yml的数据固定。

示例:

<?php

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);
    }
}
users:
    -
        username: john
        password: john
        email: john@gov.com
        roles: [ ROLE_USER ]
        first_name: John
        last_name: Doe

prototype:
    email: ~
    roles: []
    first_name: ~
    last_name: ~
    owner: main
    business_units: [ main ]
    organization: default
    organizations: [ default ]
    enabled: true

待办事项