Skip to content

Commit ef609fd

Browse files
committed
Symfony classes added
1 parent fff9f54 commit ef609fd

File tree

4 files changed

+83
-9
lines changed

4 files changed

+83
-9
lines changed

Ajax/JsUtils.php

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,57 @@ abstract class JsUtils{
4949
protected $config;
5050

5151

52+
/**
53+
* Generates an URL
54+
* Used internally by phpMv
55+
* @param string $url
56+
* @return string the generated url
57+
*/
5258
abstract public function getUrl($url);
59+
/**
60+
* Adds the array of controls q in the $view element
61+
* Used internally by phpMv
62+
* @param string $identifier
63+
* @param string $content
64+
* @param object $view
65+
*/
5366
abstract public function addViewElement($identifier,$content,&$view);
67+
/**
68+
* Creates the script variable script_foot
69+
* Used internally by phpMv
70+
* @param object $view
71+
* @param string $view_var default: script_foot
72+
* @param string $output
73+
*/
5474
abstract public function createScriptVariable(&$view,$view_var, $output);
5575
/**
56-
* render the content of $controller::$action and set the response to the modal content
76+
* Forwards to $controller::$action and set the response to the modal content
77+
* Used internally by phpMv
5778
* @param Controller $initialController
58-
* @param string $controller a Phalcon controller
59-
* @param string $action a Phalcon action
79+
* @param string $controller a controller
80+
* @param string $action an action
6081
* @param array $params
6182
*/
6283
abstract public function forward($initialController,$controller,$action,$params);
6384
/**
6485
* render the content of an existing view : $viewName and set the response to the modal content
86+
* Used internally by phpMv
6587
* @param Controller $initialControllerInstance
6688
* @param View $viewName
6789
* @param $params The parameters to pass to the view
6890
*/
6991
abstract public function renderContent($initialControllerInstance,$viewName, $params=NULL);
7092

7193
/**
72-
* Collect url parts from the request dispatcher : controllerName, actionName, parameters
94+
* Collects url parts from the request dispatcher : controllerName, actionName, parameters
95+
* Used internally by phpMv
7396
* @param mixed $dispatcher
7497
* @return array
7598
*/
7699
abstract public function fromDispatcher($dispatcher);
77100

78101
/**
79-
*
102+
* getter or setter of the jQuery-UI variable
80103
* @param JqueryUI $ui
81104
* @return JqueryUI
82105
*/
@@ -93,7 +116,7 @@ public function ui(JqueryUI $ui=NULL) {
93116
}
94117

95118
/**
96-
*
119+
* getter or setter of the Twitter Bootstrap variable
97120
* @param Bootstrap $bootstrap
98121
* @return Bootstrap
99122
*/
@@ -110,7 +133,7 @@ public function bootstrap(Bootstrap $bootstrap=NULL) {
110133
}
111134

112135
/**
113-
* Returns
136+
* getter or setter of the Semantic-UI variable
114137
* @param Semantic $semantic
115138
* @return Semantic
116139
*/
@@ -128,8 +151,8 @@ public function semantic(Semantic $semantic=NULL) {
128151

129152
/**
130153
*
131-
* @param \Ajax\config\Config $config
132-
* @return \Ajax\config\Config
154+
* @param Config $config
155+
* @return Config
133156
*/
134157
public function config($config=NULL) {
135158
if ($config===NULL) {

Ajax/php/symfony/JqueryBootstrap.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace Ajax\php\symfony;
3+
4+
use Symfony\Component\Routing\RouterInterface;
5+
use Symfony\Component\DependencyInjection\ContainerInterface;
6+
7+
class JquerySemantic extends Jquery_ {
8+
9+
public function __construct(RouterInterface $router,ContainerInterface $container ){
10+
parent::__construct(["bootstrap"=>true,"defer"=>true],$router);
11+
$this->container=$container;
12+
}
13+
}

Ajax/php/symfony/JquerySemantic.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace Ajax\php\symfony;
3+
4+
use Symfony\Component\Routing\RouterInterface;
5+
use Symfony\Component\DependencyInjection\ContainerInterface;
6+
7+
class JquerySemantic extends Jquery_ {
8+
9+
public function __construct(RouterInterface $router,ContainerInterface $container ){
10+
parent::__construct(["semantic"=>true,"defer"=>true],$router);
11+
$this->container=$container;
12+
}
13+
}

Ajax/php/symfony/Jquery_.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
namespace Ajax\php\symfony;
3+
4+
use Symfony\Component\HttpFoundation\Response;
5+
use Symfony\Component\HttpFoundation\Request;
6+
7+
abstract class Jquery_ extends JsUtils {
8+
protected $container;
9+
10+
/**
11+
* @param string $viewName
12+
* @param array $parameters
13+
* @return Response
14+
*/
15+
public function renderView($viewName,$parameters=[]){
16+
$twig=$this->container->get("twig");
17+
$this->compile($parameters);
18+
return new Response($twig->render($viewName, $parameters));
19+
}
20+
21+
public function generateUrl($path){
22+
$request=Request::createFromGlobals();
23+
return $request->getBaseUrl().$path;
24+
}
25+
}

0 commit comments

Comments
 (0)