dlin/saasu-bundle

使用 Saasu PHP 客户端库的 Saasu 2 Bundle for Syfmony

v1.0.2 2013-12-02 01:04 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:24:55 UTC


README

Dlin Saasu Bundle 是用于 Saasu PHP 客户端库的 Symfony2 包装器包。有关详细用法,请参阅文档。

此 Saasu Bundle 提供一个可配置的服务,用于与 Saasu 一起工作。

安装

使用 Composer 安装

将以下内容添加到您的 composer.json

json
{
    "require" :  {
        "dlin/saasu-bundle": "dev-master"
    }
}

在 AppKernel.php 中启用该包

public function registerBundles()
{
    $bundles = array(
    ...
    new Dlin\Bundle\SaasuBundle\DlinSaasuBundle(),
    ...
}

配置

例如

#app/config/config.yml

dlin_saasu:
    wsaccesskey: D4A92597762C4FDCAF66FF03C988B7B2
    file_uid: 41555

用法

在控制器中获取服务

$service =  $this->get('dlin.saasu_service');

在 ContainerAwareService 中获取服务

$service = $this->container->get('dlin.saasu_service');

该服务提供一个方法,用于返回 Dlin\Saasu\SaasuAPI 实例,有关详细示例,请参阅 Saasu PHP Client 库。

$api = $service->getApi();

调用 Saasu 网络服务 API 可能会很慢。如果您不需要从服务中立即得到结果,您可以通过延迟执行任务来提高用户体验。

例如,如果您只想在 Saasu 中创建发票并且不需要立即响应(发票 ID 或任何错误),您可以通过延迟执行任务来提高用户体验。

//get the service
$service =  $this->get('dlin.saasu_service');

//create an invoice object
$invoice = new Invoice();

//populate invoice with data
$invoice->transactionType = 'S';
...
//This will create the Invoice straightaway, user will experience minor delay
$service->getApi()->saveEntity($invoice);

//This will postpone Invoice creation till HTTP respond is sent to user
$service->schedule('saveEntity', $invoice);

这在创建、更新或删除实体时非常有用,尽管所有 API 方法都可以以类似方式延迟。如果您愿意,可以执行延迟/计划搜索或加载,但结果无法访问,因此没有用。

以下是一个计划删除发票的示例

$service->schedule('deleteEntity', $invoice);

许可证

MIT

免费软件,是的!