Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
getting an sfContext without singleton
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Olivier Mansour  
View profile  
 More options Jun 18 2007, 11:27 am
From: Olivier Mansour <omans...@gmail.com>
Date: Mon, 18 Jun 2007 08:27:27 -0700
Local: Mon, Jun 18 2007 11:27 am
Subject: getting an sfContext without singleton
hello

(I am new on this list, so sorry if the question was already
submitted. I have searched on archives !)

I wanted to create an helper to simply make a link to an application
from another (inside the same symphony project). So I supposed the
simple thing was to get the sfContext object related to the
application I wanted to link, and use the sfControlleur to generate
the Url.

My code is :
include_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.
$appname.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
$myControl =
sfController::newInstance(sfConfig::get('sf_factory_controller',
'sfFrontWebController'));
$myControl->initialize(sfContext::getInstance());
return $myControl->genUrl($internal_uri, false);

but, as getInstance is a singleton, I get the context of my current
application. Is there a way to get this instance ?

Thank you
Olivier


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fabien POTENCIER  
View profile  
 More options Jun 18 2007, 11:39 am
From: Fabien POTENCIER <fabien.potenc...@symfony-project.com>
Date: Mon, 18 Jun 2007 17:39:42 +0200
Local: Mon, Jun 18 2007 11:39 am
Subject: Re: [symfony-devs] getting an sfContext without singleton
Hi Olivier,

This is a known limitation of symfony.

The singleton pattern won't allow you to get 2 different sfContext
object at the same time.

Fabien


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Perriault  
View profile  
 More options Jun 18 2007, 11:43 am
From: Nicolas Perriault <nperria...@clever-age.com>
Date: Mon, 18 Jun 2007 17:43:15 +0200
Local: Mon, Jun 18 2007 11:43 am
Subject: Re: [symfony-devs] Re: getting an sfContext without singleton

Fabien POTENCIER wrote:
> The singleton pattern won't allow you to get 2 different sfContext
> object at the same time.

What about a multiton for future releases ? BC of course, but it should
worth to break for such a useful feature, no ?

++

--
Nicolas Perriault    http://www.clever-age.com
Clever Age - conseil en architecture technique
GSM: +33 6 60 92 08 67  TÈl: +33 1 53 34 66 10


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sasha klepikov  
View profile  
 More options Jun 18 2007, 11:43 am
From: sasha klepikov <alex.klepi...@gmail.com>
Date: Mon, 18 Jun 2007 19:43:44 +0400
Local: Mon, Jun 18 2007 11:43 am
Subject: Re: [symfony-devs] Re: getting an sfContext without singleton
I think this is limitation not only in
symfony but in PHP overall.

you wrote 18.06.2007, 07:39 pm:

> Hi Olivier,
> This is a known limitation of symfony.
> The singleton pattern won't allow you
> to get 2 different sfContext
> object at the same time.
> Fabien

--
sasha klepikov
http://sfproject.ru/
alex.klepi...@gmail.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fabien POTENCIER  
View profile  
 More options Jun 18 2007, 11:45 am
From: Fabien POTENCIER <fabien.potenc...@symfony-project.com>
Date: Mon, 18 Jun 2007 17:45:18 +0200
Local: Mon, Jun 18 2007 11:45 am
Subject: Re: [symfony-devs] Re: getting an sfContext without singleton
This is really a limitation of the Singleton design pattern.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fabien POTENCIER  
View profile  
 More options Jun 18 2007, 11:46 am
From: Fabien POTENCIER <fabien.potenc...@symfony-project.com>
Date: Mon, 18 Jun 2007 17:46:48 +0200
Local: Mon, Jun 18 2007 11:46 am
Subject: Re: [symfony-devs] getting an sfContext without singleton
As far as inter-application linking is concerned, this is really not
easy to do in symfony 1.0 because you have 2 singleton: sfContext and
sfRouting.

I'm working hard to remove this limitation and I hope a future release
of symfony will be able to create link for another application of the
same project our of the box.

Fabien


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Olivier Mansour  
View profile  
 More options Jun 18 2007, 12:00 pm
