playground / user
用户模块
Requires
- php: >=7.3.0
- facebook/graph-sdk: ^5.6
- hybridauth/hybridauth: @RC
- laminas/laminas-dependency-plugin: ^2.1
- laminas/laminas-developer-tools: >=1.0.0
- lm-commons/lmc-user: ^3.5
- playground/design: ^6.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.4
- phpunit/phpunit: >=4.0.0
- squizlabs/php_codesniffer: >=2.0.0
- dev-develop
- 6.0.2
- 6.0.1
- 6.0.0
- dev-master / 5.x-dev
- 5.0.0
- 4.9.5
- 4.9.4
- 4.9.3
- 4.9.2
- 4.9.1
- 4.9.0
- 4.8.1
- 4.8.0
- 4.7.0
- 4.6.2
- 4.6.1
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.0
- 4.2.13
- 4.2.12
- 4.2.11
- 4.2.10
- 4.2.9
- 4.2.8
- 4.2.7
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.0
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.6.19
- 2.6.18
- 2.6.17
- 2.6.16
- 2.6.15
- 2.6.14
- 2.6.13
- 2.6.12
- 2.6.11
- 2.6.10
- 2.6.9
- 2.6.8
- 2.6.7
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.0
- 1.1.1
This package is auto-updated.
Last update: 2024-09-17 12:08:05 UTC
README
#介绍
此模块扩展了LmcUser,提供了许多与客户账户管理相关的功能。
PgUser带来的功能包括
- 通过BjyAuthorize管理权限
- 忘记密码
- 通过邮件激活账户
- 记住我
- 管理头像
- 基于HybridAuth的Facebook认证
- 通过Ajax登录
- 用户管理个人资料
- 后台管理账户
- 锁定账户(==软删除)
#安装
使用Doctrine
通过shell定位到vendor/doctrine/doctrine-module/bin目录。
命令php doctrine-module.php orm:schema-tool:create可以将此模块的表安装到数据库中
命令php doctrine-module.php data-fixture:import --append可以安装'user'和'admin'角色以及用户'admin@test.com'(密码'admin')并赋予管理员权限。
#扩展PgUser
使用自己的用户实体
如果您想使用自己的实体
-
在lmcuser.global.php文件中更改'user_entity_class'的值。
'user_entity_class' => 'MyUser\Entity\User',
-
在您的模块.config.php模块(扩展用户实体)中放置您的doctrine定义
'doctrine' => array( 'driver' => array( 'lmcuser_entity' => array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'cache' => 'array', 'paths' => __DIR__ . '/../src/MyUser/Entity' ), 'orm_default' => array( 'drivers' => array( 'MyUser\Entity' => 'lmcuser_entity' ) ) ) ),
-
在您的模块中创建实体(使用doctrine注释),您需要实现PgUser\Entity\UserInterface接口(下面有说明)
class User implements \PgUser\Entity\UserInterface, ProviderInterface, InputFilterAwareInterface
-
其他需要链接PgUser实体基的Adfab模块实体基于接口:PgUser\Entity\UserInterface。因此,如果您扩展了用户实体,您可以轻松地替换此关系。为了做到这一点,您的用户实体需要实现PgUser\Entity\UserInterface。然后,在Module.php的onBootstrap方法中,您需要使用doctrine监听器功能将接口替换为正确的类
public function onBootstrap($e) { $sm = $e->getApplication()->getServiceManager(); $doctrine = $sm->get('application_doctrine_em'); $evm = $doctrine->getEventManager(); $listener = new \Doctrine\ORM\Tools\ResolveTargetEntityListener(); $listener->addResolveTargetEntity( 'PgUser\Entity\UserInterface', 'MyUser\Entity\User', array() ); $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $listener); }
请注意:扩展实体的模块必须放在application.config.php中链接到扩展实体的其他模块之后
使用自己的表单
如果您想更改ChangeInfo表单(例如,您想添加一个'children'选择列表以持久化到您的用户数据库表)。首先像前面解释的那样扩展实体。然后
-
在您的模块中创建表单类,该类扩展了PgUser表单
class ChangeInfo extends \PgUser\Form\ChangeInfo
如果您想使用PgUser表单的默认字段,您可以通过使用父构造函数来实现
parent::__construct($name, $createOptions, $translator);
然后添加您想要的表单元素
$this->add(array( 'type' => 'Laminas\Form\Element\Select', 'name' => 'children', 'attributes' => array( 'id' => 'children', 'options' => array( '0' => 0, '1' => 1, '2' => 2, '3' => 3, ), ), 'options' => array( 'empty_option' => $translator->translate('Select', 'pguser'), 'label' => $translator->translate('Children', 'pguser'), ), ));
-
通过在Module.php的factories定义中重复使用PgUser中使用的相同表单名称来声明您的表单
public function getServiceConfig() { return array( 'factories' => array( 'pguser_change_info_form' => function($sm) { $translator = $sm->get('MvcTranslator'); $options = $sm->get('pguser_module_options'); $form = new Form\ChangeInfo(null, $options, $translator); return $form; }, ) ); }
使用自己的用户控制器
如果您想添加一个操作或修改现有的一个。
-
在您的模块中创建控制器(如果您想使用其方法,则扩展PgUser)
class UserController extends \PgUser\Controller\Frontend\UserController { public function profileAction () { ... } }
-
在您的module.config.php文件中定义您的控制器并将路由与控制器关联。不要忘记定义视图名称并根据需要调整核心布局定义
'core_layout' => array( 'MyUser' => array( 'default_layout' => 'layout/2columns-left', 'children_views' => array( 'col_left' => 'adfab-user/layout/col-user.phtml', ), ), ), 'controllers' => array( 'invokables' => array( 'myuser_user' => 'MyUser\Controller\UserController', ), ), 'router' => array( 'routes' => array( 'lmcuser' => array( 'child_routes' => array( 'profile' => array( 'type' => 'Laminas\Router\Http\Literal', 'options' => array( 'route' => '/mes-coordonnees', 'defaults' => array( 'controller' => 'myuser_user', 'action' => 'profile', ), ), ), ), ), ), ), 'view_manager' => array( 'template_path_stack' => array( 'pguser' => __DIR__ . '/../view', ), 'template_map' => array( 'adfab-user/header/login.phtml' => __DIR__ . '/../view/adfab-user/frontend/header/login.phtml', 'my-user/user/profile' => __DIR__ . '/../view/adfab-user/frontend/account/profile.phtml', ), ),
-
您需要将此新控制器声明到bjyauthorize.global.php中
'guards' => array( 'BjyAuthorize\Guard\Controller' => array( //Front Area array('controller' => 'myuser_user', 'roles' => array('guest', 'user')),