Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Oct 9, 2020
1 parent 4e3d430 commit 225ee04
Show file tree
Hide file tree
Showing 13 changed files with 491 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vendor/aldaflux/sirene-api-bundle/AldafluxSireneApiBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aldaflux\SireneApiBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AldafluxSireneApiBundle extends Bundle
{

}
14 changes: 14 additions & 0 deletions vendor/aldaflux/sirene-api-bundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Aldaflux\SireneApiBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class DefaultController extends Controller
{



}

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Aldaflux\SireneApiBundle\DataCollector;

use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class RequestCollector extends DataCollector implements DataCollectorInterface
{

private $container;

/**
* Constructor.
*
* We don't inject the message logger and mailer here
* to avoid the creation of these objects when no emails are sent.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function __construct()
{
// $this->container = $container;
}
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = [
'method' => $request->getMethod(),
'acceptable_content_types' => $request->getAcceptableContentTypes(),
];
}

public function reset()
{
$this->data = [];
}

public function getName()
{
return 'aldaflux_sirene_api.request_collector';
}


public function getMethod()
{
return $this->data['method'];
}

public function LogCount()
{
return 666;
}

public function getAcceptableContentTypes()
{
return $this->data['acceptable_content_types'];
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Aldaflux\SireneApiBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration.
*
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
*/
class AldafluxSireneApiExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);


$container->setParameter('sirene_key', $config['credentials']["sirene_key"]);
$container->setParameter('sirene_secret', $config['credentials']["sirene_secret"]);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Aldaflux\SireneApiBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();

$rootNode = $treeBuilder->root('aldaflux_sirene_api');

$rootNode
->children()
->arrayNode('credentials')
->children()
->scalarNode('sirene_key')->end()
->scalarNode('sirene_secret')->end()
->end()
->end() // twitter
->end()
;
return $treeBuilder;

// $treeBuilder = new TreeBuilder();

/*
$treeBuilder = new TreeBuilder('aldaflux_sirene_api');
$treeBuilder->getRootNode()
->children()
->arrayNode('credentials')
->children()
->scalarNode('sirene_key')->end()
->scalarNode('sirene_secret')->end()
->end()
->end() // twitter
->end()
;
return $treeBuilder;
*
*/
}
}
75 changes: 75 additions & 0 deletions vendor/aldaflux/sirene-api-bundle/Form/Type/SiretType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Aldaflux\SireneApiBundle\Form\Type;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Exception\TransformationFailedException;

use Symfony\Component\Form\CallbackTransformer;


use Symfony\Component\Form\FormBuilderInterface;


class SiretType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(['empty_data' => '','required'=>false, 'invalid_message'=>"Le SIRET n'est pas valide" ]);
}

public function getParent()
{
return TextType::class;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->addModelTransformer(new CallbackTransformer(
function ($data) {
if ($data)
{
$data=str_replace(" ","", $data);
}
else {return("");}
},
function ($data) {
if ($data)
{
$data=str_replace(" ","", $data);
if (is_numeric($data))
{
if (strlen($data)==14)
{
return($data);
}
else
{
$privateErrorMessage = "Le Siret doit être composé de 14 chiffres";
$publicErrorMessage = "Le Siret doit être composé de 14 chiffres";
$failure = new TransformationFailedException($privateErrorMessage);
$failure->setInvalidMessage($publicErrorMessage, ['{{ value }}' => $issueNumber,]);
throw $failure;
}
}
else
{
$privateErrorMessage = "Le SIRET doit être composé de chiffre";
$publicErrorMessage = "Le SIRET doit être composé de chiffre";
$failure = new TransformationFailedException($privateErrorMessage);
throw $failure;
}

}
else
{
return "";
}
}
));
}
}
6 changes: 6 additions & 0 deletions vendor/aldaflux/sirene-api-bundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# sirene api
Have a confirmation window before link




21 changes: 21 additions & 0 deletions vendor/aldaflux/sirene-api-bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
sirene-api.sirene_service:
class: Aldaflux\SireneApiBundle\Service\SireneApiService
public: true
autowire: true
autoconfigure: true
arguments:
$container: "@service_container"
Aldaflux\SireneApiBundle\Service\SireneApiService: '@sirene-api.sirene_service'


sirene-api.data_collector:
class: Aldaflux\SireneApiBundle\DataCollector\RequestCollector
tags:
-
name: data_collector
template: '@AldafluxSireneApi/Collector/sirene_collector.html.twig'
id: 'aldaflux_sirene_api.request_collector'
public: false


Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">

