stormdelta/latex-encoder-annotation-bundle

LaTeX 编码注释包

v0.1.7 2015-09-30 05:52 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:33:20 UTC


README

此包仍在开发中!

使用注释安全地将值编码到 LaTeX。安装

composer require stormdelta/latex-encoder-annotation-bundle

配置

app/AppKernel.php 中配置 Bundle

//app/AppKernel.php

use ...

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new StormDelta\LatexEncoder\AnnotationBundle\StormDeltaLatexEncoderAnnotationBundle(),
            ...
        );
        ...
}

使用方法

在实体中使用注释

//src/AppBundle/Entity/LatexEntity.php

namespace AppBundle\Entity\LatexEntity;

use StormDelta\LatexEncoder\AnnotationBundle\Annotation\LatexEncoderAnnotation as LatexEncode;

class LatexEntity
{
    /**
     * @LatexEncode
     */
    $variable;
}

在控制器中进行编码

//src/AppBundle/Controller/DefaultController.php

namespace AppBundle\Controller;

use ...

class DefaultController extends Controller
{
    ...
    public function indexAction(...)
    {
        $entity = new LatexEntity();
        ...
        $entity = $this->get('stormdelta.latexencoder.driver')->encode($entity);
        ...
        return array('entity' => $entity);
    }
}

“高级”使用

在实体中使用 LatexEncoderFollowAnnotation 编码相关实体

//src/AppBundle/Entity/LatexEntity.php

namespace AppBundle\Entity\LatexEntity;

...
use StormDelta\LatexEncoder\AnnotationBundle\Annotation\LatexEncoderFollowAnnotation as LatexFollow;

class LatexEntity
{
    /**
     * @ORM\OneToMany(targetEntity="...")
     * @LatexFollow
     */
    $variables;
}