Skip to content

Commit

Permalink
Now using classes provided by the jaxon-sentry package.
Browse files Browse the repository at this point in the history
  • Loading branch information
feuzeu committed Apr 30, 2017
1 parent d6fc403 commit 5747a66
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ The options in the `lib` section are those of the Jaxon core library, while the

The following options can be defined in the `app` section of the config file.

| Name | Description |
|------|---------------|
| classes | An array of directory containing Jaxon application classes |
| views | An array of directory containing Jaxon application views |
| | | |

By default, the `views` array is empty. Views are rendered from the framework default location.
There's a single entry in the `classes` array with the following values.

| Name | Default value | Description |
|------|---------------|-------------|
| controllers.directory | jaxon/Controller | The directory of the Jaxon classes |
| controllers.namespace | \Jaxon\App | The namespace of the Jaxon classes |
| controllers.separator | . | The separator in Jaxon class names |
| controllers.protected | empty array | Prevent Jaxon from exporting some methods |
| directory | jaxon/Classes | The directory of the Jaxon classes |
| namespace | \Jaxon\App | The namespace of the Jaxon classes |
| separator | . | The separator in Jaxon class names |
| protected | empty array | Prevent Jaxon from exporting some methods |
| | | |

Usage
Expand Down Expand Up @@ -93,19 +102,15 @@ Then it calls the `$jaxon->css()`, `$jaxon->js()` and `$jaxon->script()` functio

### The Jaxon classes

The Jaxon classes must inherit from `\Jaxon\Module\Controller`.

The Jaxon classes of the application must all be located in the directory indicated by the `app.controllers.directory` option in the `jaxon.yml` config file.
If there is a namespace associated, the `app.controllers.namespace` option should be set accordingly.

By default, the Jaxon classes are located in the `jaxon/Controller` dir of the Symfony application, and the associated namespace is `\Jaxon\App`.
The Jaxon classes must inherit from `\Jaxon\Sentry\Classes\Base`.
By default, they are located in the `jaxon/Classes` dir of the Symfony application, and the associated namespace is `\Jaxon\App`.

This is a simple example of a Jaxon class, defined in the `jaxon/Controller/HelloWorld.php` file.
This is a simple example of a Jaxon class, defined in the `jaxon/Classes/HelloWorld.php` file.

```php
namespace Jaxon\App;
class HelloWorld extends \Jaxon\Module\Controller
class HelloWorld extends \Jaxon\Sentry\Classes\Base
{
public function sayHello()
{
Expand Down
4 changes: 2 additions & 2 deletions app/config/jaxon.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
parameters:
jaxon:
app:
controllers:
classes:
-
directory: '%kernel.root_dir%/../jaxon/Controller'
directory: '%kernel.root_dir%/../jaxon/Classes'
namespace: \Jaxon\App
# separator: '' # '.' or '_'
# protected: []
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"source": "https://github.com/jaxon-php/jaxon-symfony"
},
"require": {
"jaxon-php/jaxon-core": "~2.0",
"jaxon-php/jaxon-sentry": "~2.0",
"symfony/symfony": "2.8.*|3.0.*|3.1.*"
},
"autoload": {
Expand Down
12 changes: 7 additions & 5 deletions src/Jaxon.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Jaxon
{
use \Jaxon\Module\Traits\Module;
use \Jaxon\Sentry\Traits\Armada;

/**
* The application debug option
Expand Down Expand Up @@ -57,26 +57,28 @@ protected function jaxonSetup()
// The application web dir
$baseDir = $_SERVER['DOCUMENT_ROOT'];

$sentry = jaxon()->sentry();

// Set the config options
jaxon()->setOptions($this->configs, 'lib');
$this->appConfig = new Config();
$this->appConfig->setOptions($this->configs, 'app');

// Jaxon library default settings
$this->setLibraryOptions(!$this->debug, !$this->debug, $baseUrl . '/jaxon/js', $baseDir . '/jaxon/js');
$sentry->setLibraryOptions(!$this->debug, !$this->debug, $baseUrl . '/jaxon/js', $baseDir . '/jaxon/js');

// Set the default view namespace
$this->addViewNamespace('default', '', '.html.twig', 'twig');
$sentry->addViewNamespace('default', '', '.html.twig', 'twig');
$this->appConfig->setOption('options.views.default', 'default');

// Add the view renderer
$template = $this->template;
$this->addViewRenderer('twig', function() use($template) {
$sentry->addViewRenderer('twig', function() use($template) {
return new View($template);
});

// Set the session manager
$this->setSessionManager(function(){
$sentry->setSessionManager(function(){
return new Session();
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Jaxon\AjaxBundle;

use Jaxon\Module\View\Store;
use Jaxon\Module\Interfaces\View as ViewInterface;
use Jaxon\Sentry\View\Store;
use Jaxon\Sentry\Interfaces\View as ViewInterface;

class View implements ViewInterface
{
Expand Down

0 comments on commit 5747a66

Please sign in to comment.