Skip to content

Commit

Permalink
[MOD] init bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
lcp0578 committed Aug 25, 2017
1 parent e9e4565 commit 0a194f2
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## zend studio
/.settings
/.buildpath
/.project
13 changes: 13 additions & 0 deletions Controller/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Kit\FormBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
public function indexAction()
{
return $this->render('KitFormBundle:Default:index.html.twig');
}
}
29 changes: 29 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Kit\FormBundle\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('kit_form');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.

return $treeBuilder;
}
}
28 changes: 28 additions & 0 deletions DependencyInjection/KitFormExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Kit\FormBundle\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 KitFormExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
22 changes: 22 additions & 0 deletions Form/Type/FulltextType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Kit\FormBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;

class FulltextType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'width' => '100%',
'height' => '240px'
));
}

public function getParent()
{
return TextareaType::class;
}
}
9 changes: 9 additions & 0 deletions KitFormBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Kit\FormBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class KitFormBundle extends Bundle
{
}
3 changes: 3 additions & 0 deletions Resources/config/routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kit_form_homepage:
path: /
defaults: { _controller: KitFormBundle:Default:index }
4 changes: 4 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
# kit_form.example:
# class: Kit\FormBundle\Example
# arguments: ["@service_id", "plain_value", "%parameter%"]
1 change: 1 addition & 0 deletions Resources/views/Default/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
17 changes: 17 additions & 0 deletions Tests/Controller/DefaultControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Kit\FormBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();

$crawler = $client->request('GET', '/');

$this->assertContains('Hello World', $client->getResponse()->getContent());
}
}

0 comments on commit 0a194f2

Please sign in to comment.