0

我在 OroCommerce 中创建了一个新实体:Task.php

class Task {

    private $id;

    private $subject;

    private $body;

    /**
     * @var Organization
     *
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization")
     * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL")
     */
    protected $organization;
    //Omit getter and setter methods
}

并且数据库具有任务值。

然后我在 Resources/config/oro/ 中创建一个 datagrids.yml

datagrids:
app-tasks-grid:
    options:
        frontend: true
    source:
        type: orm
        query:
            select:
                - task.id
                - task.subject
                - task.body
            from:
                - { table: AaxisTaskExampleBundle:Task, alias: task}
    columns:
        id:
            label: ID
            frontend_type: integer
        subject:
            label: Subject
        body:
            label: Body
    sorters:
        columns:
            id:
                data_name: task.id
            subject:
                data_name: task.subject
            body:
                data_name: task.body
        default:
            id: DESC
    filters:
        columns:
            id:
                type: number
                data_name: task.id
            subject:
                type: string
                data_name: task.subject
            body:
                type: string
                data_name: task.body

然后,我创建一个控制器和视图

class TaskController extends Controller {
    /**
     * @Route("/task", name="aaxis_task_example")
     * @Template()
     */
    public function taskAction()
    {
        return [
            'entity_class'=> $this->container->getParameter('aaxis_taskexample.task.entity.class')
        ];
    }

以及 Resources/views/Task/task.html.twig 中的视图

{% extends 'OroUIBundle:actions:index.html.twig' %}
{% set gridName = 'app-tasks-grid' %}
{% set pageTitle = 'Task' %}

最后,我访问如下网址:http://localhost/task

它给了我一些错误: 变量“organization_name”不存在 我应该如何解决这个错误?

谢谢!!

-- 添加异常堆栈跟踪

变量“organization_name”不存在。

500 内部服务器错误 - Twig_Error_Runtime

堆栈跟踪

在第 3 行的 vendor/oro/customer-portal/src/Oro/Bundle/FrontendBundle/Resources/views/Organization/logo_frontend.html.twig -

{% 设置路由 = 'oro_frontend_root' %}

{% if isDesktopVersion() %}

{% if organization_name|length %}

    {% set logo = oro_theme_logo() %}

    <h1 class="logo logo-{{ logo ? 'image' : 'text' }}">

        <a href="{{ path(route) }}" title="{{ organization_name }}">

在 Twig_Template ->getContext (array('assetic' => array('debug' => false, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(AppVariable), 'ws' => array('port' => '8080', 'host' => '*', 'path' => ''), 'commerce' => array('layout' => 'OroFrontendBundle:: base.html.twig'), 'bap' => array('layout' => '::base.html.twig'), 'oro_ui_content_provider_manager' => object(ContentProviderManager), 'route' => 'oro_frontend_root') , '机构名称')

4

0 回答 0