Skip to content

Commit

Permalink
Added 'Injecting Configuration Dependency' in Config to other languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
SidRoberts committed Jul 26, 2016
1 parent 91473a8 commit c296477
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 0 deletions.
35 changes: 35 additions & 0 deletions es/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,38 @@ The above code produces the following:
)

There are more adapters available for this components in the `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions fr/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,38 @@ Le code fournit le résultat suivant :

Il y a plus d'adaptateurs disponible pour ce composant dans l'
There are more adapters available for this components in the `Incubateur Phalcon <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions ja/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,38 @@ The above code produces the following:
)

There are more adapters available for this components in the `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions pl/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,38 @@ The above code produces the following:
)

There are more adapters available for this components in the `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions pt/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,38 @@ O código acima produz o seguinte:
)

Existem mais adaptadores disponíveis para esse componente em `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions ru/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,38 @@ Ini-файлы являются довольно распространённы
)

Существует еще несколько типов адаптеров конфигурации, их можно получить в "Инкубаторе" - `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions uk/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,38 @@ The above code produces the following:
)

There are more adapters available for this components in the `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}
35 changes: 35 additions & 0 deletions zh/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,38 @@ INI文件是存储设置的常用方法。 :doc:`Phalcon\\Config <../api/Phalcon
)

有更多的适配器可用于这个组件: `Phalcon Incubator <https://github.com/phalcon/incubator>`_

Injecting Configuration Dependency
----------------------------------
You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Mvc\\Controller <../api/Phalcon_Mvc_Controller>`. To be able to do that, add following code inside your dependency injector script.

.. code-block:: php
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Config;
// Create a DI
$di = new FactoryDefault();
$di->set('config', function () {
$configData = require 'config/config.php';
return new Config($configData);
});
Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code:

.. code-block:: php
<?php
use Phalcon\Mvc\Controller;
class MyController extends Controller
{
private function getDatabaseName()
{
return $this->config->database->dbname;
}
}

0 comments on commit c296477

Please sign in to comment.