librelist archives

« back to archive

Patch to add a bootstrap to photon project

Patch to add a bootstrap to photon project

From:
William Martin
Date:
2011-09-20 @ 19:34
could not decode message

Re: [photon.users] Patch to add a bootstrap to photon project

From:
Loic d'Anterroches
Date:
2011-09-21 @ 11:17
Hello,

On 2011-09-20 21:34, William MARTIN wrote:
> Hi,
> 
> I wrote a small patch to call a bootstrap function when photon handler
> start.
> The code search a static function in the configuration file and call it. I
> really simple.
> 
> In the configuration file :
>     'startup' => 'my\app\startup::boot',

What about:

'startup' => array('my\app\startup::boot', 'other\app\Foo::boot'),


foreach (Conf::f('startup', array()) as $startup) {
    call_user_func($startup);
}

This way, each app can start its own stuff.

loïc

Re: [photon.users] Patch to add a bootstrap to photon project

From:
William Martin
Date:
2011-09-21 @ 11:36
Good point !
You can commit that when you want ;)

William

On Wed, Sep 21, 2011 at 1:17 PM, Loic d'Anterroches <loic@ceondo.com> wrote:

> Hello,
>
> On 2011-09-20 21:34, William MARTIN wrote:
> > Hi,
> >
> > I wrote a small patch to call a bootstrap function when photon handler
> > start.
> > The code search a static function in the configuration file and call it.
> I
> > really simple.
> >
> > In the configuration file :
> >     'startup' => 'my\app\startup::boot',
>
> What about:
>
> 'startup' => array('my\app\startup::boot', 'other\app\Foo::boot'),
>
>
> foreach (Conf::f('startup', array()) as $startup) {
>    call_user_func($startup);
> }
>
> This way, each app can start its own stuff.
>
> loïc
>

Re: [photon.users] Patch to add a bootstrap to photon project

From:
Loic d'Anterroches
Date:
2011-09-21 @ 12:44

On 2011-09-21 13:36, William MARTIN wrote:
> Good point !
> You can commit that when you want ;)

Ok, looking at the code, I found I need to do a bit of cleaning too. The
tasks still have some mess from the previous control system and the way
the configuration is loaded:

    public function __construct()
    {
        $this->loadConfig(Conf::f('photon_task_' . $this->name, array()));
        $this->setupControl();
        $this->setupCom();
    }

with the direct call the Conf::f is not good. The array of data should
be given directly in the constructor, this will also help unit testing.

loïc


> On Wed, Sep 21, 2011 at 1:17 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
> 
>> Hello,
>>
>> On 2011-09-20 21:34, William MARTIN wrote:
>>> Hi,
>>>
>>> I wrote a small patch to call a bootstrap function when photon handler
>>> start.
>>> The code search a static function in the configuration file and call it.
>> I
>>> really simple.
>>>
>>> In the configuration file :
>>>     'startup' => 'my\app\startup::boot',
>>
>> What about:
>>
>> 'startup' => array('my\app\startup::boot', 'other\app\Foo::boot'),
>>
>>
>> foreach (Conf::f('startup', array()) as $startup) {
>>    call_user_func($startup);
>> }
>>
>> This way, each app can start its own stuff.
>>
>> loïc
>>