Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 520d8e29f028ce1907bee3ad36c97054f9cf53d7 @Seldaek Seldaek committed Aug 18, 2012
19 Controller/LogController.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Nelmio\JsLoggerBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+
+class LogController extends Controller
+{
+ public function createAction(Request $request)
+ {
+ if ($this->get('nelmio_js_logger.logger')->handle($request)) {
+ return new Response('OK', 201);
+ }
+
+ return new Response('', 400);
+ }
+}
44 DependencyInjection/Configuration.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Nelmio\JsLoggerBundle\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/extension.html#cookbook-bundles-extension-config-class}
+ */
+class Configuration implements ConfigurationInterface
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function getConfigTreeBuilder()
+ {
+ $treeBuilder = new TreeBuilder();
+ $rootNode = $treeBuilder->root('nelmio_js_logger');
+
+ $levels = array('DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY');
+ $levelsCI = array_merge($levels, array_map('strtolower', $levels));
+
+ $rootNode
+ ->children()
+ ->arrayNode('allowed_levels')
+ ->addDefaultsIfNotSet()
+ ->default($levels)
+ ->children()
+ ->validate()
+ ->ifNotInArray($levelsCI)
+ ->thenInvalid('The level %s is not supported. Please choose one of '.json_encode($levels))
+ ->end()
+ ->end()
+ ->cannotBeEmpty()
+ ->end()
+ ->end()
+ ;
+
+ return $treeBuilder;
+ }
+}
31 DependencyInjection/NelmioJsLoggerExtension.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Nelmio\JsLoggerBundle\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
+ *
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
+ */
+class NelmioJsLoggerExtension extends Extension
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function load(array $configs, ContainerBuilder $container)
+ {
+ $configuration = new Configuration();
+ $config = $this->processConfiguration($configuration, $configs);
+
+ // TODO
+ $container->setParameter('nelmio_js_logger.allowed_levels', array());
+
+ $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('services.xml');
+ }
+}
9 NelmioJsLoggerBundle.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Nelmio\JsLoggerBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class NelmioJsLoggerBundle extends Bundle
+{
+}
10 Resources/config/routing.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<routes xmlns="http://symfony.com/schema/routing"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
+
+ <route id="NelmioJsLoggerBundle_log" pattern="/logs">
+ <default key="_controller">NelmioJsLoggerBundle:Log:create</default>
+ </route>
+</routes>
18 Resources/config/services.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <parameters>
+ <parameter key="nelmio_js_monolog.logger.class">Nelmio\JsLoggerBundle\Logger</parameter>
+ </parameters>
+
+ <services>
+ <service id="nelmio_js_monolog.logger" class="%nelmio_js_monolog.logger.class%">
+ <argument type="service" id="logger" />
+ <argument>%nelmio_js_monolog.allowed_levels%</argument>
+ <tag name="monolog.logger" channel="frontend" />
+ </service>
+ </services>
+</container>
24 composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "nelmio/js-logger-bundle",
+ "description": "Adds logging of JS errors in your Symfony2 application",
+ "keywords": ["js", "javascript", "logging", "log"],
+ "type": "symfony-bundle",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Nelmio",
+ "homepage": "http://nelm.io"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors"
@stof
stof Aug 20, 2012

looks weird :)

+ }
+ ],
+ "require": {
+ "symfony/framework-bundle": ">=2.1,<2.2-dev"
+ },
+ "autoload": {
+ "psr-0": { "Nelmio\\JsLoggerBundle": "" }
+ },
+ "target-dir": "Nelmio/JsLoggerBundle"
+}

0 comments on commit 520d8e2

Please sign in to comment.