- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Sonata 管理包来生成我的后端,我对它非常满意,我也想使用我的后端来显示统计信息。
我想我可以通过调整包的 View 来做到这一点,也许是“standard_layout.html.twig”。
问题是,我找不到例子,甚至找不到谈论它的人,所以我想知道,这可能吗?人们谈论它是不是因为它太简单了?你做了吗 ?
我真的很想有一个后端,所以请赐教!
谢谢,
康普兹
最佳答案
是的,这是可能的。可以使用 Sonata Block 或使用您自己的 Controller 来完成。
如果您使用您的 Controller ,您可以从默认 CRUD Controller 重载(一个或多个)操作,渲染结果的外观取决于您。
SonataAdminBundle:CRUD
与您的 Controller AcmeDemoAdminBundle:ProductStatisticsAdmin 定义您的管理服务和 删除实体 因为我们将尝试在没有 CRUD 操作的情况下呈现我们的统计数据。<service id="acme_demo_admin.product_statistics" class="Acme\Bundle\DemoAdminBundle\Admin\ProductStatisticsAdmin">
<tag name="sonata.admin" manager_type="orm" group="statistics_group" label_catalogue="admin" label="Product Statistics" />
<argument />
<argument />
<argument>AcmeDemoAdminBundle:ProductStatisticsAdmin</argument>
</service>
ProductStatisticsAdmin
在 Acme/Bundle/DemoAdminBundle/Admin/ProductStatisticsAdmin.php
.这个类将非常简单,因为我们只需要 list
Action ,没有其他 CRUD 操作。<?php
namespace Acme\Bundle\DemoAdminBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Route\RouteCollection;
class ProductStatisticsAdmin extends Admin
{
protected $baseRoutePattern = 'product-statistics';
protected $baseRouteName = 'productStatistics';
protected function configureRoutes(RouteCollection $collection)
{
$collection->clearExcept(array('list'));
}
}
Acme/Bundle/DemoAdminBundle/Controller/ProductStatisticsAdminController.php
和过载 listAction()
来自 Sonata 的 CRUDController。在此操作中,您可以调用您的数据库并检索统计信息,然后使用您的模板呈现它们。<?php
namespace Acme\Bundle\DemoAdminBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class ProductStatisticsAdminController extends Controller
{
public function listAction()
{
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
//... use any methods or services to get statistics data
$statisticsData = ...
return $this->render('AcmeDemoAdminBundle:ProductStatistics:product_statistics.html.twig', array(
'statistics_data' => $statisticsData,
));
}
}
product_statistics.html.twig
在 Acme/Bundle/DemoAdminBundle/Resources/views/ProductStatistics/product_statistics.html.twig
中生成图形和显示统计信息{% extends base_template %}
{% block javascripts %}
{{ parent() }}
{# put links to javascript libraries here if you need any #}
{% endblock %}
{% block content %}
{# put some html code to display statistics data or use some javascript library to generate cool graphs #}
{% endblock %}
关于symfony - SonataAdminBundle : display non crud (statistics),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15966575/
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
我刚刚发现了这门语言,我想知道是否可以使用数据库制作基本的 CRUD 网络应用程序。 最佳答案 有 mysql 的库和 postgresql , 核心库提供了一个 web server支持 HTTP、
Symfony 4.0 发布后,不再支持 SensioGeneratorBundle .因此命令 php app/console generate:doctrine:crud不可用。 他们建议使用 M
在开发 Web 应用程序时,我通常会看到人们执行增删改查和同步 View 的两种方式。 这里是使用 ajax 的高级示例。 1-方法一 创建操作可能涉及 POST 请求,成功后只需执行另一个 GET
我已经成功地使用 Yii2 模型和 CRUD 生成器为我的网络应用程序获取了一些框架代码文件。特别是,CRUD Generator 声称已成功将其 View 文件创建到: /basic/views//
在我的项目中,我一直在使用 Django 的通用 CRUD View 来处理很多事情。我现在想开始迁移到 DJango 1.3 中基于类的新样式通用 CRUD View 。我没有发现这些文档有多大帮助
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题?通过 editing this post 添加详细信息并澄清问题. 7年前关闭。 Improve this
我希望标题不要太含糊,所以这里是: 我创建了一个 MySQL 数据库,其中存储了两个表:一个包含输入数据,另一个包含输出数据。 之后我编写了一个程序,连接到这个特定的数据库,从输入表中提取数据,解析它
我需要编辑我的实体以获得更多值。我已经用我之前的值生成了 crud。如何在编辑实体后通过应用程序/控制台重新生成 crud,以便它自动为其他值生成函数。 最佳答案 为此,您需要删除为此 crud 生成
因此,我仅使用 JavaScript 创建了一个简单的 CRUD 应用程序。现在,您可以将国家/地区添加到数组中并从数组中删除国家/地区。我希望能够编辑数组中的现有国家/地区,例如我想将“斯德哥尔摩”
我想让java中的一个类有一个可以与Hibernate配置交互并执行某些操作的方法,该方法被标识为ENUM(例如:读取,更新,添加,删除等) 方法参数应为(枚举操作、类 DTO、NamedQuery
我正在构建一个 React 应用程序,并使用 auth0 来登录/验证用户。 在使用 auth0 之前,我一直在对 API 进行 CRUD 调用来发布帖子。这又是在使用 auth0 之前、在我拥有用户
尝试使用 BlueJ 构建我的第一个 Java MySQL CRUD 应用程序。我可以运行该应用程序并将数据写入 MySQL 数据库。但是,当我运行搜索函数时,我得到了 Java .NullPoint
我正在试用 Microsoft Master Data Services,我想以编程方式将数据添加到数据库中。我开始获得模型/实体/成员结构,但我还不确定。如果您对此结构有很好的解释,请分享。 假设有
我正在尝试开发一个 Backbone Marionette 应用程序,我需要知道如何以最佳方式执行 CRUD(创建、读取、更新和销毁)操作。我找不到任何解释这一点的资源(仅适用于 Backbone)。
我已经根据文档和 medium article 模拟了与 Room 的多对多关系。 .使用这个@Relation,我可以从数据库中检索RecipeWithIngredients 或Ingredient
Closed. This question is opinion-based。它当前不接受答案。 想要改善这个问题吗?更新问题,以便editing this post用事实和引用来回答。 3年前关闭。
通过AngularJS通过REST进行CRUD操作的最佳实践是什么? 特别是这里的 Angular-Way 。我的意思是使用最少代码和最默认 Angular 设置来达到此目的的方式。 我知道$ res
我无法弄清楚我的更新功能。我能够从数据库中检索和删除,但我不知道如何更新。这对我来说是全新的,所以我很困惑。 .js 文件 //update user $("#btnUpdateUser").clic
我正在寻找一种对用户透明的 CRUD 操作后重新加载页面的方法。 实际上,在创建或删除之后,我必须重新加载页面才能显示我的操作。 我使用 api 来实现这个,当我将它与 json 文件一起使用时,它工
我是一名优秀的程序员,十分优秀!