-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Commit
- Loading branch information
0 parents
commit 5b6011e
Showing
17 changed files
with
1,226 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
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 @@ | ||
* @nextbox-dev/neos-developer |
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,21 @@ | ||
name: Create new version | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@586e1a624db6a5a4ac2c53daeeded60c5e3d50fe | ||
with: | ||
app_id: ${{ secrets.TOKEN_APP_ID }} | ||
private_key: ${{ secrets.TOKEN_APP_PRIVATE_KEY }} | ||
|
||
- name: Create Release | ||
uses: google-github-actions/release-please-action@v3 | ||
with: | ||
command: manifest | ||
token: ${{ steps.generate_token.outputs.token }} |
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,26 @@ | ||
name: Format (PHP) | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
php-cs-fixer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 | ||
with: | ||
app_id: ${{ secrets.TOKEN_APP_ID }} | ||
private_key: ${{ secrets.TOKEN_APP_PRIVATE_KEY }} | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
token: ${{ steps.generate_token.outputs.token }} | ||
|
||
- name: Run PHP CS Fixer | ||
uses: oskarstark/php-cs-fixer-ga@1b312141100e6b0800d5df42f73016e680c60669 | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a | ||
with: | ||
commit_message: 'fix: Apply php-cs-fixer changes' |
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,2 @@ | ||
.idea/ | ||
.php-cs-fixer.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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in('.') | ||
->name('*.php'); | ||
|
||
$config = new PhpCsFixer\Config(); | ||
return $config | ||
->setRules([ | ||
'@PSR12' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'ordered_imports' => ['sort_algorithm' => 'alpha'], | ||
'@PHP81Migration' => true, | ||
'no_empty_statement' => true, | ||
'no_unused_imports' => true, | ||
'no_trailing_comma_in_singleline_array' => true, | ||
'modernize_strpos' => true, | ||
'fully_qualified_strict_types' => true, | ||
'heredoc_indentation' => [ | ||
'indentation' => 'same_as_start' | ||
], | ||
]) | ||
->setRiskyAllowed(true) | ||
->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,3 @@ | ||
{ | ||
".": "0.0.1" | ||
} |
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,68 @@ | ||
<?php | ||
namespace NextBox\Neos\QrCode\Command; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Cli\CommandController; | ||
use Neos\Flow\Persistence\PersistenceManagerInterface; | ||
use NextBox\Neos\QrCode\Services\QrCodeService; | ||
|
||
class QrCodeCommandController extends CommandController | ||
{ | ||
/** | ||
* @Flow\Inject | ||
* @var QrCodeService | ||
*/ | ||
protected $qrCodeService; | ||
|
||
/** | ||
* @Flow\Inject() | ||
* @var PersistenceManagerInterface | ||
*/ | ||
protected $persistenceManager; | ||
|
||
/** | ||
* Generate a new qr code if it is missing | ||
* Force remove the existing qr code if the argument `force` is set | ||
* | ||
* @param string $shortIdentifier the value of the short identifier | ||
* @param string $shortType the definition in the settings | ||
* @param bool $force overwrite an existing image | ||
* @return void | ||
*/ | ||
public function generateCommand(string $shortIdentifier, string $shortType = 'default', bool $force = false): void | ||
{ | ||
$resource = $this->qrCodeService->getFile($shortIdentifier, $shortType); | ||
|
||
if ($resource && !$force) { | ||
$this->output->outputLine('<comment>There is an image already existing. Use --force to overwrite this image and create a new one.</comment>'); | ||
} else { | ||
if ($force) { | ||
$this->qrCodeService->deleteFile($shortIdentifier, $shortType); | ||
$this->output->outputLine('<comment>The qr-code was force removed</comment>'); | ||
$this->persistenceManager->persistAll(); | ||
} | ||
|
||
// ToDo: Uri has `/./` after the TLD | ||
$this->qrCodeService->generateAndSendToUri($shortIdentifier, $shortType); | ||
$this->output->outputLine('<success>The qr-code with the `url-short-identifier` ' . $shortIdentifier . ' was created successfully.</success>'); | ||
} | ||
} | ||
|
||
/** | ||
* Delete a qr-code resource | ||
* | ||
* @param string $shortIdentifier the value of the short identifier | ||
* @param string $shortType | ||
* @return void | ||
*/ | ||
public function removeCommand(string $shortIdentifier, string $shortType = 'default'): void | ||
{ | ||
$state = $this->qrCodeService->deleteFile($shortIdentifier, $shortType); | ||
|
||
if ($state) { | ||
$this->output->outputLine('<success>The qr-code with the `short-identifier` ' . $shortIdentifier . ' was removed successfully.</success>'); | ||
} else { | ||
$this->output->outputLine('<error>Can not find a qr-code with the `short-identifier` ' . $shortIdentifier . '</error>'); | ||
} | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
namespace NextBox\Neos\QrCode\Controller; | ||
|
||
use Neos\ContentRepository\Domain\Model\NodeInterface; | ||
use Neos\ContentRepository\Exception\PageNotFoundException; | ||
use Neos\Flow\Mvc\Controller\ActionController; | ||
use Neos\Flow\Mvc\Exception\StopActionException; | ||
use Neos\Neos\Service\LinkingService; | ||
use NextBox\Neos\QrCode\Services\QrCodeService; | ||
use Neos\Flow\Annotations as Flow; | ||
use NextBox\Neos\UrlShortener\Services\RedirectService; | ||
|
||
class QrCodeController extends ActionController | ||
{ | ||
/** | ||
* @Flow\Inject | ||
* @var QrCodeService | ||
*/ | ||
protected $qrCodeService; | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var RedirectService | ||
*/ | ||
protected $redirectService; | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var LinkingService | ||
*/ | ||
protected $linkingService; | ||
|
||
/** | ||
* @param string $shortIdentifier | ||
* @return void | ||
* @throws PageNotFoundException | ||
* @throws StopActionException | ||
*/ | ||
public function generateQrCodeAction(string $shortIdentifier, string $shortType = 'default'): void | ||
{ | ||
$documentNode = $this->redirectService->getNodeByShortIdentifierAndType($shortIdentifier, $shortType); | ||
|
||
if (!$documentNode instanceof NodeInterface) { | ||
throw new PageNotFoundException(); | ||
} | ||
|
||
$resource = $this->qrCodeService->getQrCodeResource($this->redirectService->createShortUri($shortIdentifier, $shortType), $shortIdentifier, $shortType); | ||
|
||
$this->response->setContentType('image/png'); | ||
$this->response->setHttpHeader('Content-disposition', 'inline; filename="qrcode_' . $shortIdentifier . '_' . ($documentNode->getProperty('title') ?: '') . '.png"'); | ||
$this->response->setHttpHeader('Content-Control', 'public, must-revalidate, max-age=0'); | ||
$this->response->setHttpHeader('Pragma', 'public'); | ||
$this->response->setHttpHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT'); | ||
$this->response->setContent($resource->getStream()); | ||
- | ||
throw new StopActionException(); | ||
} | ||
} |
Oops, something went wrong.