GithubHelp home page GithubHelp logo

theme's Introduction

安装

  • 使用composer 创建主题项目 php composer create-project typenter/theme <your-theme-name>

目录说明

  • app 启动文件目录
  • app/Resources/views 模版文件目录
  • assets 静态资源目录
  • cache 缓存目录
  • views 模版目录
  • tests 测试脚本

app/kernel.php 内核启动脚本

<?php
defined('ABSPATH') or die('-2');

require __DIR__ . '/autoload.php';

use Typenter\Component\Kernel\Kernel;
use Typenter\Component\Kernel\KernelEvents;
use Typenter\Component\Kernel\Event\GetAssetsEvent;

class ThemeAppKernel extends Kernel
{
    public function registerBundles()
    {
        return array(
            new Typenter\Bundle\TemplatingBundle\TemplatingBundle(),
            new Typenter\Bundle\FrameworkBundle\FrameworkBundle(),
            new Typenter\Bundle\ThemeBundle\ThemeBundle()
        );
    }
    
    /**
     * @see \Typenter\Component\Kernel\KernelEvents
     * @return  array
     */
    public function registerEventListeners()
    {
        return array(
             array(
                'name' => KernelEvents::ENQUEUE_ASSETS,
                'priority' => 200,
                'listener' => function (GetAssetsEvent $event) {
                    // $event->addStyle($handle, $style);
                    // $event->addScript($handle, $script, array(), $event::VERSION, true);
                }
            ),
        );
    }
    
    /**
     * @return  array
     */  
    public function registerEventSubscribers()
    {
        return array(
            // new Typenter\Bundle\FrameworkBundle\EventListener\AssetsEventSubscriber(),  
            // ...
        );
    }
}   
    
// dev 启用开发环境,页面缓存会自动刷新,生产环境 prod
$kernel = new ThemeAppKernel('dev');	
$kernel->boot();
// 如果需要在其他PHP代码中使用整个运行环境,需要设置全局变量  
typenter_setup_environment($kernel);  

模版

如果指定了命名空间为ThemeBundletypenter_render('@ThemeBundle/index.html.twig') 的查找顺序为

  • <主题根目录>/views/ThemeBundle/index.html.twig
  • <主题根目录>/path/to/ThemeBundle/Resources/views/index.html.twig

typenter_render('index.html.twig') 查找目录为

  • <主题根目录>/app/Resources/views/index.html.twig

如果未找到则抛出异常.

theme's People

Contributors

libertyspy avatar

Watchers

little-ant avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.