libre-informatique/decorator-bundle

这是Libre Informatique Symfony2项目GUI的基础

安装: 2,061

依赖项: 2

建议者: 0

安全: 0

星星: 0

关注者: 6

分支: 0

语言:CSS

类型:symfony-bundle

0.6.4 2017-11-03 15:08 UTC

This package is not auto-updated.

Last update: 2024-09-09 05:43:34 UTC


README

Build Status Coverage Status License

Latest Stable Version Latest Unstable Version Total Downloads

各种项目的基礎裝飾器

安装

前置需求

有運行的Symfony2環境

  • 已創建一個運行的Symfony2應用程序(包括您的數據庫和您的數據庫鏈接)
  • 已安裝composer(在/usr/local/bin/composer,/usr/local/bin已在您的路徑中)

選擇性

  • 已安裝libre-informatique/core-bundle,或者如果沒有,請按照Core bundle的README說明進行操作

下載

從您的項目根目錄

$ composer require libre-informatique/crm-bundle dev-master

Sonata包

不要忘記配置SonataAdminBundle。在libre-informatique/crm-bundle文檔中找到示例。

Libre Informatique包

不要忘記配置BlastCoreBundle。在libre-informatique/core-bundle文檔中找到示例。

完成

LibrinfoDecoratorBundle視為assetic包

# app/config/config.yml
# ...
assetic:
    bundles:
        # ...
        - LibrinfoDecoratorBundle
# ...

發佈資產

$ app/console assets:install --symlink

此包的目標

此包旨在以可重用和可擴展的方式簡化您的项目的个性化,就像一個框架一樣,一次為所有項目。

它作為一種中間技術,它覆蓋了默認配置,但沒有搶奪項目重新定義的權利。此外,此包還減少了項目全局配置的大小。

改進LibrinfoDecoratorBundle

基礎是能夠非常順暢地擴展SonataAdminBundle,在單個名為Resources/config/decorator.yml的YAML文件中替換其默認參數,並使用Twig的繼承和塊哲學。

decorator.yml

# Resources/config/decorator.yml
parameters:
    librinfo_decorator:
        templates:
            layout:
                original: [SonataAdminBundle::standard_layout.html.twig, BlastCoreBundle::standard_layout.html.twig]
                modified: LibrinfoDecoratorBundle::layout.html.twig

您已經注意到此包參數的根:librinfo_decorator。然後,如果您需要替換某些默認模板,您需要配置您想要替換的默認配置,以避免過度加載項目直接配置。

因此,您必須指定Sonata鍵(從您的app/config/config.yml中的sonata_admin根元素開始,參見Sonata文檔)和兩個子鍵

  • original:一個數組,其中包含您允許LibrinfoDecoratorBundle刪除的值
  • modified:將用於替換original子鍵中寫入的值的值

模板

一旦您已用新模板替換了一些默認配置模板,您將能夠,如果新模板位於LibrinfoDecoratorBundle中,在Resources/views/目錄中定義它們。在那裡,您將使用Twig的extends{{ parent() }}{% block xxx %}指導來提高效率。

例如。

{# Resources/views/layout.html.twig #}
{#

This file is part of the Libre Informatique CoreBundle package.

(c) Baptiste SIMON <baptiste.simon _AT_ libre-informatique.fr>
(c) Gildas LE MOAL <gildas.lemoal _AT_ libre-informatique.fr>
(c) Libre Informatique [http://www.libre-informatique.fr/]

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% extends 'BlastCoreBundle::standard_layout.html.twig' %}

{% block body_attributes %}

class="sonata-bc skin-blue fixed"

{% endblock %}

{% block side_bar_after_nav %}

{% endblock %}

{% block sonata_top_nav_menu %}

<div class="navbar-right">
    <ul class="nav navbar-nav">
        <li class="dropdown user-menu">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
            </a>
            <ul class="dropdown-menu dropdown-user">
                {% include admin_pool.getTemplate('user_block') %}
            </ul>
        </li>
    </ul>
</div>

{% endblock %}

{% block logo %}
    {% spaceless %}
    <a class="logo" href="{{ url('sonata_admin_dashboard') }}">
        {% if 'single_image' == admin_pool.getOption('title_mode') or 'both' == admin_pool.getOption('title_mode') %}
            {% if 'bundles/sonataadmin/logo_title.png' == admin_pool.titlelogo %}
            <img src="{{ asset('bundles/librinfodecorator/logo-li.png') }}" alt="Libre Informatique">
            {% else %}
            <img src="{{ asset(admin_pool.titlelogo) }}" alt="{{ admin_pool.title }}">
            {% endif %}
        {% endif %}
        {% if 'single_text' == admin_pool.getOption('title_mode') or 'both' == admin_pool.getOption('title_mode') %}
            {% if 'Sonata Admin' == admin_pool.title %}
            <span>Libre Informatique</span>
            {% else %}
            <span>{{ admin_pool.title }}</span>
            {% endif %}
        {% endif %}
    </a>
    {% endspaceless %}
{% endblock %}