nitra / e-commerce-site-storebundle
该软件包已被弃用,并且不再维护。没有建议的替代软件包。
Store Bundle
v2.0.0
2015-02-12 14:12 UTC
This package is auto-updated.
Last update: 2018-04-17 12:34:38 UTC
README
描述
主要电商平台插件。用于缓存商店数据、处理订单以及基本模板。
连接
为了在项目中连接此模块,需要以下步骤:
- composer.json:
{
...
"require": {
...
"nitra/e-commerce-site-storebundle": "dev-master",
...
}
...
}
- app/AppKernel.php:
<?php
//...
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
//...
public function registerBundles()
{
//...
$bundles = array(
//...
new Nitra\StoreBundle\NitraStoreBundle(),
//...
);
//...
return $bundles;
}
//...
}
配置
parameters.yml
- 订单完成时的电子邮件通知
- 经理 - send_email_order_manager: true|false
- 客户 - send_email_order_buyer: true|false
config.yml
#.....
nitra_store:
cart_products_group:
fields: []
anti_bot:
enabled: true
field_name: __antibot__
#.....
- cart_products_group - 设置购物车中商品的分组。要正确工作,分组字段必须是 必需的。
- fields - 分组的字段,默认不分组,指定为 fields: [ getModel, getColor ]
- anti_bot - 防止机器人设置
- enabled - 是否启用保护
- field_name - 隐藏字段的名称
如何在控制器中禁用特定 action 的防机器人保护
这可以通过添加注释 `@AntiBot(check=false)`
实现
示例
<?php
namespace Nitra\YourBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Nitra\StoreBundle\Annotations\AntiBot;
class DefaultController extends Controller
{
//...
/**
* @Route("/", name="index")
* @Template()
* @AntiBot(check=false)
*/
public function indexAction()
{
//...
return array();
}
//...
}
版本 2.0 的会话处理
为了在调用 get() 和 has() 函数时不创建会话,需要添加以下代码:
services.yml
parameters:
session.class: Nitra\StoreBundle\Session\Session
同样,为了使本地不使用会话,需要注释掉以下行
config.yml
lunetics_locale:
guessing_order:
- query
- router
#- session
- cookie
- browser