-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Bukashk0zzz/symfony4
Refactoring
- Loading branch information
Showing
29 changed files
with
4,956 additions
and
877 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/* | ||
/vendor/ | ||
.php_cs.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR1' => true, | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'@PHP70Migration' => true, | ||
'@PHP70Migration:risky' => true, | ||
'@PHP71Migration' => true, | ||
'phpdoc_summary' => false, | ||
'yoda_style' => false, | ||
'self_accessor' => false, | ||
'combine_consecutive_unsets' => true, | ||
'blank_line_after_opening_tag' => false, | ||
'phpdoc_to_comment' => false, | ||
'phpdoc_no_empty_return' => false, | ||
'strict_param' => true, | ||
'doctrine_annotation_indentation' => true, | ||
'mb_str_functions' => true, | ||
'native_function_invocation' => true, | ||
'no_short_echo_tag' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'ordered_class_elements' => true, | ||
'phpdoc_add_missing_param_annotation' => true, | ||
'phpdoc_order' => true, | ||
'simplified_null_return' => false, | ||
'strict_comparison' => true, | ||
'ordered_imports' => ['sortAlgorithm' => 'alpha'], | ||
'declare_equal_normalize' => ['space' => 'single'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
'list_syntax' => ['syntax' => 'short'], | ||
'doctrine_annotation_braces' => ['syntax' => 'with_braces'], | ||
'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'created', 'version', 'package', 'copyright', 'license', 'throws']], | ||
]) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
language: php | ||
sudo: false | ||
|
||
php: | ||
- 7.1 | ||
|
||
env: | ||
- SYMFONY_VERSION="3.3.*" | ||
- SYMFONY_VERSION="4.0.*" | ||
|
||
before_script: | ||
- composer self-update | ||
- sed -i -e 's/^3.3|^4.0/${SYMFONY_VERSION}/g' composer.json; | ||
- composer install --dev --prefer-dist --no-interaction -o | ||
|
||
script: | ||
- ./vendor/bin/phpcs -p --standard=./ruleset.xml | ||
- ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml | ||
|
||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) | ||
|
||
cache: | ||
directories: | ||
- $COMPOSER_CACHE_DIR | ||
|
||
notifications: | ||
email: | ||
- [email protected] | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
<?php | ||
<?php declare(strict_types = 1); | ||
|
||
namespace AtlassianConnectBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
/** | ||
* Class AtlassianConnectBundle | ||
*/ | ||
class AtlassianConnectBundle extends Bundle | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,86 @@ | ||
<?php | ||
<?php declare(strict_types = 1); | ||
|
||
namespace AtlassianConnectBundle\Command; | ||
|
||
use AtlassianConnectBundle\Entity\TenantInterface; | ||
use AtlassianConnectBundle\Model\JWTRequest; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Doctrine\Common\Persistence\ManagerRegistry; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class RequestAPICommand extends ContainerAwareCommand | ||
/** | ||
* Class RequestAPICommand | ||
*/ | ||
class RequestAPICommand extends Command | ||
{ | ||
protected function configure() | ||
/** | ||
* @var bool | ||
*/ | ||
protected $shouldNotRun; | ||
|
||
/** | ||
* @var \Doctrine\ORM\EntityManager | ||
*/ | ||
private $em; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $tenantClass; | ||
|
||
/** | ||
* @param ManagerRegistry $registry | ||
* @param string $tenantClass | ||
*/ | ||
public function __construct(ManagerRegistry $registry, string $tenantClass) | ||
{ | ||
$this->em = $registry->getManager(); | ||
$this->tenantClass = $tenantClass; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName('ac:request-api') | ||
->addArgument('rest-url', InputArgument::REQUIRED, "REST api endpoint, like /rest/api/2/issue/{issueIdOrKey}") | ||
->addOption('client-key', "c", InputOption::VALUE_REQUIRED, "Client-key from tenant") | ||
->addOption('tenant-id', "t", InputOption::VALUE_REQUIRED, "Tenant-id") | ||
->setDescription('Request REST end-points. | ||
Documentation available on https://docs.atlassian.com/jira/REST/cloud/'); | ||
->addArgument('rest-url', InputArgument::REQUIRED, 'REST api endpoint, like /rest/api/2/issue/{issueIdOrKey}') | ||
->addOption('client-key', 'c', InputOption::VALUE_REQUIRED, 'Client-key from tenant') | ||
->addOption('tenant-id', 't', InputOption::VALUE_REQUIRED, 'Tenant-id') | ||
->setDescription('Request REST end-points. Documentation available on https://docs.atlassian.com/jira/REST/cloud/'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return void | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): void | ||
{ | ||
$restUrl = $input->getArgument('rest-url'); | ||
$em = $this->getContainer()->get('doctrine')->getManager(); | ||
$tenantClass = $this->getContainer()->getParameter("atlassian_connect_tenant_entity_class"); | ||
if($input->getOption("tenant-id")) { | ||
$tenant = $em->getRepository($tenantClass) | ||
->find($input->getOption("tenant-id")); | ||
} elseif($input->getOption("client-key")) { | ||
$tenant = $em->getRepository($tenantClass) | ||
->findOneByClientKey($input->getOption('client-key')); | ||
|
||
/** @var TenantInterface $tenant */ | ||
if ($input->getOption('tenant-id')) { | ||
$tenant = $this->em->getRepository($this->tenantClass)->find($input->getOption('tenant-id')); | ||
} elseif ($input->getOption('client-key')) { | ||
/** @noinspection PhpUndefinedMethodInspection */ | ||
$tenant = $this->em->getRepository($this->tenantClass)->findOneByClientKey($input->getOption('client-key')); | ||
} else { | ||
throw new \Exception("Please provide client-key or tenant-id"); | ||
throw new \RuntimeException('Please provide client-key or tenant-id'); | ||
} | ||
|
||
$request = new JWTRequest($tenant); | ||
$json = $request->get($restUrl); | ||
|
||
$output->writeln(''); | ||
print json_encode($json, JSON_PRETTY_PRINT); | ||
echo \json_encode($json, \JSON_PRETTY_PRINT); | ||
$output->writeln(''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
<?php | ||
<?php declare(strict_types = 1); | ||
|
||
namespace AtlassianConnectBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
class UnlicensedController extends Controller | ||
/** | ||
* Class UnlicensedController | ||
*/ | ||
class UnlicensedController | ||
{ | ||
public function unlicensedAction() | ||
/** | ||
* @var \Twig_Environment | ||
*/ | ||
private $twig; | ||
|
||
/** | ||
* @param \Twig_Environment $twig | ||
*/ | ||
public function __construct(\Twig_Environment $twig) | ||
{ | ||
$this->twig = $twig; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function unlicensedAction(): string | ||
{ | ||
return $this->render('@AtlassianConnect/unlicensed.html.twig'); | ||
return $this->twig->render('@AtlassianConnect/unlicensed.html.twig'); | ||
} | ||
} |
Oops, something went wrong.