From: "Olivier Mansour" <omans...@gmail.com>
Date: Mon, 18 Jun 2007 18:00:18 +0200
Local: Mon, Jun 18 2007 12:00 pm
Subject: Re: [symfony-devs] Re: getting an sfContext without singleton
2007/6/18, Fabien POTENCIER <fabien.potenc...@symfony-project.com>:

> As far as inter-application linking is concerned, this is really not
> easy to do in symfony 1.0 because you have 2 singleton: sfContext and
> sfRouting.

> I'm working hard to remove this limitation and I hope a future release
> of symfony will be able to create link for another application of the
> same project our of the box.

Thank you for the answer.

I'am just discovering the heart of symfony and I suppose it will be
difficult for me to help a lot. So, to build my helper, I will parse
the routing.yml of the other app.

Olivier

--
Olivier Mansour
omans...@gmail.com
http://podcastfr.info

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Meves  
View profile  
(1 user)  More options Jun 18 2007, 1:15 pm
From: Scott Meves <sme...@gmail.com>
Date: Mon, 18 Jun 2007 13:15:51 -0400
Local: Mon, Jun 18 2007 1:15 pm
Subject: Re: [symfony-devs] Re: getting an sfContext without singleton
I've managed to create links to other apps using project-wide config  
settings. Of course, this doesn't use any of the routing rules, but  
it works in many cases. It sounds like your new helper, Olivier, will  
be much more robust if it parses the routing.yml of the other app.  
For a simple solution, I found this works. Hope it helps.

1. Add appropriate URLs in the project's config/app.yml file. As  
there are different settings used depending on the environment, you  
can put the full URL here and have it automatically use the right  
setting...

<snip>
prod:
   url:
    frontend:  http://public.mysymfonyapp.com
     backend:   http://private.mysymfonyapp.com
dev:
   url:
    frontend:  http://myappdev/frontend.php
    backend:  http://myappdev/backend.php
</snip>

2. In your templates, whenever you need to link between apps, you can  
use this:
<?php echo link_to('Admin Site', sfConfig::get('app_url_backend')) ?>
or
<?php echo link_to('Public Site', sfConfig::get('app_url_frontend')) ?>

-Scott

---------------------
Scott Meves
Stereo :: Interactive & Design
http://www.stereointeractive.com
http://blog.stereodevelopment.com

On Jun 18, 2007, at 12:00 PM, Olivier Mansour wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matthias N.  
View profile  
 More options Jun 18 2007, 4:13 pm
From: "Matthias N." <matthias.nothh...@googlemail.com>
Date: Mon, 18 Jun 2007 20:13:33 -0000
Local: Mon, Jun 18 2007 4:13 pm
Subject: Re: getting an sfContext without singleton
On 18 Jun., 17:46, Fabien POTENCIER <fabien.potenc...@symfony-

project.com> wrote:
> As far as inter-application linking is concerned, this is really not
> easy to do in symfony 1.0 because you have 2 singleton: sfContext and
> sfRouting.

> I'm working hard to remove this limitation and I hope a future release
> of symfony will be able to create link for another application of the
> same project our of the box.

Hi Fabien.

Just wanted to inform you that I have started working on implementing
a dependency injection solution (or is it a service locator?? ;-) )
inspired by Garden (I posted about it before). I think I can commit it
at the end of the week to my mahono branch so people can test it.

At this time I implemented it as additional feature (some new methods
in sfContext) without any BC issues. But it is very easy to replace
the factory.yml in the future.
Unlike Garden I implemented a Yaml driver today that makes setting up
objects really easy and turns this approach into a cool symfony
feature.
And I call it 'tone' instead of 'bean' - I thought "symfony tone" is
much cooler than "Java Bean" ;-)

A tone.yml file looks for example like:

all:
  Request:
    class: sfWebRequest
    singleton: true
    lazy_init: false
    init_method: initialize
    destroy_method: shutdown

And then you can call:

$request = sfContext::getInstance()->getTone('Request');

And symfony cares about the tone magic.

I don't know what you've done so far in that direction, Fabien, but I
could imagine that this could even help with getting this inter-
application linking problem solved. For example by prefixing tone
names:

$foo = sfContext::getInstance()->getTone('backend:MyOtherFoo');

Next step if "tone support" works is sfContext->getRemoteTone() to
work with web services configured with tone.yml

Regards,
Matthias


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google