Доктрина
доступна в composer.json
. Оба находятся в обязательном разделе.
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Config\Definition\Exception\Exception;
use AppBundle\Entity\AppConnector;
use AppBundle\Repository\AppConnectorRepository;
class AppController extends Controller {
public $s_mch = '';
public $s_headers = '';
public $s_data = '';
public $s_response = '';
public $o_results = '';
public $s_results = '';
public $s_url = '';
public $s_cid = '';
public $s_url_prefix = '';
public $s_url_suffix = '';
protected $s_user = '';
protected $s_apikey = '';
protected $s_server = '';
public $s_klant = '';
public $s_request_type = '';
/**
* @Route('/app-index')
*/
public function indexAction() {
}
public function returnObjectAction($klant='',$url_suffix='',$cid='',$request_type='GET') {
$this->s_klant = $klant;
$this->s_cid = $cid;
$this->s_url_suffix = $url_suffix;
$this->s_request_type = $request_type;
$klant_info = $this->getDoctrine()->getManager();
// ->getRepository(AppConnector::class)
// ->find($this->s_klant);
// if (!$klant_info) {
// throw $this->createNotFoundException(
// 'Geen informatie gevonden voor klant: '.$this->s_klant
// );
// }
/*
* 28 april 2018 - 9:10 AM
* --
*/
$this->s_url = 'https://' . $this->s_server . '.' . $this->s_url_suffix;
if($this->s_request_type == 'GET')
$s_mch = curl_init();
$s_headers = array(
'Content-Type: application/json',
'Authorization: Basic '.base64_encode($this->s_user . ':' . $this->s_apikey)
);
curl_setopt($s_mch, CURLOPT_URL, $this->s_url);
curl_setopt($s_mch, CURLOPT_HTTPHEADER, $s_headers);
curl_setopt($s_mch, CURLOPT_CUSTOMREQUEST, $this->s_request_type);
curl_setopt($s_mch, CURLOPT_TIMEOUT, 10);
curl_setopt($s_mch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($s_mch, CURLOPT_RETURNTRANSFER, 1);
if($this->s_request_type != 'GET') {
curl_setopt($s_mch, CURLOPT_POST, true);
curl_setopt($s_mch, CURLOPT_POSTFIELDS, json_encode($this->s_data) ); // send data in json
}
$this->s_response = curl_exec($s_mch);
if ($this->s_response === false) {
throw new Exception('curl_exec returned false: ' . trigger_error(curl_error($s_mch)));
}
$this->o_results = json_decode($this->s_response);
return $this->o_results;
}
}