[symfony-users] [SF2] WebTestCase - Simulate AJAX Request

2011-06-20 Thread Roger Webb
Hey Everyone,

I use "if($this->get('request')->isXmlHttpRequest()" in several places
and was wondering how you would simulate an XmlHttpRequest using
BrowserKit/Client (ie. is there something built in or do I need to set
some headers).

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] [SF2] WebTestCase Issues

2011-06-17 Thread Roger Webb
I tried creating the client with a fully-qualified url and with the
route only and get the same error.

This is the error I get when running phpunit:

There was 1 error:

1) ARN\UserBundle\Tests\Controller\UserControllerTest::testLoginAction
InvalidArgumentException: The current node list is empty.

This is the test case (minus username and pw):

class UserControllerTest extends WebTestCase {
   public function testLoginAction() {
   $client = $this->createClient();

   $crawler = $client->request('GET', '/user/login');

   $form = $crawler->selectButton('submit')->form();

   $form['_username'] = 'username';
   $form['_password'] = 'password';

   $crawler = $client->submit($form);
   }

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] [SF2] Functional Testing and SF2 Security

2011-06-17 Thread Roger Webb
Hello Everyone,

I am starting down the road of functional testing with Symfony and am
wondering what is considered the "best practice" for simulating
authentication.  My app uses form-based authentication.  The cook book
contains a piece on simulating HTTP authentication, but I couldn't
find anything on form/entity based auth.

Also, is it best to set up the client in the "setUp" method (ie.
create the client, submit the login form and use this client with all
of the test cases.

As always, I appreciate the help.

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: datetime widget single_text format

2011-06-16 Thread Roger Webb
It's expecting something like this:

$builder->add('next_contact_date', 'date', array('input' =>
'datetime', 'widget' => 'single_text', 'format' =>
\IntlDateFormatter::SHORT));

Note this: \IntlDateFormatter::SHORT

This is a PHP thing.  The docs: 
http://www.php.net/manual/en/class.intldateformatter.php

Not sure if this will get the date format you're looking for, but
that's where the integer comes from.

Roger

On Jun 16, 6:59 am, Stephan Petzl  wrote:
> there is a pending pull request:
>
> https://github.com/symfony/symfony/pull/694
>
> as far as i see, the formating option will be available as soon as
> this is merged...
>
> BR Stephan
>
> On Jun 16, 11:44 am, ibrows_symfony  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I would like to change the format of the datetime widget to "dd.mm.".
> > How can I do that?
>
> > Actually, my field is implemented like this:
> > $builder->add('startdatum', 'datetime', array( 'date_widget' =>
> > 'single_text', 'time_widget' => 'text'));
>
> > I saw there is a parameter format, but it needs an integer-value.
> > Any idea?
>
> > Thanks.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: app/cache and permissions

2011-06-10 Thread Roger Webb
You can have the user you log in as and the "apache" user be in the
same group.

On Jun 10, 11:22 am, theinterned  wrote:
> Hi,
>
> I am wondering how you all are managing permissions on your symfony 2
> projects.
>
> I seem to be constantly wrestling with permissions as I generate files
> in app/cache form the command line (as my user) and from the apache
> web server (as the apache user). Both of these users are generating
> files and folders in app cache and the permissions are constantly
> colliding. I find myself constantly doing this dance:
>
> rm -rf app/cache
> mkdir app/cache
> chmod -R +w app/cache
>
> I have tried the cache:clear console command, but this just runs into
> the same permission issues.
>
> Just curious what other are doing about this?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: getting a fatal error using swiftmailer

2011-06-03 Thread Roger Webb
I went through this *exact* issue and found an answer on the list.

You *MUST* retrieve the "mailer" before creating a new Swift_Message

$mailer = $this->get('mailer');

$message = \Swift_Message::newInstance()->...

Roger

On Jun 3, 9:27 am, Kevin  wrote:
> I was also having this issue, updating to sf2 master cleared it up for
> me.
>
> On Jun 2, 10:35 am, keymaster  wrote:
>
>
>
>
>
>
>
> > Getting the identical error, also on Sf2 Beta3.
>
> > *Fatal error*: Call to a member function clearAll() on a non-object in 
> > *C:\Program
> > Files
> > (x86)\Zend\Apache2\htdocs\Symfony\vendor\swiftmailer\lib\classes\Swift\Mime\SimpleMimeEntity.php
> > * on line *822
>
> > Here is the code:
> > *
> > $message = \Swift_Message::newInstance()->setSubject( 'Contact Email' )
> >                     ->setFrom( 's...@example.com' )
> >                     ->setTo( 'recipi...@example.com' )
> >                     ->setBody( 'Hi There' );
> > $this->get( 'mailer' )->send( $message );

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Handling AccessDeniedException

2011-06-02 Thread Roger Webb
Your AJAX request will use the same cookie/authentication as you use
normally.  I would check the access control on the route you are
POSTing to with your AJAX request.  My guess is that you are having an
issue with ROLEs or user type.  Remember that firewalls/access control
(ROLES) can (and often are) cascading.

On Jun 2, 11:13 am, winzou  wrote:
> Hi all,
>
> I'm using some ajax features with Symfony2 and jQuery. All is working well,
> except the case when an ajax request encounters an AccessDeniedException.
> The behavior in the usual case is to redirect to the login page, I'm ok with
> that. But, when it's an XmlHttpRequest, with a Json RequestFormat... why
> this exception still wants to redirect?
>
> First: is this behavior on purpose or not?
> And then, is there any way to disable redirection on an ajax request, and
> instead sending a json error message with a 500 error code?
>
> Thanks a lot

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Recommended way to handle Entities that were not found?

2011-06-02 Thread Roger Webb
If you're using a DQL Query:

try {
   $em->createQuery('...')->getSingleResult();
} catch(\Exception $e) {
   return new Response('...');
}

Will throw an exception if no record is returned.

Same thing with "getResult" instead of "getSingleResult" should return
an ArrayCollection with a count of 0 if nothing is found:

$users = $em->createQuery('...')->getResult();

if($users->count() == 0)
   throw new Exception('...');

(return a Response, throw an Exception, whatever you like, but those
are the tests I currently use).

Roger


On Jun 2, 10:03 am, thesaint  wrote:
> In your controllers you'll often load entities with IDs coming from
> the URL. What's the recommended way to deal with the case that an
> entity was not found?
>
> In Symfony 1.4 it was
>
> $id = $request->getParameter('id);
> $this->forward404Unless($user = Doctrine_Core::getTable('User')-
>
> >find($id), sprintf('User not found (%s).', $id));
>
> For the time being I do the following in SF2:
>
> $em = $this->getEntityManager();
> $user = $em->find('MyBundle:User', $id);
> if(!$user) {
>   throw new Symfony\Component\HttpKernel\Exception
> \NotFoundHttpException(sprintf('User not found (%s).', $id));
>
> }
>
> Are there better/recommended ways?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: - [beta3] Empty values on the page that exists in database

2011-06-02 Thread Roger Webb
Hello,

Did you follow the update document closely:
https://github.com/symfony/symfony/blob/master/UPDATE.md

That's solved most of my update-related issues.

I know there are some bundles (WebServiceBundle for one) that were
broken in the last release or two.  So, there could, possibly, be
bundle-related issues.

Roger

On Jun 2, 6:00 am, seven seven  wrote:
> Hi everyone,
>
> I am currently working on a basic CMS based on sf2. After upgrading from
> beta1 to beta3 a strange thing happened , some data doesn't appear on the
> page anymore; same database as in beta1. I must mention that data from the
> same entity , some works some does not, but every time I refresh the
> page the same data doesn't appear.
>
> I have also updated gedmo ,DoctrineExtensionsBundle and also DoctrineORM to
> master branch. I didn't checked if using the 2.0.x versions same thing
> happens.
>
> Database and data got generate in old sf2 PRs and updated over the time. The
> fact is that I need data currently used in beta1 to be imported in beta3 and
> so on...
>
> Anyone with the issue ?
>
> Thanks in advance !
>
> --
> 
> Cezar

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Is there demand for a Symfony2 Eclipse Plugin?

2011-06-01 Thread Roger Webb
Hi,

I like Eclipse as well.  If it's easier (due to existing Twig support)
to use NetBeans, I'm not opposed to that.  I used Eclipse PHP in the
past and was pleased.

I've never done any Eclipse Plugin development.  If you put one out
I'd be happy to test and document (and, if I end up with some time,
could read up on Eclipse dev and see what I could do there).

Roger

On Jun 1, 8:45 am, xaben  wrote:
> Hi,
>
> i switched from Eclipse to Netbeans, because it has a Twig plugin with
> code highlighting,
>
> http://blogsh.de/twig-for-netbeans/
>
> it's not complete, as i found it is lacking automatic code formatting
> for twig tags.
>
> I'd say it would be nice to have a plugin for Eclipse (that would work
> for Zend Studio users as well i assume). For me the first priority
> would be the Twig code highlight and autoformat, as well as Yaml (not
> sure if there is support for it in Eclipse or it's pluggins).
>
> cheers,
> Alex
>
> On 1 июн, 13:51, Robert Gründler  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > i'm one of the developers of the (never-finished) symfony 1.x eclipse
> > plugin:
>
> >http://sourceforge.net/projects/sfdt/.
>
> > Personally, i've switched from Eclipse to TextMate  a couple of months ago,
> > due
> > to several reasons, one of them was the poor performance of Eclipse on OSX
> > in
> > larger projects.
>
> > However, the current version of the PHP Plugin for Eclipse 3.7 seems to
> > perform
> > far better than a couple of months ago, so i see several advantages of using
> > an IDE
> > with a more sophisticated autocompletion than a scripteditor like Textmate.
>
> > As i have more time the next 2-3 months, i've been thinking about
> > resurrecting the idea
> > of a community-developed Eclipse plugin for Symfony2.
>
> > Therefore, i'd like to ask for some feedback from the symfony community on
> > several issues:
>
> > * Do people actually use Eclipse as their preferred IDE for Symfony / PHP
> > projects?
> > * Is there a Twig (or Jinja) Editor available for Eclipse - or does this
> > need to be part of the plugin?
> > * Are there people willing to contribute to the development of a Symfony2
> > Eclipse-Plugin (development, testing, documentation) ?
>
> > cheers,
>
> > -robert

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: app.php in prod generates blank page

2011-05-25 Thread Roger Webb
Then you should be able to modify the permissions using the
"properties" of the folder.

On May 25, 9:54 am, Marco Roello  wrote:
> Ricardo Thanks but, as I said in the first post, but I'm testing on a
> windows environment
>
> 2011/5/24 Ricardo Oliveira 
>
>
>
>
>
>
>
> > It seems you haven't changed the permissions on the log folder to 777,
> > and the same for cache folder.
>
> > On May 23, 10:55 am, abunet  wrote:
> > > HI,
> > > I've installed symfony beta1 on a windows environment (apache 2.2.17
> > > and php 5.3.6)
> > > The demo app works fine in app_dev mode, and also in app prod mode
> > > with debug = true ($kernel = new AppKernel('prod', true);)
>
> > > if I keep default prod mode:
> > > $kernel = new AppKernel('prod', true);
> > > the result is a blank page.
> > > to debug the problem, I've added ini_set('display_errors', 1); and I
> > > retrieve the following error:
>
> > > Fatal error: Uncaught exception 'UnexpectedValueException' with
> > > message 'The stream could not be opened, "C:\www\Symfony\app/logs/
> > > prod.log" may be an invalid url.' in C:\www\symfony.local\vendor
> > > \monolog\src\Monolog\Handler\StreamHandler.php on line 67
> > > UnexpectedValueException: The stream could not be opened, "C:\www
> > > \Symfony\app/logs/prod.log" may be an invalid url. in C:\www
> > > \symfony.local\vendor\monolog\src\Monolog\Handler\StreamHandler.php on
> > > line 67 Call Stack: 0.0275 330672 1. {main}() C:\www\symfony.local\web
> > > \app.php:0 8.8634 650432 2.
> > Symfony\Component\HttpKernel\Kernel->handle(???, ???, ???)
> > C:\www\symfony.local\web\app.php:16 8.8689
>
> > > 757232 3. Symfony\Bundle\FrameworkBundle\HttpKernel->handle(???, ???,
> > ???) C:\www\symfony.local\app\bootstrap.php.cache:
>
> > > 613
>
> > > I think that the problem is the following path:
> > > C:\www\Symfony\app/logs/prod.log
> > > the correct path should be:
> > > C:\www\symfony.local\app\logs\prod.log
>
> > > Any Ideas?
> > > Thanks
> > > Marco Roello
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Forms -

