maillotf/ardaccess-bridge-bundle

适用于 Symfony 的 ARD 访问包

1.0.2 2020-10-28 14:52 UTC

This package is auto-updated.

Last update: 2024-09-14 21:49:08 UTC


README

Software license Latest stable Packagist PHP Version Support

基于用户名和密码认证的 ARD 访问 REST 客户端的 Symfony 扩展包

文档

所需配置

修改 framework.yaml

ardaccess:
    authentication:
        protocol: "http"
        host: "127.0.0.1"
        port: "80"
        username: "USERNAME"
        password: "PASSWORD"

修改 services.yaml

services:
    MaillotF\Ardaccess\ArdaccessBridgeBundle\Service\ArdaccessService: '@ardaccess.service'

使用 composer 安装包

$ composer require maillotf/ardaccess-bridge-bundle

在控制器中使用

<?php
//...
use MaillotF\Ardaccess\ArdaccessBridgeBundle\Service\ArdaccessService;

class exampleController extends AbstractController
{
	/**
	 * Example
	 * 
	 * @Route("example", name="example", methods={"GET"})
	 * 
	 */
	public function test(ArdaccessService $aas)
	{
		//List of the carriers
		$carriersList = $aas->carrier->ListCarriers();
		
		//Update a carrier
		$apiAttributes = $aas->creator
				->addAttribute('uid', 6078)
				->addAttribute('rid', 794)
				->addAttribute('firstname', 'Jean')
				->addAttribute('lastname', 'Dupont')
				->addAttribute('usergroup', '171,233')
				->addAttribute('begindate', 946681200)
				->addAttribute('enddate', 1627602000)
				->addAttribute('country', 'France')
				->getAttributes();
		$attributes = $aas->carrier->Carrier(null, 'u', $apiAttributes);

		//Search with criterion
		$criterions = $aas->creator
					->newCriterion('date', '>', 946681200)
						->addSubCriterion('example', '=', 'value')
					->addCriterion()
					->newCriterion('...', '=', '...')
					->addCriterion()
					->getCriterionsArray()
					;
		$result = $aas->supervision->ListEvents(null, $criterions);

		//Handback a smartobject
		$smartobjectId = 2;
		$success = $aas->getSmartObjectHelper()->handbackSmartObject($smartObjectId);
		if ($success === true)
			return ($this->json('OK'));
		return ($this->json('Not Found', Response::HTTP_BAD_REQUEST));
	}

}