webundle/puzzle-news-bundle

管理文章和新闻

安装: 2

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.0 2019-07-10 09:39 UTC

This package is auto-updated.

Last update: 2024-09-10 21:05:41 UTC


README

本项目基于 Symfony 项目,用于管理新闻账户和新闻安全。

安装包

打开命令行,进入您的项目目录,然后执行以下命令以下载此包的最新稳定版本

composer require webundle/puzzle-news-bundle

步骤 1: 启用包

通过将包添加到您的项目 app/AppKernel.php 文件中注册的包列表中,来启用管理员包

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Puzzle\NewsBundle\NewsBundle(),
        );

        // ...
    }

    // ...
}

步骤 2: 配置包安全

通过在您的项目 app/config/security.yml 文件中添加配置来配置安全设置

security:
   	...
    role_hierarchy:
        ...
        # News
        ROLE_NEWS: ROLE_ADMIN
        ROLE_SUPER_ADMIN: [..,ROLE_NEWS]
        
	...
    access_control:
        ...
        # News
        - {path: ^%admin_prefix%news, host: "%admin_host%", roles: ROLE_NEWS }

步骤 3: 启用包路由

通过将其添加到您的项目 app/config/routing.yml 文件中,注册默认路由

....
news:
    resource: "@NewsBundle/Resources/config/routing.yml"
    prefix:   /

输入以下命令以查看所有新闻路由:php bin/console debug:router | grep news

步骤 4: 配置包

通过将其添加到您的项目 app/config/config.yml 文件中来配置管理员包

admin:
    ...
    modules_available: '..,news'
    navigation:
        nodes:
            ...
            # News
            news:
                label: 'news.title'
                description: 'news.description'
                translation_domain: 'news'
                attr:
                    class: 'fa fa-newspaper-o'
                parent: ~
                user_roles: ['ROLE_NEWS']
            news_post:
                label: 'news.post.navigation'
                description: 'news.post.description'
                translation_domain: 'news'
                path: 'puzzle_admin_news_post_list'
                sub_paths: ['puzzle_admin_news_post_create', 'puzzle_admin_news_post_update', 'puzzle_admin_news_post_update_gallery',  'puzzle_admin_news_post_show', 'puzzle_admin_news_comment_list']
                parent: news
                user_roles: ['ROLE_NEWS']
            news_category:
                label: 'news.category.navigation'
                description: 'news.category.description'
                translation_domain: 'news'
                path: 'puzzle_admin_news_category_list'
                sub_paths: ['puzzle_admin_news_category_create', 'puzzle_admin_news_category_update', 'puzzle_admin_news_category_show']
                parent: news
                user_roles: ['ROLE_NEWS']