2017 © Pedro Peláez
 

symfony-bundle ssa-bundle

ssa bundle for use ssa framework into Symfony

image

ssa/ssa-bundle

ssa bundle for use ssa framework into Symfony

  • Saturday, September 6, 2014
  • by deblockt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

SSA Symfony bundle

Ssa is a framework for access to your php service in your javascript code. This project is the ssa integration on symfony 2. Ssa project, (*1)

Installation

Ssa bundle installation is very simple, you need just to add composer dependency., (*2)

composer.json, (*3)

"require": {
  "ssa/ssa-bundle" : "dev-master",
}

If composer say "ssa/core" not found add this line in your composer file : composer.json, (*4)

"require": {
  "ssa/core" : "dev-master",
}

Add the bundle in your kernel :, (*5)

new Ssa\SsaBundle\SsaBundle()

Add the ssa routing in your routing.yml, (*6)

routing.yml, (*7)

_ssa:
    resource: "@SsaBundle/Resources/config/routing.yml"

After you can register your services into config.yml, (*8)

config.yml, (*9)

ssa :
    services :
        # serviceName is the ssa service name
        # service : is the symfony serivce
        serviceName : {service : 'ssa.test.service'}
        # or you can just export any methods of this service
        serviceName2 : {service : 'ssa.test.service', methods : ['methodToImport']}
        # if your service is not a symfony service you can use the class attribute
        serviceName3 : {class : '\Path\To\Your\Class', methods : ['methodToImport']}      

And you can Simply import the javascript service with assetic, like this :, (*10)

file.html.twig, (*11)

{% javascripts 
    'ssa:serviceName'
    'ssa:serviceName1'
    'ssa:serviceName2'
%}
<script type="text/javascript" src="{{asset_url }}"></script>
{% endjavascripts  %}

you can now simply call your php service into your javascript file :, (*12)

serviceName1
    .methodToImport('param1', {objectProp : 'ObjectValue', objectProp2 : 'ObjectValue2'})
    .done(function(data){
        console.log(data);
    });

Support

Ssa allow to call php service into javascript code. Ssa in symfony add a parameter resolver. It can convert json oject into your doctrine entity. Example : Entity, (*13)

Product :
  - id
  - name
  - price

Database, (*14)

Id | Name | Price, (*15)

1 | Foo | 10.0, (*16)

ProductService.php, (*17)

class ProductService {
    private $em;

    public function __construct(EntityManagerInterface $em) {
        $this->em = $em;
    }

    public function getProduct(Product $p) {
        return $p;
    }

    public function updateProduct(Product $p) {
        $this->em->persist($p);
        $this->em->flush();
        return $p;
    }
}

Javascript call :, (*18)

productService.getProduct({id : 1}).done(function(data){
  // data.id = 1
  // data.name = "Foo"
  // data.price = 10.0
});

productService.updateProduct({name : 'Bar', price : 15}).done(function(data){
  // data.id = AutoGenerated value
  // data.name = 'Bar'
  // data.price = 15
});

productService.updateProduct({id : 1, price : 11.5}).done(function(data){
  // data.id = 1
  // data.name = 'Foo'
  // data.price = 11.5
});

customization

You can customize the framework with you own classes or change parameters., (*19)

Parameters

You can change any parameters on config.yml, (*20)

config.yml, (*21)

ssa :
    configuration :
        # the debug configuration, default is the symfony configuration
        debug : true | false
        # the cache configuration, by default there are no cache, the cachemode is not mandatory with symfony
        cacheMode : file | apc | memcache
        # the cache directory if cacheMode is file. default it's the kernel.cache_dir
        cacheDirectory : 
        # the host for memcache cacheMode
        memcacheHost :
        # the port for memcache cacheMode
        memcachePort :
        # path to ssa js file, if you have your own ssa js implementation. Path begin in web directory
        ssaJsFile :

You can add your own resolver, if you want use specific resolver for your own class : Ssa documentation, (*22)

config.yml, (*23)

ssa :
    parameterResolver :
        primitive :
            - YourFirstPrimitiveResolver
            - YoutSecondPrimitiveResolver
        object :
            - YourFirstObjectResolver
            - YourSecondObjectResolver

Implementation

You can change ssa implementation, add ssa parameters resolver, change route generator., (*24)

Route manager

Routes are use for generate url to call php services, by default the ssa_run_service route is used. You have two way for change route generation. The first is to change the route name used :, (*25)

service.yml, (*26)

parameters :
    ssa.runner.route : 'your_own_ssa_route_name'

Or you can completly change the class use for generate route, your class must implements ssa\converter\UrlFactory interface, your constructor must have two parameters Symfony\Component\Routing\RouterInterface $router and $routeName. For change the class used you must change the ssa.urlFactory.class parameter :, (*27)

service.yml, (*28)

parameters :
    ssa.runner.route : Your\Own\UrlFactory
Parameter resolver

If you want use your own parameter resolver, you can set the class used. the parameter resolver is used for convert get or post parameter in php object. Your parameter resolver need to extends ssa\runner\resolver\impl\DefaultParameterResolver or implements ssa\runner\resolver\ParameterResolver. Your must change the parameter ssa.parameterResolver.class for use your own parameterResolver., (*29)

service.yml, (*30)

parameters :
    ssa.parameterResolver.class : Your\own\resolver

The Versions

06/09 2014

1.0.x-dev

1.0.9999999.9999999-dev

ssa bundle for use ssa framework into Symfony

  Sources   Download

The Requires

 

by Thomas Deblock

php ajax ssa

06/09 2014

v1.0.1

1.0.1.0

ssa bundle for use ssa framework into Symfony

  Sources   Download

The Requires

 

by Thomas Deblock

php ajax ssa

13/08 2014

dev-master

9999999-dev

ssa bundle for use ssa framework into Symfony

  Sources   Download

The Requires

 

by Thomas Deblock

php ajax ssa

03/08 2014

v1.0.0

1.0.0.0

ssa bundle for use ssa framework into Symfony

  Sources   Download

The Requires

 

by Thomas Deblock

php ajax ssa