2011-05-24 Thread Roger Webb
No worries buddy.  Like I said, I figure there's a good possibility
that others will encounter the same issue, so why not post it here.

On May 24, 4:19 pm, jmihel  wrote:
> Hi,
>
> I'm sorry for not posting my reply here, I was still using the old google
> group. I will post here from now on.
>
> Josip

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Forms -

2011-05-24 Thread Roger Webb
>From jmi...@gmail.com

I moved it here so everyone can benefit from the conversation :)

As I learned from my recent issues when I updated to beta 2, here is
the process.

When the form is created via $this->get('form.factory')->create(new
MyFormType(), $data), 3 things happen that are relevant to this use-
case.

1)  The method setData(null) is called.  Note the null, you have to
account for this in the preSetData event.
2)  setData($data) is called with $data being the second argument of
create.  Could be an Entity, POPO, or associative array.
3)  When we call $form->bindRequest($this->get('request')), the
preBind event is triggered, the data is an associative array of the
relevant part of the request.  If your type was "MyType", the array
returned from $request->get('mytype') is what you get.

Here is josip's email (the full file he requested is below his e-
mail):

I'm having a similar problem as you had. Since i reckon yours is
working now I would just like to ask you a few things.

1) Where does the data['state'] in the preBind listener come from, is
it an entity field, i.e. an choice field?
2) If 1) is true isn't the data['state'] in this  preBInd listener
actually an identifier of the state entity and not the entity itself
(i gather that the conversion of the submitted data into its entities
is complete when the onBindNormData event is fired).
3) if 2) is correct did you than load the state entity with an entity
manager from the given id.
4) could you maybe provide me with the complete ContactType form

Thanks in advance

Josip

*

