承接 sip/text-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sip/text-bundle

Composer 安装命令:

composer require sip/text-bundle

包简介

Simple text page using SyliusResourceBundle

README 文档

README

Module for create simple text pages with SonataAdmin backend.

Installation

  1. command to add the bundle to your composer.json and download package.
$ composer require "sip/text-bundle": "dev-master"
  1. Enable the bundle inside the kernel.
<?php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        new SIP\TextBundle\SIPTextBundle(),
        new Genemu\Bundle\FormBundle\GenemuFormBundle(),
        // If you wish to use SonataAdmin
        new Sonata\BlockBundle\SonataBlockBundle(),
        new Sonata\jQueryBundle\SonatajQueryBundle(),
        new Sonata\AdminBundle\SonataAdminBundle(),

        // Other bundles...
    );
}

Read more about installation SonataAdminBundle

  1. Creating your entity
<?php
namespace MyBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use SIP\TextBundle\Entity\Text as BaseText;

/**
 * @ORM\Entity
 * @ORM\Table(name="content_text")
 */
class Text extends BaseText
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }
}
  1. Updating database schema
$ php app/console doctrine:schema:update --force

This should be done only in dev environment! We recommend using Doctrine migrations, to safely update your schema.

  1. Importing routing configuration
SIPTextBundle:
    resource: '@SIPTextBundle/Resources/config/routing.yml'
    prefix:   /
  1. Configuration:
# app/config/config.yml
sip_text:
    model: MyBundle\Entity\Text
    # All Default configuration:
    # controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
    # repository: Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository
    # admin: SIP\TextBundle\Admin\TextAdmin
  1. Templates

The bundle requires only the show.html template. Easiest way to override the view is placing it here app/Resources/SIPTextBundle/views/Text/show.html.twig.

  1. Usage

Create a menu for text pages

<?php

namespace MyBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;

class Builder extends ContainerAware
{
    public function mainMenu(FactoryInterface $factory)
    {
        $menu = $factory->createItem('root', array(
            'childrenAttributes' => array(
                'class' => 'nav'
            )
        ));

        $childOptions = array(
            'attributes'         => array('class' => 'dropdown'),
            'childrenAttributes' => array('class' => 'dropdown-menu'),
            'labelAttributes'    => array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'href' => '#')
        );

        $child = $menu->addChild('Text pages', $childOptions);

        $textPages = $this->getTextRepository()->findBy(array('disabled' => 0));
        foreach ($textPages as $textPage) {
            $child->addChild($textPage->getTitle(), array(
                'route'           => 'sip_text_text_item',
                'routeParameters' => array(
                    'slug'  => $textPage->getSlug()
                ),
                'labelAttributes' => array('icon' => 'icon-chevron-right')
            ));
        }

        return $menu;
    }

    public function getTextRepository()
    {
        return $this->container->get('sip_text.repository.text');
    }
}

Now you have a menu of text pages and you can use it in your template. Read more about rendering knp menu

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固