onaxis/ezplatform-extra

eZ Platform 扩展包

安装: 11

依赖: 0

建议者: 0

安全: 0

星标: 4

关注者: 2

分支: 0

开放问题: 0

类型:ezplatform-bundle

v1.0.4 2018-12-16 04:07 UTC

This package is auto-updated.

Last update: 2024-09-16 19:43:49 UTC


README

安装

使用 Composer

composer require onaxis/ezplatform-extra

将扩展包添加到您的应用程序中

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Onaxis\EzPlatformExtraBundle\OnaxisEzPlatformExtraBundle(),
        // ...
    );
}

路由

在您的 routing.yml 文件中添加以下内容

onaxis_ezplatform_extra:
    resource: "@OnaxisEzPlatformExtraBundle/Resources/config/routing.yml"

此路由文件启用了路由 onaxis_ezplatform_extra.user.selfedit (/user/selfedit)

角色

您需要将 user/selfedit 策略添加到用户角色中。

信息

字段 user_account.enabled 将不会被用户编辑,以避免用户禁用自己。

额外配置

您可以通过创建该表单的多个版本来自定义用户自我编辑表单。

例如,您可能需要创建 2 个页面

  • 一个个人资料编辑页面
  • 一个密码编辑页面

自定义表单示例

onaxis_ez_platform_extra:
    user_self_edit_form_filters:
        profile:
            # type is optional: default value is 'include/exclude'
            # other posible value is 'exclude/include'
            type: 'include/exclude'
            exclude: ['user_account']
        account:
            include: ['user_account']
        password:
            include: ['user_account']
            exclude: ['user_account.username', 'user_account.email']

此配置启用了以下 URL

  • /user/selfedit/profile
  • /user/selfedit/account
  • /user/selfedit/password

以下是如何生成这些路由

<a href="{{ path('onaxis_ezplatform_extra.user.selfedit', {'filter': 'profile'}) }}">Edit my profile</a>
<a href="{{ path('onaxis_ezplatform_extra.user.selfedit', {'filter': 'account'}) }}">Edit my account</a>
<a href="{{ path('onaxis_ezplatform_extra.user.selfedit', {'filter': 'password'}) }}">Change my password</a>

要了解可用字段,请使用以下命令

php bin/console ezplatform-extra:user-self-edit:form-fields

默认情况下,列出的字段对应于管理员用户内容类型(用户)(UserID:14)

输出示例

User Content ID:    14
Content Type ID:    4
Content Identifier: user
----------------------------

 - first_name
 - last_name
 - user_account
 - user_account.username
 - user_account.password
 - user_account.password.first
 - user_account.password.second
 - user_account.email
 - user_account.enabled
 - signature
 - image
 - image.remove
 - image.file
 - image.alternativeText

要了解其他内容类型的字段,只需传递一个用户内容 ID:(必须存在您的后端中具有此内容类型的用户)

php bin/console ezplatform-extra:user-self-edit:form-fields 80

输出示例

User Content ID:    80
Content Type ID:    13
Content Identifier: member_user
----------------------------

 - first_name
 - last_name
 - user_account
 - user_account.username
 - user_account.password
 - user_account.password.first
 - user_account.password.second
 - user_account.email
 - user_account.enabled