class ContactInfoType extends AbstractType {

public function buildForm(FormBuilder $builder, array $options) {
$factory = $builder->getFormFactory();

$refreshCity = function ($form, $state) use ($factory) {
$form->add($factory->createNamed('entity', 'city', null,
array(
'class' => 'Entity:Cities',
'property'  => 'city_name',
'label' => 'City',
'query_builder' => function (EntityRepository
$repository) use ($state) {
   $qb = $repository-
>createQueryBuilder('cities')
 -
>select(array('cities', 'zip_codes'))
 -
>innerJoin('cities.states', 'states')
 -
>innerJoin('cities.zip_codes', 'zip_codes');

   if($state instanceof States) {
   $qb = $qb-
>where('cities.states = :state')
-
>setParameter('state', $state);
   } elseif(is_numeric($state)) {
   $qb = $qb-
>where('states.state_id = :state_id')
-
>setParameter('state_id', $state);
   } else {
   $qb = $qb-
>where('states.state_id = 1');
   }

   return $qb;
   }
)));
};

$builder->addEventListener(Events::preSetData, function
(DataEvent $event) use ($refreshCity) {
$form = $event->getForm();
$data = $event->getData();

if($data instanceof ContactInfo) {
$refreshCity($form, $data->getCity()->getState());
}
});

$builder->addEventListener(Events::preBind, function
(DataEvent $event) use ($refreshCity) {
$form = $event->getForm();
$data = $event->getData();

if(array_key_exists('state', $data)) {
$refreshCity($form, $data['state']);
}
});

$builder->add('first_name', 'text');
$builder->add('last_name', 'text');
$builder->add('address', 'text');

$builder->add('state', 'entity', array(
'class' => 'Entity:States',
'property'  => 'abbrev',
'label' => 'State',
'query_builder' => function (EntityRepository $repository)
{
   return $repository

[symfony-users] Re: Security : Retrieving user and password

2011-05-24 Thread Roger Webb
Sorry to reply again, but I forgot to put in the snippet I used to
retrieve it.

$this->get('security.context')->getToken()->getUser()->getPassword();


On May 24, 9:41 am, Roger Webb  wrote:
> I am unable to reproduce the issue you're describing.  As I understand
> it best, *you* control what is retrieved from the database in your
> UserProviderInterface.  That is, of course, assuming you are using
> "entity" authentication.
>
> On May 24, 9:25 am, dbenjamin  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I see that the password is not hydrated when retreiving user through
> > security context.
>
> > But when a provider fetches the user from a database, not having the
> > password forces the developper to execute an extra request just to be able
> > to save the user without a null password.
>
> > I know that's a security matter, but i feel like i'm doing the exact same
> > query the provider does a second time when it could be avoided.
>
> > What's the best practice for this ?
>
> > Thanks.
>
> > *
> > --
> > Benjamin Dulau - anonymation CEO
> > anonymation.com | code.anonymation.com
> > ben...@anonymation.com
> > *

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Security : Retrieving user and password

2011-05-24 Thread Roger Webb
I am unable to reproduce the issue you're describing.  As I understand
it best, *you* control what is retrieved from the database in your
UserProviderInterface.  That is, of course, assuming you are using
"entity" authentication.

On May 24, 9:25 am, dbenjamin  wrote:
> Hi,
>
> I see that the password is not hydrated when retreiving user through
> security context.
>
> But when a provider fetches the user from a database, not having the
> password forces the developper to execute an extra request just to be able
> to save the user without a null password.
>
> I know that's a security matter, but i feel like i'm doing the exact same
> query the provider does a second time when it could be avoided.
>
> What's the best practice for this ?
>
> Thanks.
>
> *
> --
> Benjamin Dulau - anonymation CEO
> anonymation.com | code.anonymation.com
> ben...@anonymation.com
> *

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] SF2 WebServiceBundle

2011-05-24 Thread Roger Webb
I tried to get the WebServiceBundle up and running and encountered the
following error:

ServiceNotFoundException: The service
"webservice.definition.loader.annot_class" has a dependency on a non-
existent service "annotations.configuration_reader".

Has anyone tried to use this bundle?  It looks like it was updated at
the beginning of April, so maybe it's a beta2 change affecting the
bundle or perhaps I'm missing something in my configuration.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: null data in form - using the Event System

2011-05-23 Thread Roger Webb
For the benefit of the list.

>From Chris Wallsmith (thanks):

---
Every form starts with a call to setData(null)
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php#L227

Adding a if (null === $data) return; condition to your listener would
probably fix it.

---

That fixes it.

Roger


On May 23, 3:28 pm, Roger Webb  wrote:
> This worked in beta1 but not in beta2 [seems to be a theme today :
> (  ]   This was Berhard's nifty solution to my AJAX city/state
> problem.
>
> I print_r()'d the array ($realtor_search_params) and it is indeed
> populated with data (an associative array), but I get the following
> exception when I run it:
>
> "Warning: array_key_exists() expects parameter 2 to be array, null
> given ..."
>
> Did something change in the event (or form) system?
>
> From Controller:
>
>         $realtor_search_form = $this->get('form.factory')->create(new
> RealtorSearchType(), $realtor_search_params);
>
> From RealtorSearchType:
>
>         $builder->addEventListener(Events::preSetData, function
> (DataEvent $event) use ($refreshCity) {
>             $data = $event->getData();
>
>             if(array_key_exists('state', $data))  // ERROR IS HERE,
> $data is null
>                 $refreshCity($event->getForm(), $data['state']);
>         });

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Forms - form_rest() renders fields already rendered with form_widget

2011-05-23 Thread Roger Webb
done

On May 23, 3:27 pm, Donald Tyler  wrote:
> I would suggest creating this as an issue on github.
>
>
>
>
>
>
>
> On Mon, May 23, 2011 at 3:25 PM, pzwosta  wrote:
> > Hi,
>
> > I have the same problem since BETA 2:
>
> >     public function buildForm(FormBuilder $builder, array $options)
> >     {
> >         $builder->add('firstname', 'text');
> >         $builder->add('lastname', 'text');
> >         $builder->add('email', 'text');
> >         $builder->add('password', 'repeated', array('type' => 'password'));
> >     }
>
> > ...
> >   label($form['password']['first'], 'Pw:')
> > ?>
> >   widget($form['password']['first']) ?>
> >  
> >    label($form['password']['second'], 'Repeat
> > Pw:') ?>
> >   widget($form['password']['second']) ?>
> > ...
> >   rest($form) ?>  -->> Both of the password Input
> > fields are rendered again. I'd expect only the token to be rendered.
>
> > regards Peter
>
> >  --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] null data in form - using the Event System

2011-05-23 Thread Roger Webb
This worked in beta1 but not in beta2 [seems to be a theme today :
(  ]   This was Berhard's nifty solution to my AJAX city/state
problem.

I print_r()'d the array ($realtor_search_params) and it is indeed
populated with data (an associative array), but I get the following
exception when I run it:

"Warning: array_key_exists() expects parameter 2 to be array, null
given ..."

Did something change in the event (or form) system?

>From Controller:

$realtor_search_form = $this->get('form.factory')->create(new
RealtorSearchType(), $realtor_search_params);

>From RealtorSearchType:

$builder->addEventListener(Events::preSetData, function
(DataEvent $event) use ($refreshCity) {
$data = $event->getData();

if(array_key_exists('state', $data))  // ERROR IS HERE,
$data is null
$refreshCity($event->getForm(), $data['state']);
});

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Beta2 - Date Field (3 Text Boxes instead of 1)

2011-05-23 Thread Roger Webb
Not that I'm aware of.  One possible solution would be to use Jquery
to render it invisible (or render the three fields individually and
set us the 'attr' parameter to mark it as invisible.  Either way you
would set a default value for the day.

Not sure if that's the best solution, but either one should work.

On May 23, 1:35 pm, umpirsky  wrote:
> Can I render only year and month? Useful for credit cards for example.
>
> On May 23, 8:11 pm, Roger Webb  wrote:
>
>
>
>
>
>
>
> > It's in the update doc and I'm having a severe case of the mondays.
>
> > "Form: Renamed option value "text" of "widget" option of the "date"
> > type was renamed to "single-text". "text" indicates to use separate
> > text boxes now (like for the "time" type)."
>
> > On May 23, 1:01 pm, Roger Webb  wrote:
>
> > > From the "date" field documentation:
> > > "The field can be rendered as a single text box or three select boxes
> > > (month, day, and year)."
>
> > > I'm not seeing an option for "3 Text Boxes", it rendered as a single
> > > text field before which made it work nice with JQuery UI Datepicker.
>
> > > Perhaps the documentation is out of date.  Is there a way to make it
> > > render as one field?
>
> > > Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] SF2 Forms - form_rest() renders fields already rendered with form_widget

2011-05-23 Thread Roger Webb
I have several cases where, due to some picky spacing issues, I have
rendered fields manually with form_widget.

For instance:

  First Name: {{ form_widget(borrower_search_form.first_name, { 'required':
false }) }}

In beta1, I could call form_rest() and it would behave as ( I )
expected.  In beta2, if I rendered the field in this manner,
form_rest() will re-render all of these fields at the bottom of my
form.

Is there a better way to go about this?  (or a way to "mark" it as
already rendered)

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Beta2 - Date Field (3 Text Boxes instead of 1)

2011-05-23 Thread Roger Webb
It's in the update doc and I'm having a severe case of the mondays.

"Form: Renamed option value "text" of "widget" option of the "date"
type was renamed to "single-text". "text" indicates to use separate
text boxes now (like for the "time" type)."

On May 23, 1:01 pm, Roger Webb  wrote:
> From the "date" field documentation:
> "The field can be rendered as a single text box or three select boxes
> (month, day, and year)."
>
> I'm not seeing an option for "3 Text Boxes", it rendered as a single
> text field before which made it work nice with JQuery UI Datepicker.
>
> Perhaps the documentation is out of date.  Is there a way to make it
> render as one field?
>
> Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] SF2 Beta2 - Date Field (3 Text Boxes instead of 1)

2011-05-23 Thread Roger Webb
>From the "date" field documentation:
"The field can be rendered as a single text box or three select boxes
(month, day, and year)."

I'm not seeing an option for "3 Text Boxes", it rendered as a single
text field before which made it work nice with JQuery UI Datepicker.

Perhaps the documentation is out of date.  Is there a way to make it
render as one field?

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: notice: serialize() __sleep

2011-05-23 Thread Roger Webb
Issue has been resolved.  I had a DateTime in there that I hadn't
converted to a string.  For anyone else's benefit that may stumble
upon this, here's some relevant code snippets that worked out for me:

Class Declaration

class Users implements UserInterface, \Serializable {

Serialize/Unserialize Methods (Not sure if it's the right way or the
wrong way, but it's the Webb way and it works for now):

public function serialize() {
return implode(',', array(
'user_id' => $this->getUserId(),
'username'=> $this->getUsername(),
'password'=> $this->getPassword(),
'user_active' => $this->getUserActive(),
'user_date'   => $this->getUserDate()->format('m/d/Y')
));
}


public function unserialize($strSerialized) {
$serialized = explode(',', $strSerialized);

$this->setUserId($serialized[0]);
$this->setUsername($serialized[1]);
$this->password = $serialized[2];
$this->setUserActive($serialized[3]);
$this->setUserDate(new \DateTime($serialized[4]));
}


On May 23, 12:30 pm, Roger Webb  wrote:
> Until the BETA2 update I was getting warnings related to serializing
> the User Entity, it is a breaking problem in beta2.  So, I googled
> around and found this:
>
> http://groups.google.com/group/symfony-users/browse_thread/thread/54c...
>
> Following the advice there, I created serialize() and unserialize()
> methods and had my "Users" class implement \Serializable.  I tried
> returning an array, which through the following Exception:
>
> "Symfony\Component\Security\Core\Authentication\Token
> \UsernamePasswordToken::serialize() must return a string or NULL"
>
> I returned null and it worked but it rendered the Entity returned by
> $this->get('security.context') and it's twig counterpart useless
> because it contained no data.
>
> So, I tried imploding the array and returning that and was met with
> the Exception noted above.
>
> I also tried looking through the "Security" chapter in the book and
> could not find any  information about how to or what to serialize.
> Can anyone point me to a resource that explains how to do this in a
> Symfony-appropriate way?
>
> Roger
>
> On May 17, 1:58 am, Marco Pivetta  wrote:
>
>
>
>
>
>
>
> > I usually build stuff like this when making a multi-step form with different
> > http requests:
>
> > request 1:
> > $ns = new \Zend_Session_Namespace('test'); //don't care about it, I usually
> > work with ZF
> > /* We suppose this is my entity fetched by some kind of voodoo query or
> > complex stuff that can be done only in step 1 (picker?) */
> > $modifiedUser = $em->getRepository('My\User')->findOneBy(array('fullname' =>
> > 'Marco Pivetta'));
> > $em->detach($modifiedUser);
> > $ns->user = $modifiedUser;
>
> > request 2:
> > $ns = new \Zend_Session_Namespace('test');
> > //Bringing my user entity back to life!
> > $modifiedUser = $ns->user;
> > $em->merge($modifiedUser);
> > $em->refresh($modifiedUser); //Yeah, this is overhead, but it solved a LOT
> > of troubles in my case...
> > $modifiedUser->doStuff();
> > //Now again, for the next step! And so on and on and on...
> > $em->detach($modifiedUser);
> > $ns->user = $modifiedUser;
>
> > request 3:
> > //repeat stuff like request 2 here!
>
> > Marco Pivetta
> > @Ocramius <http://twitter.com/Ocramius>http://marco-pivetta.com
>
> > On 17 May 2011 04:53, Luis Cordova  wrote:
>
> > > yes and if you find a resource or more styled example or post that can
> > > clarify this further would be great
>
> > > On Mon, May 16, 2011 at 9:48 PM, oscar balladares 
> > > wrote:
> > > > Another issue that I run into is:
> > > > Let's say we have object A, and object A has refernce to Object B, both
> > > are
> > > > entities instances, and reference of B is actually a proxy.
> > > > This is the case when retrieving A with the entity manager. The 
> > > > reference
> > > of
> > > > Object B is a doctrine proxy of Object B actually.
> > > > So when serializing A, reference to B will be set to NULL. And this
> > > > behaviour is explained in Doctrine Docs. They advice to not to
> > > > serialize Entities (that are being managed by an entity manager).
> > > > Now I&

[symfony-users] Re: SF2 Security (beta2) - Serializing User Entities - Blocking Issue

2011-05-23 Thread Roger Webb
done

On May 23, 12:26 pm, Luis Cordova  wrote:
> please can you use the same thread to reply to that serialize problem?
> it will help others to have it all into one place
>
>
>
>
>
>
>
> On Mon, May 23, 2011 at 12:23 PM, Roger Webb  wrote:
> > Until the BETA2 update I was getting warnings related to serializing
> > the User Entity, it is a breaking problem in beta2.  So, I googled
> > around and found this:
>
> >http://groups.google.com/group/symfony-users/browse_thread/thread/54c...
>
> > Following the advice there, I created serialize() and unserialize()
> > methods and had my "Users" class implement \Serializable.  I tried
> > returning an array, which through the following Exception:
>
> > "Symfony\Component\Security\Core\Authentication\Token
> > \UsernamePasswordToken::serialize() must return a string or NULL"
>
> > I returned null and it worked but it rendered the Entity returned by
> > $this->get('security.context') and it's twig counterpart useless
> > because it contained no data.
>
> > So, I tried imploding the array and returning that and was met with
> > the Exception noted above.
>
> > I also tried looking through the "Security" chapter in the book and
> > could not find any  information about how to or what to serialize.
> > Can anyone point me to a resource that explains how to do this in a
> > Symfony-appropriate way?
>
> > Roger
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to 
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: notice: serialize() __sleep

2011-05-23 Thread Roger Webb
Until the BETA2 update I was getting warnings related to serializing
the User Entity, it is a breaking problem in beta2.  So, I googled
around and found this:

http://groups.google.com/group/symfony-users/browse_thread/thread/54c...

Following the advice there, I created serialize() and unserialize()
methods and had my "Users" class implement \Serializable.  I tried
returning an array, which through the following Exception:

"Symfony\Component\Security\Core\Authentication\Token
\UsernamePasswordToken::serialize() must return a string or NULL"

I returned null and it worked but it rendered the Entity returned by
$this->get('security.context') and it's twig counterpart useless
because it contained no data.

So, I tried imploding the array and returning that and was met with
the Exception noted above.

I also tried looking through the "Security" chapter in the book and
could not find any  information about how to or what to serialize.
Can anyone point me to a resource that explains how to do this in a
Symfony-appropriate way?

Roger

On May 17, 1:58 am, Marco Pivetta  wrote:
> I usually build stuff like this when making a multi-step form with different
> http requests:
>
> request 1:
> $ns = new \Zend_Session_Namespace('test'); //don't care about it, I usually
> work with ZF
> /* We suppose this is my entity fetched by some kind of voodoo query or
> complex stuff that can be done only in step 1 (picker?) */
> $modifiedUser = $em->getRepository('My\User')->findOneBy(array('fullname' =>
> 'Marco Pivetta'));
> $em->detach($modifiedUser);
> $ns->user = $modifiedUser;
>
> request 2:
> $ns = new \Zend_Session_Namespace('test');
> //Bringing my user entity back to life!
> $modifiedUser = $ns->user;
> $em->merge($modifiedUser);
> $em->refresh($modifiedUser); //Yeah, this is overhead, but it solved a LOT
> of troubles in my case...
> $modifiedUser->doStuff();
> //Now again, for the next step! And so on and on and on...
> $em->detach($modifiedUser);
> $ns->user = $modifiedUser;
>
> request 3:
> //repeat stuff like request 2 here!
>
> Marco Pivetta
> @Ocramius http://marco-pivetta.com
>
> On 17 May 2011 04:53, Luis Cordova  wrote:
>
>
>
>
>
>
>
> > yes and if you find a resource or more styled example or post that can
> > clarify this further would be great
>
> > On Mon, May 16, 2011 at 9:48 PM, oscar balladares 
> > wrote:
> > > Another issue that I run into is:
> > > Let's say we have object A, and object A has refernce to Object B, both
> > are
> > > entities instances, and reference of B is actually a proxy.
> > > This is the case when retrieving A with the entity manager. The reference
> > of
> > > Object B is a doctrine proxy of Object B actually.
> > > So when serializing A, reference to B will be set to NULL. And this
> > > behaviour is explained in Doctrine Docs. They advice to not to
> > > serialize Entities (that are being managed by an entity manager).
> > > Now I'm facing this problem. Even using \Serializable interface. I read
> > > about a guy that hacked the source code of doctrine (proxies) to
> > > allow serialization but never explained how.
> > > So my big question is: If serializing entities is not adviced, how can I
> > > solve my use case?
> > > I'm implementing a shopping cart, and serializing products entities
> > > instances and saving them in a Session variable.
> > > I hate using arrays when I could achive the same with POO.
> > > But, I must remark that this is a Doctrine/PHP issue not a Symfony
> > Framework
> > > related one.
> > > I'll keep searching. Any usefull information will be posted here to help
> > > someone ;)
> > > 2011/5/16 Luis Cordova 
>
> > >> someone has to write about this case more clearly to explain to all
>
> > >> This example is perfect, although one more could be added
>
> > >> Even though is not sf2 related specifically I think that it has to be
> > >> explained since we are going to run into these kind of problems
>
> > >> Thanks
>
> > >> On Mon, May 16, 2011 at 10:43 AM, oscar balladares <
> > liebegr...@gmail.com>
> > >> wrote:
> > >> > Yes, you are right. I hadn't try out the ->detach() method :P Sorry. I
> > >> > saw a
> > >> > tutorial that seemed very convincing :P (it was very late when posted
> > >> > last
> > >> > email and I didn't try it till now).
> > >> > My apologies :F
>
> > >> > 2011/5/16 Marco Pivetta 
>
> > >> >> Careful! The entity manager's detach method does not return anything!
> > >> >> Marco Pivetta
> > >> >> @Ocramius
> > >> >>http://marco-pivetta.com
>
> > >> >> On 16 May 2011 08:55, oscar balladares  wrote:
>
> > >> >>> According what I have read so far, serialize/unserialize $entities
> > >> >>> with
> > >> >>> proxies associations is not advised.
> > >> >>> And of course, if you are saving objects in session() vars, it is an
> > >> >>> innecesary load to save proxies information.
> > >> >>> So, it is adviced to detach proxies from entities (in case where
> > >> >>> entites
> > >> >>> are retrieved with the en

[symfony-users] SF2 Security (beta2) - Serializing User Entities - Blocking Issue

2011-05-23 Thread Roger Webb
Until the BETA2 update I was getting warnings related to serializing
the User Entity, it is a breaking problem in beta2.  So, I googled
around and found this:

http://groups.google.com/group/symfony-users/browse_thread/thread/54ca0790fa861271/edffbbc8343af2d0?lnk=gst&q=__sleep#edffbbc8343af2d0

Following the advice there, I created serialize() and unserialize()
methods and had my "Users" class implement \Serializable.  I tried
returning an array, which through the following Exception:

"Symfony\Component\Security\Core\Authentication\Token
\UsernamePasswordToken::serialize() must return a string or NULL"

I returned null and it worked but it rendered the Entity returned by
$this->get('security.context') and it's twig counterpart useless
because it contained no data.

So, I tried imploding the array and returning that and was met with
the Exception noted above.

I also tried looking through the "Security" chapter in the book and
could not find any  information about how to or what to serialize.
Can anyone point me to a resource that explains how to do this in a
Symfony-appropriate way?

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Doxygen Annotations Broken in Beta2

2011-05-23 Thread Roger Webb
I stand corrected.  When placed in the *class* comment block,
@IgnoreAnnotation("fn") works.  Alos, upon reading the doxygen
documentation, \fn works just as well as @fn, so I recommend using
\fn, \param, etc to avoid having to put those @IgnoreAnnotation
annotations in every file.

On May 23, 11:01 am, Johannes Schmitt  wrote:
> As I said, you need to put it in the doc comment of the _class_ even if
> "@fn" is used in a method of that class.
>
> I understand that it might be a bit tedious to update your code at first,
> but being a bit stricter in the parsing process allows us to catch errors
> early on. This will reduce the time that you spend with searching for
> missing imports, typos, or just sitting there wondering why something
> doesn't work.
>
> Johannes
>
>
>
>
>
>
>
> On Mon, May 23, 2011 at 5:26 PM, Roger Webb  wrote:
> > The comment in question is below.  This is still throwing the same
> > error.  Also, it's generating this error based on the method.  Will I
> > have to put this annotation in every comment block that uses the "fn"
> > annotation, or just in the first comment of the file?
>
> > For the developers, it would IMHO be best if the Symfony/Doctrine
> > annotations were namespaced and did not adversely affect annotations
> > from other projects.
>
> >    /**
> >     * @IgnoreAnnotation("fn")
> >     * @fn loginAction
> >     *
> >     */
>
> > Thank you for your help,
>
> > Roger
>
> > On May 23, 10:17 am, Johannes Schmitt  wrote:
> > > Put an @IgnoreAnnotation("fn") in the doc comment of the class where this
> > > annotation is used.
>
> > > Johannes
>
> > > On Mon, May 23, 2011 at 5:05 PM, Roger Webb 
> > wrote:
> > > > Hey Everyone,
>
> > > > I'm using Doxygen for my documentation generation.  I updated to Beta2
> > > > and fixed all of the Doctrine annotations as described in the Update
> > > > Document and found that all of my doxygen annotations are causing an
> > > > exception to be thrown:
>
> > > > [Semantical Error] The annotation "@fn" in method ARN\UserBundle
> > > > \Controller\UserController::loginAction() was never imported.
>
> > > > Any ideas on a workaround?
>
> > > > Roger
>
> > > > --
> > > > If you want to report a vulnerability issue on symfony, please send it
> > to
> > > > security at symfony-project.com
>
> > > > You received this message because you are subscribed to the Google
> > > > Groups "symfony users" group.
> > > > To post to this group, send email to symfony-users@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > symfony-users+unsubscr...@googlegroups.com
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/symfony-users?hl=en
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Doxygen Annotations Broken in Beta2

2011-05-23 Thread Roger Webb
The comment in question is below.  This is still throwing the same
error.  Also, it's generating this error based on the method.  Will I
have to put this annotation in every comment block that uses the "fn"
annotation, or just in the first comment of the file?

For the developers, it would IMHO be best if the Symfony/Doctrine
annotations were namespaced and did not adversely affect annotations
from other projects.

/**
 * @IgnoreAnnotation("fn")
 * @fn loginAction
 *
 */

Thank you for your help,

Roger

On May 23, 10:17 am, Johannes Schmitt  wrote:
> Put an @IgnoreAnnotation("fn") in the doc comment of the class where this
> annotation is used.
>
> Johannes
>
>
>
>
>
>
>
> On Mon, May 23, 2011 at 5:05 PM, Roger Webb  wrote:
> > Hey Everyone,
>
> > I'm using Doxygen for my documentation generation.  I updated to Beta2
> > and fixed all of the Doctrine annotations as described in the Update
> > Document and found that all of my doxygen annotations are causing an
> > exception to be thrown:
>
> > [Semantical Error] The annotation "@fn" in method ARN\UserBundle
> > \Controller\UserController::loginAction() was never imported.
>
> > Any ideas on a workaround?
>
> > Roger
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Using Doctrine Entities without Symfony (beta2)

2011-05-23 Thread Roger Webb
Hey Everyone,

Another annotation issue with the SF2 Beta2 update.   I have a
separate doctrine_bootstrap.php to use my entities outside of Symfony
(for some SOAP services) and it seems that the
"setAnnotationNamespaceAlias" method has been removed from the
AnnotationReader, so I removed the call to it.  Now it's giving me the
"[Semantical Error] The annotation "@ORM\Table" in class [redacted]
was never imported."  I am, of course, trying to use the same entity
classes both inside and outside of SF2.

Any ideas?

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Doxygen Annotations Broken in Beta2

2011-05-23 Thread Roger Webb
Hey Everyone,

I'm using Doxygen for my documentation generation.  I updated to Beta2
and fixed all of the Doctrine annotations as described in the Update
Document and found that all of my doxygen annotations are causing an
exception to be thrown:

[Semantical Error] The annotation "@fn" in method ARN\UserBundle
\Controller\UserController::loginAction() was never imported.

Any ideas on a workaround?

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Presenting of SF2 - Guidance on Use of Logo and Content, etc.

2011-05-20 Thread Roger Webb
Hello Everyone,

In a few weeks I will be giving a presentation on Symfony2 to a local
group of web developers (comorichweb).  I have also submitted an
abstract to Strange Loop 2011 (a conference in St. Louis in
September).  I'm very much looking forward to sharing my
(overwhelmingly positive) experience developing on this framework and
encouraging others to do the same.

My question is, what are my boundaries here, and maybe this is a
question better directed toward Sensio Labs, but I thought I'd bring
it up on the open forum in case anyone else has the same question.
Obviously, I will not be, and have no reason to represent myself as
being affiliated with Sensio, but what about use of the Symfony Logo?
Also, there are some graphics in the documentation that could also
prove useful in explaining the framework, could I use some of those in
my slides?

Just looking for some generalized guidance.  Thanks.

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Forms - Cannot Store "0" in decimal field (0.0 works)

2011-05-19 Thread Roger Webb
Submitted.  Thanks.

On May 18, 6:31 pm, Bernhard Schussek  wrote:
> Hi Roger,
>
> Could you please create a ticket for 
> this?https://github.com/symfony/symfony/issues
>
> Thanks,
> Bernhard

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] SF2 Forms - Cannot Store "0" in decimal field (0.0 works)

2011-05-18 Thread Roger Webb
I'm using "money" field on a form and ran into a peculiar problem.  If
I enter in a plain zero, 0, I get no error or exception, but the field
is not updated in the database.  Any other integer value works, and
entering 0.0 works, but the plain 0, not so much.  My boss is not
pleased.

I can work around it if need be (update the request parameter before
binding it to the form, but that's not really a clean solution.

I tried a normal UPDATE query (using plain old SQL) using 0 as the
value for the decimal field and it ran and updated successfully.

Any suggestions?  (currency=USD, by the way)

Thanks,

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Fatal Error Using "date" widget

2011-05-12 Thread Roger Webb
Muchas Grasias!  That was easier than expected.  Could be problematic
for those on shared hosting, but I'm up and running.

For my fellow RHEL users, it's "yum install php-intl"

On May 12, 11:30 am, Luis Cordova  wrote:
> sudo apt-get install intl
>
>
>
>
>
>
>
> On Thu, May 12, 2011 at 11:11 AM, Matt Robinson  wrote:
> > Sounds like you're missing the PHP intl extension…?
>
> > On 12 May 2011, at 17:07, Roger Webb wrote:
>
> >> The Error:
>
> >> Fatal error: Call to undefined function Symfony\Component\Form
> >> \Extension\Core\DataTransformer\intl_get_error_code() in /var/www2/
> >> vendor/symfony/src/Symfony/Component/Form/Extension/Core/
> >> DataTransformer/DateTimeToLocalizedStringTransformer.php on line 84
>
> > […]
> >> Any ideas as to why this would be happening?
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to 
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Fatal Error Using "date" widget

2011-05-12 Thread Roger Webb
Do you *have* to have the intl extension to use the date widget?  Our
site is English only, and I don't see that changing.

Thanks for the reply.

On May 12, 11:11 am, Matt Robinson  wrote:
> Sounds like you're missing the PHP intl extension…?
>
> On 12 May 2011, at 17:07, Roger Webb wrote:
>
>
>
>
>
>
>
>
>
> > The Error:
>
> > Fatal error: Call to undefined function Symfony\Component\Form
> > \Extension\Core\DataTransformer\intl_get_error_code() in /var/www2/
> > vendor/symfony/src/Symfony/Component/Form/Extension/Core/
> > DataTransformer/DateTimeToLocalizedStringTransformer.php on line 84
>
> […]
> > Any ideas as to why this would be happening?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Fatal Error Using "date" widget

2011-05-12 Thread Roger Webb
The Error:

Fatal error: Call to undefined function Symfony\Component\Form
\Extension\Core\DataTransformer\intl_get_error_code() in /var/www2/
vendor/symfony/src/Symfony/Component/Form/Extension/Core/
DataTransformer/DateTimeToLocalizedStringTransformer.php on line 84

The Code:

>From the Form Class (extends AbstractType)
$builder->add('next_contact_date', 'date', array('input' =>
'datetime', 'widget' => 'text'));

In The Template:

{{ form_widget(borrower_form.next_contact_date) }}


Any ideas as to why this would be happening?

Thanks,

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Re : Re: Doctrine2 cache with Symfony2

2011-05-05 Thread Roger Webb
>From the Doctrine documentation (21. Caching)

"We also provide an ArrayCache driver which stores the data in a PHP
array. Obviously, the cache does not live between requests but this is
useful for testing in a development environment."

On May 5, 2:42 pm, winzou  wrote:
> I'm using array caching for the moment. Shouldn't it work even with the
> array driver for the cache? As it's in the same http request, array caching
> must persist data from the first SQL request until the second one. But it
> doesn't.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Doctrine2 cache with Symfony2

2011-05-05 Thread Roger Webb
I am using Doctrine with SF2 and APC.  I know that, in my case, the
class metadata is cached in the user cache.  The class files
themselves would probably appear in the system cache.  I found this by
looking at apc.php (if you're not sure about this look at the manual
on php.net)

To enable caching for Doctrine in Symfony, put this in your
config_prod.php (you won't want to use APC in dev):

doctrine:
orm:
metadata_cache_driver: apc
query_cache_driver: apc
result_cache_driver: apc


On May 5, 12:39 pm, winzou  wrote:
> Hi,
>
> Doctrine2 has a cache system. But does Symfony2 use it?
>
> I'm using FOS\UserBundle and on the page /user/{username}, if I'm logged
> into "test" user and want to see /user/test, then 2 requests are executed.
> And these two requests are exactly the same, namely something like
> $someObject->findUserBy('username', 'test');
> According to the webprofiler, no cache is used for the second request.
>
> So is there any configuration step to make Doctrine2 use the cache within a
> Symfony2 project?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Forms -

2011-05-05 Thread Roger Webb
Hi Bernhard,

Thank you so much for your reply.  Everything works perfectly.  There
was only one thing that needed to be changed.  The data in the
"preBind" callback was an associative array instead of a ContactInfo
entity.

Thanks again, I struggled with this form component for a couple of
days but I'm really loving it now.

Roger

On May 4, 3:15 pm, Bernhard Schussek  wrote:
> Hi Roger,
>
> You should never rely on the form data in your type class (as you've
> just discovered). When the form is constructed, you can never be
> certain that the data is already available and won't be changed.
>
> In your case, I recommend to add an event listener to the preBind and
> preSetData events that overrides the 'city' field.
>
>     class ContactType extends AbstractType {
>
>        public function buildForm(FormBuilder $builder, array $options) {
>            $factory = $builder->getFormFactory();
>
>            $refreshCity = function ($form, $state) use ($factory) {
>                $form->add($factory->createNamed('entity', 'city', null, array(
>                    'class' => 'Entity:Cities',
>                    'query_builder' => function (EntityRepository
> $repository) use ($state) {
>                        return $respository->createQueryBuilder('cities')
>                            ->select(array('cities', 'zip_codes'))
>                            ->innerJoin('cities.zip_codes', 'zip_codes')
>                            ->where('cities.states = :state')
>                            ->setParameter('state', $state);
>                    },
>                    'property' => 'city_name',
>                    'label' => 'City',
>                )));
>            };
>
>            $builder->addEventListener(Events::preSetData, function
> (DataEvent $event) use ($refreshCity) {
>                $form = $event->getForm();
>                $data = $event->getData();
>
>                if ($data instanceof ContactInfo) {
>                    $refreshCity($form, $data->getCity()->getState());
>                }
>            });
>
>            $builder->addEventListener(Events::preBind, function
> (DataEvent $event) use ($refreshCity) {
>                $form = $event->getForm();
>                $data = $event->getData();
>
>                if (isset($data['state'])) {
>                    $refreshCity($form, $data['state']);
>                }
>            });
>
> Obviously this is untested, but I think this should work (with
> probably minor modifications depending on your form).
>
> Bernhard

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 Forms -

2011-05-04 Thread Roger Webb
Hey Donald and Friends,

As requested, snippets of the relevant classes:

class ContactInfo {

/**
 * @orm:ManyToOne(targetEntity="Cities")
 * @orm:JoinColumn(name="city_id", referencedColumnName="city_id")
 */
private $cities;
}

class ContactType extends AbstractType {

public function buildForm(FormBuilder $builder, array $options) {
$state = $this->contact_info->getCity()->getState();

$city_qb = $this->entity_manager->createQueryBuilder()
  ->select(array('cities', 'zip_codes'))
  ->from('Entity:Cities', 'cities')
  ->innerJoin('cities.zip_codes', 'zip_codes')
  ->where('cities.states = :state')
  ->setParameter('state', $state);

$builder->add('city', 'entity', array(
'class' => 'Entity:Cities',
'query_builder' => $city_qb,
'property'  => 'city_name',
'label' => 'City',
));


}
}


On May 4, 10:38 am, Roger Webb  wrote:
> I posted this issue on the dev list as well (maybe not the right
> place).
>
> I have a "ContactInfo" entity that has a relationship to a "City"
> entity (ManyToOne).  I use an "entity" type to represent the "City" in
> the form. I also have a "state" field (US) which is also of the
> "entity" type.  When the "state" is changed I use an AJAX request to
> re-populate the "city" select with cities from the selected state.
>
> I create the form like this:
>
> $contact = $em->getRepository('Entity:ContactInfo')->findByXYZ(...);
> $contact_form = $this->get('form.factory')->create(new
> ContactInfoType($entity_manager), $contact);
>
> At this point the "contact_form" is created, data is set, all is
> well.
> *** important ***:  The "city" entity field is populated based on what
> is in the database, not what was submitted.
>
> If the state was changed, and a city from a different state than what
> was originally in the database was chosen, everything fails.  The form
> is invalid, and the appropriate city is not set for the Contact.  This
> is because the "city" choice field was populated with cities from the
> previously stored state when FormFactory::create() was called and the
> selected city is not an available option in the "city" field.
>
> I tried a messy solution to try to get around this, and passed the
> state I wanted to populate the city choice with as an argument to the
> constructor of ContactInfoType, but this caused the same problem, only
> backwards.  The new cities were populated and when it tried to
> setData() on the original "contact_info" (as it was in the database),
> it fails because *that* city isn't an option in the current form.
>
> I'm at my wits end with this one.  Any ideas?  please...
>
> Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] SF2 Forms -

2011-05-04 Thread Roger Webb
I posted this issue on the dev list as well (maybe not the right
place).

I have a "ContactInfo" entity that has a relationship to a "City"
entity (ManyToOne).  I use an "entity" type to represent the "City" in
the form. I also have a "state" field (US) which is also of the
"entity" type.  When the "state" is changed I use an AJAX request to
re-populate the "city" select with cities from the selected state.

I create the form like this:

$contact = $em->getRepository('Entity:ContactInfo')->findByXYZ(...);
$contact_form = $this->get('form.factory')->create(new
ContactInfoType($entity_manager), $contact);

At this point the "contact_form" is created, data is set, all is
well.
*** important ***:  The "city" entity field is populated based on what
is in the database, not what was submitted.

If the state was changed, and a city from a different state than what
was originally in the database was chosen, everything fails.  The form
is invalid, and the appropriate city is not set for the Contact.  This
is because the "city" choice field was populated with cities from the
previously stored state when FormFactory::create() was called and the
selected city is not an available option in the "city" field.

I tried a messy solution to try to get around this, and passed the
state I wanted to populate the city choice with as an argument to the
constructor of ContactInfoType, but this caused the same problem, only
backwards.  The new cities were populated and when it tried to
setData() on the original "contact_info" (as it was in the database),
it fails because *that* city isn't an option in the current form.


I'm at my wits end with this one.  Any ideas?  please...

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Issues with Entity Fields in SF2 Form Component

2011-05-03 Thread Roger Webb
Greetings,

I've been struggling with the new form component, particularly with
the "entity" choice fields.

I have a "ContactInfo" Entity with some scalar fields (first_name,
address, etc) and a ManyToOne relationship with "Cities".  "Cities"
has a ManyToOne relationship with "States"

class ContactInfo {
/** orm:ManyToOne(...) */
private $cities;

function setCity($city) { $this->cities = $city; }
}

class Cities {
/** orm:ManyToOne(...) */
private $states
}

// In ContactType::buildForm()

$builder->add('city', 'entity', array(
'class' => 'Entity:Cities',
'query_builder' => $city_qb,
'property'  => 'city_name',
'label' => 'City',
));

It's pretty much the same for the "state" field.

The first issue is a dependency on the EntityManager if we want to use
an "entity" field in the form (it requires a QueryBuilder).  I passed
it in via the constructor and all is well, but if there is access to
the EntityManager from within AbstractType::buildForm().

The second issue:  Every time, whether the city changes or not, an
UPDATE query is created for the city:

UPDATE cities SET city_name = ?, county = ?, latitude = ?, longitude
= ? WHERE city_id = ?
Parameters: [columbia, boone, 38.896439, -92.246277, '5533']

The city should *never* be updated.  How do I stop this?


The third (***blocking***) issue:

I have an AJAX setup where I re-populate the "cities" drop down when
the state changes.  If I do *not* change the state, the city saves
fine.  If the state changes, $form->isValid() returns false and no
changes are committed to the database.  The AJAX method in question
*only* replaces the "" tags in the select and works as
expected.


Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: SF2 - User Impersonation Unable to Switching Back

2011-04-27 Thread Roger Webb
Also, does anyone know how to tell if the logged in user is being
"impersonated"?  I, of course, would like to have a link up top to
switch back to the original user when we're impersonating one.


On Apr 27, 3:20 pm, Roger Webb  wrote:
> Greetings,
>
> I've set up a system using SF2 Security and User Impersonation.
>
> Relevant lines from config.yml
>
> firewalls:
>     user:
>         switch_user { role: ROLE_USER_ADMIN }
>
> Switching to a user with "http://www.mydomain.com/blah?
> _switch_user=username" works fine, but I am unable to switch back with
> anything like "http://www.mydomain.com/blah?_switch_user=_exit";.
> Instead I am redirected to the login path with the impersonated user
> still logged in?
>
> Any ideas?
>
> Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] SF2 - User Impersonation Unable to Switching Back

2011-04-27 Thread Roger Webb
Greetings,

I've set up a system using SF2 Security and User Impersonation.

Relevant lines from config.yml

firewalls:
user:
switch_user { role: ROLE_USER_ADMIN }

Switching to a user with "http://www.mydomain.com/blah?
_switch_user=username" works fine, but I am unable to switch back with
anything like "http://www.mydomain.com/blah?_switch_user=_exit";.
Instead I am redirected to the login path with the impersonated user
still logged in?

Any ideas?

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Swiftmailer - Multiple Transports in SF2

2011-04-13 Thread Roger Webb
Hey Everyone,

I have a situation where, based on different criteria, I have to send
out messages from one of two different domains (ie. same user, 2
different email addresses).  I can't find any documentation showing
how to configure multiple mailers.

Example:

This is from the docs

swiftmailer:
transport:  smtp
encryption: ssl
auth_mode:  login
host:   smtp.gmail.com
username:   your_username
password:   your_password

So, maybe something like this:

swiftmailer:
   mailer_a:
   transport: smtp
   host: mail.domaina.com
   username: x
   ...
   mailer_b:
   transport: smtp
   host: mail.domainb.com
   username: y
Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Jobeet (doctrine help)!

2011-04-04 Thread Roger Webb
Hello again,

Here is a more concrete example:

class UserTable extends Doctrine_Table {

public function findActiveUsersByUsername($username) {
return Doctrine_Query::create()
   ->from('Users u')
   ->where('u.username = ?', $username)
   ->andWhere(u.active = 1)
   ->execute();
}

}

$users = Doctrine_Core::getTable('User')-
>findActiveUsersByUsername('john_smith');

As you can see in the example, we use Doctrine_Query in the Table
Class to retrieve our users in exactly the same way that we would
without the Table Class, but leaving it inside the Table Class allows
us to re-use this query over and over.  If you're sure that you will
only use the query you created in one place, by all means, leave it
outside of the Table Class, but if you think you might use it in more
than one place, put it in a function.

Roger


On Mar 31, 8:52 pm, FHoerth  wrote:
> I Just posted my answer but it seems that was an error, if tomorrow
> doesn't appear I will answer again.
> Thank you for answering Roger
>
> On 1 abr, 00:13, Roger Webb  wrote:
>
> > As I best understand it, the "table" object is supposed to act as a
> > repository.  You would, ideally, add methods to the table class to
> > retrieve instances of 'tableClass'.
>
> > It may be better illustrated with an example:
>
> > You have a class(model) User.  In your UserTable class you might make
> > a method called "findActiveUserByUsername()" to find all active
> > users.
>
> > If you were to use Doctrine_Query::create()->from('User 
> > u')->where('u.active = 1');  you would get the same result, but your query
>
> > would not be re-usable.
>
> > Roger
>
> > On Mar 31, 1:54 pm, FHoerth  wrote:
>
> > > Hi!
> > > Can someone explain me what is the difference between:
>
> > > $this->var = Doctrine_Core::getTable('tableClass')-
>
> > > >createQuery('alias')->where('alias.column > ?', date);
>
> > > and this?
>
> > > $this->var = Doctrine_Query::create()->from('tableClass alias')-
>
> > > >where('alias.column > ?', date);
>
> > > Why not using a single method?
>
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How to extend from an app's template now?

2011-04-01 Thread Roger Webb
Looks like you beat me too it.

Did you clear app/cache?  I had problems there.  You also have to
change everything that has the "Bundle" suffix.  It's a lot of find/
replace on all of your templates (every template that "extends"
another).

Roger

On Apr 1, 11:09 am, Roger Webb  wrote:
> If you just upgraded to PR9, the base template is now in app/Resources/
> base.html.twig
>
> https://github.com/symfony/symfony/blob/master/UPDATE.md
>
> The upgrade from PR8 to PR9 was a bit more painful that previous
> ones.  Read the update document thoroughly.
>
> Roger
>
> On Apr 1, 9:45 am, Gustavo Adrian  wrote:
>
> > Hi,
>
> > I have in one of my bundle's templates:
>
> > {% extends "::layout.html.twig" %}
>
> > This extended from app/views/layout.html.twig. After updating Symfony it
> > throws an exception:
>
> > "Unable to find template ""::layout.html.twig"". at line 0"
>
> > How should I extend now from application specific templates?
>
> > NOTE: I already moved app/views/layout.html.twig to
> > app/Resources/views/layout.html.twig , but it still doesn't work.
>
> > Thanks!
>
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: How to extend from an app's template now?

2011-04-01 Thread Roger Webb
If you just upgraded to PR9, the base template is now in app/Resources/
base.html.twig

https://github.com/symfony/symfony/blob/master/UPDATE.md

The upgrade from PR8 to PR9 was a bit more painful that previous
ones.  Read the update document thoroughly.

Roger

On Apr 1, 9:45 am, Gustavo Adrian  wrote:
> Hi,
>
> I have in one of my bundle's templates:
>
> {% extends "::layout.html.twig" %}
>
> This extended from app/views/layout.html.twig. After updating Symfony it
> throws an exception:
>
> "Unable to find template ""::layout.html.twig"". at line 0"
>
> How should I extend now from application specific templates?
>
> NOTE: I already moved app/views/layout.html.twig to
> app/Resources/views/layout.html.twig , but it still doesn't work.
>
> Thanks!

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Jobeet (doctrine help)!

2011-03-31 Thread Roger Webb
As I best understand it, the "table" object is supposed to act as a
repository.  You would, ideally, add methods to the table class to
retrieve instances of 'tableClass'.

It may be better illustrated with an example:

You have a class(model) User.  In your UserTable class you might make
a method called "findActiveUserByUsername()" to find all active
users.

If you were to use Doctrine_Query::create()->from('User u')-
>where('u.active = 1');  you would get the same result, but your query
would not be re-usable.

Roger

On Mar 31, 1:54 pm, FHoerth  wrote:
> Hi!
> Can someone explain me what is the difference between:
>
> $this->var = Doctrine_Core::getTable('tableClass')-
>
> >createQuery('alias')->where('alias.column > ?', date);
>
> and this?
>
> $this->var = Doctrine_Query::create()->from('tableClass alias')-
>
> >where('alias.column > ?', date);
>
> Why not using a single method?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: link_for() /put/delete on twig views??

2011-03-28 Thread Roger Webb
If your route is:

my_route:
pattern:  /my/route
defaults { _controller: MyBundle:MyController:doSomething }

you would use path('my_route') to get a relative URL or simply
url('my_route') to get a fully qualified URL.

If you're using a slug:
my_route:
/my/route/{some_param}

You'd do something like this:  path('my_route, { 'some_param': xxx })

Roger

On Mar 28, 4:59 pm, oscar balladares  wrote:
> Hi everyone. [?]
>
> I would like to implement something like the url_for() helper of S1 on S2.
>
> I've been reading Twig docs, they have macros to declare some functions,
> I could easily implement one to achieve a  tag with Javascript
> embedded
> to simulate a PUT/DELETE button.
>
> But on S1, the link_for() also included a random generated token that
> validates the authenticity of the request.
>
> How can I achieve this on Twig? Should I ask on a Twig mailing list?
>
> Regards [?]
>
>  349.gif
> 1KViewDownload
>
>  360.gif
> < 1KViewDownload

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Newcomer: start symfony1 or Symfony2?

2011-03-28 Thread Roger Webb
Symfony2 is definitely stable enough to start a site with.  I've had
one running since PR6.  You must, however, keep up with the updates.
Each time I've updated I've had to spend about a half hour or so
updating the things that have changed.  A little change in the
configuration here, they renamed an interface there, etc.  If you keep
up with the updates, it's pretty easy to maintain.

I didn't have the pleasure of working with the 1.x line, so my
decision was more based on the fact that Symfony 1.x will be out of
maintenance in a couple of years, and our site will be around for much
longer than that.  So, I've been willing to do a little editing by
hand and keep up with the changes, and so far I've been quite
impressed.  Community support has been outstanding, the framework has
been easy to use and wicked fast, and the integration with Doctrine 2
has made security and form-field generation a breeze.  In fact,
Doctrine was what originally drew me to Symfony.

If your going to be maintaining the site for awhile, I think the
investment in learning Symfony2 will be well worth your while.

Roger


On Mar 28, 3:41 pm, oscar balladares  wrote:
> +1 Symfony2.
>
> If you start studying hard, you could easily get the necessary knowledge in
> 1 month.
> I suggest 3 hours a day at least.
>
> To help you out deciding, I must remark some point:
>
> S1 has some good features like generating forms, and CRUD files and
> directories in one command
> (you have to write up a yml file with your database logic), in S2 we do not
> have that magic yet.
>
> S2 is under frenetic developement, so docs are not In Sync with the commits
> done to the core framework.
> (They have docs on github, they are the most up to date docs, but not are
> fully in Sync with commits)
>
> Mailing list is a must with S2; S1 in the other hand, has a lot of
> docs/books/tutorials etc, so mailing
> list would be usefull only if you have a philosophical question [?].
>
> S1 has an admin module generator, so with few fixes you will have a fully
> functional admin backend.
> I must warn you that I don't like it very much, but tons of people love it.
> S2 has a Bundle (plugin) under
> developement to achieve this. (it is not ready for production yet).
>
> I quit mastering S1 in order to focus all my efforts on S2, and I dont
> regret at all. Im very happy for my
> decision.
>
> Knowing you have CakePHP under the hud, you can throw yourself into the S2
> ocean.
>
> 2011/3/28 violyn 
>
> > i would go with symfony2 for sure
>
> >  --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en
>
>
>
>  360.gif
> < 1KViewDownload

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: EntityChoiceField - Is it going away?

2011-03-28 Thread Roger Webb
It's gone of the api.symfony-reloaded.org/master documentation.  I see
it here now:  
http://api.symfony.com/2.0/Symfony/Component/Form/EntityChoiceField.html

I take it the symfony-reloaded one is no longer being maintained.  It
might be a good idea to take that site down if that's the case.

Roger

On Mar 28, 3:32 pm, Roger Webb  wrote:
> Subject says it all.  I see it's still in the right place in the
> source tree (under vendor/), but I noticed it was missing from the
> master documentation.  This has me worried, as I use this in several
> parts of my site.  It's not a big deal if it is going away, but I need
> to know so I can refactor.
>
> Thanks,
>
> Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] EntityChoiceField - Is it going away?

2011-03-28 Thread Roger Webb
Subject says it all.  I see it's still in the right place in the
source tree (under vendor/), but I noticed it was missing from the
master documentation.  This has me worried, as I use this in several
parts of my site.  It's not a big deal if it is going away, but I need
to know so I can refactor.

Thanks,

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: User Authentication

2011-03-10 Thread Roger Webb
Hey Luc and Everyone,

I think part of the problem you guys were having was that your login
path was locked out.  Use security:false or
IS_AUTHENTICATED_ANONYMOUSLY like in luc's example.

FYI as well, I am running off a sandbox and was able to get it
working.  Went through most of the problems you guys had, but the
documentation is improving (make sure to read it *all*, there are no
*small* details.

Roger

On Mar 9, 9:05 am, Luc Vandesype  wrote:
> here mine, worked!
>
> security:
>     encoders:
>         Bundles\AdminBundle\Entity\AdminUser: plaintext
>
>     providers:
>         main:
>             entity: { class: AdminBundle:AdminUser, property: username }
>
>     firewalls:
>         backend:
>             pattern: /admin.*
>             form_login:
>                 check_path: /admin/login-check
>                 login_path: /admin/login
>                 remember_me: false
>                 post_only: true
>                 default_target_path: /admin/
>             logout: { path: /admin/logout, target: /admin/login }
>
>         frontend:
>             pattern:  /.*
>             security: false
>
>     access_control:
>       - { path: /admin/login.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
>       - { path: /admin.*, role: ROLE_ADMIN }
>       - { path: /.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
>
> 2011/3/9 Philip Cole 
>
>
>
> > Hi Florian,
>
> > Thanks for your help. I tried this and it doesn't work either.
> > I have no idea what is wrong and I think the latest docs (even on
> > github)
> > may be out of synch or something is broken. Although I do not rule out
> > that it could be my fault.S
> > Does somebody have form based user login working (without the FOS
> > UserBundle) with the latest Symfony code (from the master branch on
> > github)?
>
> > Thanks,
>
> > Philip
>
> > On Mar 9, 7:03 am, Florian Semm  wrote:
> > > Am 08.03.2011 15:56, schrieb Donald:
>
> > > > OK, I modified the security.yml file as follows:
>
> > > > # app/config/security.yml
> > > > security:
> > > >    access_denied_url: /error403
>
> > > >    providers:
> > > >      entity:
> > > >        entity: { class: UserBundle:User, property: username }
>
> > > >    firewalls:
> > > >      main:
> > > >        form_login:
> > > >          check_path:   /login_check
> > > >          login_path:   /login
> > > >          failure_path: /login
> > > >        logout:     true
>
> > > > And I still get the following error after submitting the login form:
>
> > > > Unable to find the controller for path "/login_check". Maybe you
> > > > forgot to add the matching route in your routing configuration?
>
> > > > On Mar 7, 2:27 pm, Christophe COEVOET  wrote:
> > > >> Le 07/03/2011 21:24, Donald a crit :>  Christophe,
>
> > > >>> Thanks for the response.
> > > >>> I'm aware that there are certain features missing from my example
> > > >>> above. But I'm trying to keep this test case very limited so I can
> > > >>> concentrate on the problem at hand; being that the check
> > > >>> authentication is not working.
> > > >> Sure, but your issue can be this: when the authentication fails, the
> > > >> request is not redirected so you need to have a controller. Thus it
> > > >> would display the authentication error (which also appear in the logs
> > if
> > > >> you log debug messages)
>
> > > >> --
> > > >> Christophe | Stof
>
> > > hi,
>
> > > i think something is missing in your config. add
> > >          "anonymous: true" and "pattern: .*"
> > > to your config. it looks like this:
>
> > > security:
> > >    access_denied_url: /error403
>
> > >    providers:
> > >      entity:
> > >        entity: { class: UserBundle:User, property: username }
>
> > >    firewalls:
> > >      main:
> > >        pattern: .*
> > >        form_login:
> > >          check_path:   /login_check
> > >          login_path:   /login
> > >          failure_path: /login
> > >        logout:     true
> > >        anonymous: true
>
> > > FS
>
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> > security at symfony-project.com
>
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to symfony-users@googlegroups.com
> > To unsubscribe from this group, send email to
> > symfony-users+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/symfony-users?hl=en
>
> --
> Luc Vandesype -http://www.neoplug.com

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Using Symfony2 Session and normal PHP Session Side-by-side

2011-03-09 Thread Roger Webb
Greetings,

We have a large site/database in place and re-writing the whole thing
all at one simply isn't an option.  So, I would like to start
converting the site in pieces as I have time allotted.  The problem
arose when I tried to access $_SESSION inside my controller.  It was
empty.

I gathered from the profiler that there are two cookies set, PHPSESSID
and _SESS.  From what I can tell, Symfony is using _SESS and PHPSESSID
points to the original (out of the box) PHP session.  I tried
switching up with session_id(...) and session_start().  What ended up
happening was that the PHPSESSID and _SESS were now equal.

Does anyone know of a good way to be able to have access to both
sessions side-by-side?

Roger

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: User Authentication

2011-03-04 Thread Roger Webb
First of all, lose the controller argument on your security check
route. There is no "checkAction" needed.  Symfony handles checking the
password and forwarding to the appropriate route.

If you're using form authentication you need a textfield named
"_username" and one named "_password".  The "action" for your form
should be the "check_path" specified in your configuration.  If you
don't specify one "/login/check" is the default I think.

What UserProvider are you using?  I'm set up using Doctrine Entity and
can help you further with that for sure.

Some more insight into your configuration would help me help you
better.

Cheers.

Roger

On Mar 4, 7:51 am, Donald  wrote:
> Here's some more info on what I'm trying to accomplish:
>
> #UserBundle/Resources/config/routing.yml
> _security_login:
>   pattern:  /login
>   defaults: { _controller: UserBundle:Security:login }
>
> _security_check:
>   pattern:  /login_check
>   defaults: { _controller: UserBundle:Security:check }
>
> #UserBundle/Controller/SecurityController.php
> class SecurityController extends Controller {
>
>   public function loginAction($_format) {
>     $request = $this->get('request');
>
>     if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
>
>       $error = 
> $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
>
>     } else {
>       $error = 
> $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
>
>     }
>
>     return $this->render('UserBundle:user:login.' . $_format . '.php',
> array(
>       // last username entered by the user
>       '_username' => 
> $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
>
>       'error'    => $error,
>     ));
>   }
>
>   public function checkAction() {
>     // what goes here?
>   }
>
> }
>
> Do I even need the checkAction method? If so, how do I authenticate
> the user? If I don't need the checkAction method, how exactly do I
> authenticate a user?
>
> On Mar 3, 4:29 pm, Donald  wrote:
>
> > Unfortunately the authentication docs there aren't updated at all.
>
> > So I'm still looking for advice...
>
> > On Mar 3, 3:18 pm, Donald  wrote:
>
> > > I wasn't aware that was on github. I'll go check it out immediately.
>
> > > Thanks!
>
> > > On Mar 3, 3:07 pm, olimination  wrote:
>
> > > > Hi,
>
> > > > I sometimes use the master documentation on GitHub and there you find
> > > > some updated documentations:
>
> > > >https://github.com/symfony/symfony-docs
>
> > > > greets,
> > > > Oli
>
> > > > On Mar 3, 8:38 pm, Donald  wrote:
>
> > > > > Hi,
>
> > > > > I'm working with the master branch of the Symfony 2 sandbox, and I'm
> > > > > trying to get user authentication to work. Obviously things have
> > > > > changed a great deal since the last preview release, so I'm hoping to
> > > > > get some pointers.
>
> > > > > I've managed to get everything setup to the point where I'm being
> > > > > redirected to the /login_check url. I got the impression from the
> > > > > Symfony Reloaded docs that I don't actually have to authenticate the
> > > > > user myself, and that it would be handled automatically by the
> > > > > framework. It doesn't seem to be working that way in practice though.
>
> > > > > Do I need to authenticate the user myself by implementing an action
> > > > > for the /login_check URL, and if so, how exactly do I do that?
> > > > > SecurityContext getUser() method doesn't seem to exist anymore, and
> > > > > I've been digging around the source code all day with no luck.
>
> > > > > Thank in advance for any help.
>
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Symfony2 Security - Role Combinations

2011-03-02 Thread Roger Webb
I couldn't find anything in the "Authorization" section of the
documentation covering this.

Is there a way to restrict access to a pattern by forcing a user to
have (role_a AND role_b) or (role_a OR role_b)?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Normal and ajax version for a template

2011-02-27 Thread Roger Webb
 $this->container->get('request')->isXmlHttpRequest()

can also be shortened to $this->get('request')->isXmlHttpRequest()


On Feb 27, 1:58 pm, Christophe COEVOET  wrote:
> Le 27/02/2011 20:48, Christophe Beyer a crit :> Hello,
>
> > I want to display a template in two modes : the "normal" mode,
> > embedded in the main layout, and an ajax mode; without duplicate my
> > template of course.
>
> > 1. In my controller, how can I check if the requested url is an ajax
> > request (without adding any parameter) ?
>
> $this->container->get('request')->isXmlHttpRequest()
>
> > 2. In the Twig file, I tried to make this :
> > {% if ajax %}{% extends "MyBundle::layout.twig.html" %}{% endif %}
> > but it doesn't work.
>
> {% extends ajax ? "" : "MyBundle::layout.twig.html" %}
>
> Regards
>
> --
> Christophe | Stof

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: EntityChoiceField Issue with QueryBuilder params

2011-02-23 Thread Roger Webb
This worked.  Thanks.

On Feb 22, 12:25 pm, Nathan Mudie  wrote:
> You need to use the use option for the closure as the variable your
> trying to use isn't in the correct scope.
>
> See example 3 on this page:http://php.net/manual/en/functions.anonymous.php
>
> Your code will look like this:
>
> 'query_builder' => function($repository) use ($state_id) {
>      return $repository->createQueryBuilder('cities')-
>
> >where('cities.state_id = :state_id')->setParameter('state_id',
> $state_id);
> }
>
> On Feb 23, 1:19 am, Roger Webb  wrote:
>
> > Another interesting point to add.  If I define(STATE_ID, $state_id)
> > and pass that to the QueryBuilder setParameter method it works.
>
> > On Feb 21, 3:12 pm, Roger Webb  wrote:
>
> > > Greetings,
>
> > > Ran into an issue with the EntityChoiceField.  I am rendering a SELECT
> > > field with city names.  If I use a literal value (ie. 2) in the
> > > query_builder param of the EntityChoiceField everything works
> > > perfectly.  If I substitute that with a variable value I get an empty
> > > select.  Also, I have printed out the value of the state_id from the
> > > request and it prints the correct value.
>
> > > Any help would be appreciated.
>
> > > Roger
>
> > > Here is the code where I create the field.
>
> > > This is the code for the controller that is fetching the select field
>
> > > $params['city_select'] = 
> > > $this->forward('UserBundle:Ajax:getCitySelectByStateId', array(),
>
> > > array('state_id' => 2))->getContent();
>
> > > $params gets passed to the view
>
> > > This is the code from my AjaxController which should return these db
> > > driven fields on demand.
>
> > >     public function getCitySelectByStateIdAction() {
> > >         $em = $this->get('doctrine.orm.entity_manager');
> > >         $request = $this->get('request');
>
> > >         if(!$request->get('state_id'))
> > >                 return new Response('ERROR');  //NOT GETTING AN ERROR
> > > HERE
>
> > >         $state_id = (int)$request->get('state_id');
>
> > >         $field = new EntityChoiceField($name, array(
> > >                 'em' => $em,
> > >                 'class' => 'ARN\EntityBundle\Entity\Cities',
> > >                 'property' => 'city_name',
> > >                 'query_builder' => function($repository) {
> > >                      return 
> > > $repository->createQueryBuilder('cities')->where('cities.state_id = 
> > > :state_id')->setParameter('state_id',
>
> > > $state_id);
> > >                                            }
> > >         ));
>
> > >         return $this->render('UserBundle:Ajax:form_field.html.twig',
> > > array('field' => $field));
> > >     }
>
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: EntityChoiceField Issue with QueryBuilder params

2011-02-22 Thread Roger Webb
Another interesting point to add.  If I define(STATE_ID, $state_id)
and pass that to the QueryBuilder setParameter method it works.

On Feb 21, 3:12 pm, Roger Webb  wrote:
> Greetings,
>
> Ran into an issue with the EntityChoiceField.  I am rendering a SELECT
> field with city names.  If I use a literal value (ie. 2) in the
> query_builder param of the EntityChoiceField everything works
> perfectly.  If I substitute that with a variable value I get an empty
> select.  Also, I have printed out the value of the state_id from the
> request and it prints the correct value.
>
> Any help would be appreciated.
>
> Roger
>
> Here is the code where I create the field.
>
> This is the code for the controller that is fetching the select field
>
> $params['city_select'] = 
> $this->forward('UserBundle:Ajax:getCitySelectByStateId', array(),
>
> array('state_id' => 2))->getContent();
>
> $params gets passed to the view
>
> This is the code from my AjaxController which should return these db
> driven fields on demand.
>
>     public function getCitySelectByStateIdAction() {
>         $em = $this->get('doctrine.orm.entity_manager');
>         $request = $this->get('request');
>
>         if(!$request->get('state_id'))
>                 return new Response('ERROR');  //NOT GETTING AN ERROR
> HERE
>
>         $state_id = (int)$request->get('state_id');
>
>         $field = new EntityChoiceField($name, array(
>                 'em' => $em,
>                 'class' => 'ARN\EntityBundle\Entity\Cities',
>                 'property' => 'city_name',
>                 'query_builder' => function($repository) {
>                      return 
> $repository->createQueryBuilder('cities')->where('cities.state_id = 
> :state_id')->setParameter('state_id',
>
> $state_id);
>                                            }
>         ));
>
>         return $this->render('UserBundle:Ajax:form_field.html.twig',
> array('field' => $field));
>     }

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] EntityChoiceField Issue with QueryBuilder params

2011-02-21 Thread Roger Webb
Greetings,

Ran into an issue with the EntityChoiceField.  I am rendering a SELECT
field with city names.  If I use a literal value (ie. 2) in the
query_builder param of the EntityChoiceField everything works
perfectly.  If I substitute that with a variable value I get an empty
select.  Also, I have printed out the value of the state_id from the
request and it prints the correct value.

Any help would be appreciated.

Roger

Here is the code where I create the field.

This is the code for the controller that is fetching the select field

$params['city_select'] = $this-
>forward('UserBundle:Ajax:getCitySelectByStateId', array(),
array('state_id' => 2))->getContent();

$params gets passed to the view

This is the code from my AjaxController which should return these db
driven fields on demand.


public function getCitySelectByStateIdAction() {
$em = $this->get('doctrine.orm.entity_manager');
$request = $this->get('request');

if(!$request->get('state_id'))
return new Response('ERROR');  //NOT GETTING AN ERROR
HERE

$state_id = (int)$request->get('state_id');

$field = new EntityChoiceField($name, array(
'em' => $em,
'class' => 'ARN\EntityBundle\Entity\Cities',
'property' => 'city_name',
'query_builder' => function($repository) {
 return $repository->createQueryBuilder('cities')-
>where('cities.state_id = :state_id')->setParameter('state_id',
$state_id);
   }
));

return $this->render('UserBundle:Ajax:form_field.html.twig',
array('field' => $field));
}

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en