<g class="layer">
<title>Layer 1</title>
<rect id="svg_1" fill="#750500" height="51.2" width="281.6" y="384.853" x="115.2"/>
<path id="svg_2" fill="#490000" d="m140.8,384.87l0,-140.8c0,-63.522 51.67799,-115.2 115.2,-115.2s115.20001,51.67801 115.20001,115.2l0,140.8l-230.40001,0z"/>
<g id="svg_3">
<path id="svg_4" fill="#e5e5e5" d="m384,372.07001l0,-128c0,-70.57901 -57.42099,-128 -128,-128s-128,57.42101 -128,128l0,128c-14.14,0 -25.6,11.45999 -25.6,25.60001l0,25.60001c0,14.13998 11.46,25.59998 25.6,25.59998l256,0c14.14001,0 25.60001,-11.45999 25.60001,-25.59998l0,-25.60001c0,-14.13901 -11.45999,-25.60001 -25.60001,-25.60001zm-230.39999,-128c0,-56.55899 45.84999,-102.39999 102.39999,-102.39999s102.40002,45.841 102.40002,102.39999l0,128l-204.80002,0l0,-128zm230.39999,179.19998l-256,0l0,-25.60001l256,0l0,25.60001z"/>
<path id="svg_5" fill="#e5e5e5" d="m76.8,244.07001c0,-49.408 20.096,-94.20799 52.548,-126.652l-18.091,-18.091c-37.08501,37.07799 -60.057,88.27798 -60.057,144.743c0,38.50201 10.88,74.41901 29.431,105.22501l21.922,-13.14999c-16.238,-26.95703 -25.753,-58.38501 -25.753,-92.07501z"/>
<path id="svg_6" fill="#e5e5e5" d="m400.75101,99.319l-18.091,18.091c32.444,32.452 52.54001,77.252 52.54001,126.66c0,33.69 -9.51501,65.11798 -25.74503,92.07498l21.92203,13.15002c18.543,-30.80502 29.42297,-66.73102 29.42297,-105.22501c0,-56.46501 -22.97198,-107.66501 -60.04898,-144.75101z"/>
<path id="svg_7" fill="#e5e5e5" d="m436.93201,63.13l-18.099,18.099c41.728,41.719 67.56702,99.31901 67.56702,162.842c0,43.31499 -12.237,83.72899 -33.10901,118.37401l21.922,13.15799c23.19299,-38.50198 36.78699,-83.405 36.78699,-131.53299c0,-70.58701 -28.70599,-134.58701 -75.06799,-180.94001z"/>
<path id="svg_8" fill="#e5e5e5" d="m93.158,81.229l-18.09,-18.099c-46.362,46.353 -75.068,110.353 -75.068,180.94001c0,48.12799 13.594,93.03 36.779,131.53299l21.922,-13.15799c-20.864,-34.65402 -33.101,-75.06799 -33.101,-118.375c0,-63.522 25.839,-121.12201 67.558,-162.84101z"/>
</g>
<g id="svg_9"/>
<g id="svg_10"/>
<g id="svg_11"/>
<g id="svg_12"/>
<g id="svg_13"/>
<g id="svg_14"/>
<g id="svg_15"/>
<g id="svg_16"/>
<g id="svg_17"/>
<g id="svg_18"/>
<g id="svg_19"/>
<g id="svg_20"/>
<g id="svg_21"/>
<g id="svg_22"/>
<g id="svg_23"/>
</g>
</svg>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
{% set icon %}
{% include('@AldafluxSireneApi/Collector/icons/insee.html.twig') %}
<span class="sf-toolbar-value">SIRENE</span>
{% endset %}

{% set text %}
{# this is the content displayed when hovering the mouse over
the toolbar panel #}
<div class="sf-toolbar-info-piece">
<b>Method</b>
<span>{{ collector.method }}</span>
</div>

<div class="sf-toolbar-info-piece">
<b>Accepted content type</b>
<span>{{ collector.acceptableContentTypes|join(', ') }}</span>
</div>
{% endset %}

{{ include('@WebProfiler/Profiler/toolbar_item.html.twig') }}
{% endblock %}


{% block menu %}
{% set profiler_markup_version = profiler_markup_version|default(1) %}

<span class="label ">

<span class="icon">
{% include('@AldafluxSireneApi/Collector/icons/insee.html.twig') %}
</span>
<strong>Siren</strong>
<span class="count">
<span>{{collector.LogCount}}</span>
</span>
</span>
{% endblock %}

{% block panel %}
{% set profiler_markup_version = profiler_markup_version|default(1) %}

{% if profiler_markup_version == 1 %}
<style>
h3 { margin-top: 2em; }
h3 span { color: #999; font-weight: normal; }
h3 small { color: #999; }
h4 { font-size: 14px; font-weight: bold; }
.card { background: #F5F5F5; margin: .5em 0 1em; padding: .5em; }
.card .label { display: block; font-size: 13px; font-weight: bold; margin-bottom: .5em; }
.card .card-block { margin-bottom: 1em; }
</style>
{% endif %}

<h2>Siren</h2>
<div class="empty">
<p>There are no IDS logs .</p>
</div>



</div>
{% endblock %}

Loading

0 comments on commit 225ee04

Please sign in to comment.