添加网站文件
This commit is contained in:
64
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/Controller/QrCodeController.php
vendored
Normal file
64
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/Controller/QrCodeController.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Bundle\QrCodeBundle\Controller;
|
||||
|
||||
use Endroid\QrCode\Factory\QrCodeFactory;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* QR code controller.
|
||||
*/
|
||||
class QrCodeController extends Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param string $text
|
||||
* @param string $extension
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function generateAction(Request $request, $text, $extension)
|
||||
{
|
||||
$options = $request->query->all();
|
||||
|
||||
$qrCode = $this->getQrCodeFactory()->create($text, $options);
|
||||
$qrCode->setWriterByExtension($extension);
|
||||
|
||||
return new Response($qrCode->writeString(), Response::HTTP_OK, ['Content-Type' => $qrCode->getContentType()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function twigFunctionsAction()
|
||||
{
|
||||
if (!$this->has('twig')) {
|
||||
throw new \LogicException('You can not use the "@Template" annotation if the Twig Bundle is not available.');
|
||||
}
|
||||
|
||||
$param = [
|
||||
'message' => 'QR Code',
|
||||
];
|
||||
|
||||
$renderedView = $this->get('twig')->render('@EndroidQrCode/QrCode/twigFunctions.html.twig', $param);
|
||||
|
||||
return new Response($renderedView, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return QrCodeFactory
|
||||
*/
|
||||
protected function getQrCodeFactory()
|
||||
{
|
||||
return $this->get('endroid.qrcode.factory');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Bundle\QrCodeBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class WriterRegistryCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->has('endroid.qrcode.writer_registry')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$writerRegistryDefinition = $container->findDefinition('endroid.qrcode.writer_registry');
|
||||
|
||||
$taggedServices = $container->findTaggedServiceIds('endroid.qrcode.writer');
|
||||
foreach ($taggedServices as $id => $tags) {
|
||||
foreach ($tags as $attributes) {
|
||||
$writerRegistryDefinition->addMethodCall('addWriter', [new Reference($id), isset($attributes['set_as_default']) && $attributes['set_as_default']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
77
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/DependencyInjection/Configuration.php
vendored
Normal file
77
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/DependencyInjection/Configuration.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Bundle\QrCodeBundle\DependencyInjection;
|
||||
|
||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||
use Endroid\QrCode\LabelAlignment;
|
||||
use Predis\Response\Error;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
|
||||
$treeBuilder
|
||||
->root('endroid_qr_code')
|
||||
->children()
|
||||
->scalarNode('writer')->end()
|
||||
->integerNode('size')->min(0)->end()
|
||||
->integerNode('margin')->min(0)->end()
|
||||
->scalarNode('encoding')->defaultValue('UTF-8')->end()
|
||||
->scalarNode('error_correction_level')
|
||||
->validate()
|
||||
->ifNotInArray(ErrorCorrectionLevel::toArray())
|
||||
->thenInvalid('Invalid error correction level %s')
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('foreground_color')
|
||||
->children()
|
||||
->scalarNode('r')->isRequired()->end()
|
||||
->scalarNode('g')->isRequired()->end()
|
||||
->scalarNode('b')->isRequired()->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('background_color')
|
||||
->children()
|
||||
->scalarNode('r')->isRequired()->end()
|
||||
->scalarNode('g')->isRequired()->end()
|
||||
->scalarNode('b')->isRequired()->end()
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('logo_path')->end()
|
||||
->integerNode('logo_width')->end()
|
||||
->scalarNode('label')->end()
|
||||
->integerNode('label_font_size')->end()
|
||||
->scalarNode('label_font_path')->end()
|
||||
->scalarNode('label_alignment')
|
||||
->validate()
|
||||
->ifNotInArray(LabelAlignment::toArray())
|
||||
->thenInvalid('Invalid label alignment %s')
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('label_margin')
|
||||
->children()
|
||||
->scalarNode('t')->end()
|
||||
->scalarNode('r')->end()
|
||||
->scalarNode('b')->end()
|
||||
->scalarNode('l')->end()
|
||||
->end()
|
||||
->end()
|
||||
->booleanNode('validate_result')->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
34
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/DependencyInjection/EndroidQrCodeExtension.php
vendored
Normal file
34
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/DependencyInjection/EndroidQrCodeExtension.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Bundle\QrCodeBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
class EndroidQrCodeExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(), $configs);
|
||||
|
||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
|
||||
$factoryDefinition = $container->getDefinition('endroid.qrcode.factory');
|
||||
$factoryDefinition->replaceArgument(0, $config);
|
||||
}
|
||||
}
|
||||
27
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/EndroidQrCodeBundle.php
vendored
Normal file
27
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/EndroidQrCodeBundle.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Jeroen van den Enden <info@endroid.nl>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Endroid\QrCode\Bundle\QrCodeBundle;
|
||||
|
||||
use Endroid\QrCode\Bundle\QrCodeBundle\DependencyInjection\Compiler\WriterRegistryCompilerPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class EndroidQrCodeBundle extends Bundle
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container->addCompilerPass(new WriterRegistryCompilerPass());
|
||||
}
|
||||
}
|
||||
11
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/Resources/config/routing.yml
vendored
Normal file
11
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/Resources/config/routing.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
endroid_qrcode_generate:
|
||||
path: /{text}.{extension}
|
||||
requirements:
|
||||
text: "[\\w\\W]+"
|
||||
defaults:
|
||||
_controller: EndroidQrCodeBundle:QrCode:generate
|
||||
|
||||
endroid_qrcode_twig_functions:
|
||||
path: /twig
|
||||
defaults:
|
||||
_controller: EndroidQrCodeBundle:QrCode:twigFunctions
|
||||
31
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/Resources/config/services.yml
vendored
Normal file
31
vendor/endroid/qr-code/src/Bundle/QrCodeBundle/Resources/config/services.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
services:
|
||||
endroid.qrcode.factory:
|
||||
class: Endroid\QrCode\Factory\QrCodeFactory
|
||||
arguments: [ null, '@endroid.qrcode.writer_registry' ]
|
||||
endroid.qrcode.twig.extension:
|
||||
class: Endroid\QrCode\Twig\Extension\QrCodeExtension
|
||||
arguments: [ '@endroid.qrcode.factory', '@router']
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
endroid.qrcode.writer_registry:
|
||||
class: Endroid\QrCode\WriterRegistry
|
||||
endroid.qrcode.writer.binary_writer:
|
||||
class: Endroid\QrCode\Writer\BinaryWriter
|
||||
tags:
|
||||
- { name: endroid.qrcode.writer }
|
||||
endroid.qrcode.writer.debug_writer:
|
||||
class: Endroid\QrCode\Writer\DebugWriter
|
||||
tags:
|
||||
- { name: endroid.qrcode.writer }
|
||||
endroid.qrcode.writer.eps_writer:
|
||||
class: Endroid\QrCode\Writer\EpsWriter
|
||||
tags:
|
||||
- { name: endroid.qrcode.writer }
|
||||
endroid.qrcode.writer.png_writer:
|
||||
class: Endroid\QrCode\Writer\PngWriter
|
||||
tags:
|
||||
- { name: endroid.qrcode.writer, set_as_default: true }
|
||||
endroid.qrcode.writer.svg_writer:
|
||||
class: Endroid\QrCode\Writer\SvgWriter
|
||||
tags:
|
||||
- { name: endroid.qrcode.writer }
|
||||
@@ -0,0 +1,3 @@
|
||||
<img src="{{ qrcode_path(message) }}" />
|
||||
<img src="{{ qrcode_url(message, { writer: 'svg' }) }}" />
|
||||
<img src="{{ qrcode_data_uri(message, { writer: 'svg', size: 150 }) }}" />
|
||||
Reference in New Issue
Block a user