declare(strict_types = 1);
namespace App\Controller;
use AtlassianConnectBundle\Service\AtlassianRestClient;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
* @Route("/protected")
*/
class ProtectedController extends Controller
{
/**
* @Route("/", name="main")
*/
public function index()
{
$client = $this->container->get(AtlassianRestClientInterface::class);
// Or
// $client = $this->container->get('atlassian_connect_rest_client');
// If you are not in a security context fetch the tenant first
// $client->setTenant($tenant);
// If you want to impersonate the user
// $client->actAsUser($this->getUser()->getUserName())
// Send request from anonymous plugin user
$issue = $client->get('/rest/api/2/issue/KEY-XXX');
// Send request from choosen user
$user = $client
->setUser('5ds4e4352a12451789b13243') // the accountId of the user in Jira/Confluence etc.
->get('/rest/api/2/myself')
;
return new Response([$issue, $user]);
}
}
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AtlassianConnectBundle\Entity\TenantTrait;
use AtlassianConnectBundle\Entity\TenantInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* JiraTenant
*
* @ORM\Table()
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity()
*/
class JiraTenant implements UserInterface, TenantInterface
{
/**
* @ORM\OneToMany(type="MyEntity", mappedBy="jiraTenant")
*/
protected $myEntities;
use TenantTrait;
// getters/setters for your custom properties
}