8000 Warning: Illegal offset type in isset or empty in/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php line 180 · Issue #11188 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Warning: Illegal offset type in isset or empty in/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php line 180 #11188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cesarve77 opened this issue Jun 20, 2014 · 9 comments

Comments

@cesarve77
Copy link
/**
     * {@inheritdoc}
     *
     * @throws \InvalidArgumentException
     */
    public function getManager($name = null)
    {
        if (null === $name) {
            $name = $this->defaultManager;
        }
//line 181
        if (!isset($this->managers[$name])) {
            throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
        }

        return $this->getService($this->managers[$name]);
    }

for any reason the name is a object, this happen when I´m trying to overwrite a form type.
example:

class AddressType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('country', 'chained_select', array('mapped' => false, 'class' => 'cesarve77\\ChainedSelectBundle\\Entity\\Country'));
        $builder->add('state', 'chained_select', array('mapped' => false,'class' => 'cesarve77\\ChainedSelectBundle\\Entity\\State'));
        $builder->add('city', 'chained_select', array('mapped' => true, 'class' => 'cesarve77\\ChainedSelectBundle\\Entity\\City'));
        $builder
            ->add('address');
    }

custom type chained_select

class ChainedSelectType extends AbstractType
{


    public function buildForm(FormBuilderInterface $builder, array $options)
    {
       $builder->addEventSubscriber(new AddChainedSelectSubscriber());
    }

in subscriber:

 public function preSetData(FormEvent $event)
    {

        $form = $event->getForm();
        $data=$event->getData();
// custom logic for change the $options
        $form->add($form->getConfig()->getName(),'entity',$options);
}
@stof
Copy link
Member
stof commented Jun 20, 2014

your error message tells that the error is in Doctrine Common. Why are you opening the issue in the Symfony project ?

@stof
Copy link
Member
stof commented Jun 20, 2014

OK, after fixing the markup so that code snippet appear properly, it looks like an issue somewhere in the form later. Can you show how your custom logic looks like ?

@cesarve77
Copy link
Author

This Is happen in symfony, but i can move it.

I really don't need to change the options, If I use the same options i got the error.

@cesarve77
Copy link
Author

@thedamnedrhino
Copy link

I faced a similar problem.In my case the name was an instance of the entity manager itself.I was trying to modify a forms options in the FormEvents::POST_SET_DATA.So I retrieved the previous Options using $form->get($childName)->getConfig()->getOptions() then modified it's query_builder key, but I got the error mentioned.So I unset the em key in the retrieved options and it was fixed.

@ro0NL
Copy link
Contributor
ro0NL commented Jun 17, 2016

Our "workaround"

$options = $form->getConfig()->getOptions();
if (isset($options['em']) && $options['em'] instanceof EntityManagerInterface) {
    // https://github.com/symfony/symfony/issues/11188
    $options['em'] = 'default'; // we only have 1 entity manager, so works for now :)
}

@xabbuh
Copy link
Member
xabbuh commented Dec 17, 2016

@cesarve77 @thedamnedrhino @ro0NL Can anyone of you fork the Symfony Standard Edition and make the changes that are necessary to reproduce your issue?

@ro0NL
Copy link
Contributor
ro0NL commented Dec 17, 2016

I think it's solved with #12251

This issue is from Jun 20 2014, the PR is added on Oct 18 2014.. so it could actually be. I have no access anymore to the repo i once applied my patch to :(

@xabbuh
Copy link
Member
xabbuh commented Dec 17, 2016

Okay, closing for now then. If anyone is still experiencing this issue, please provide a failing test case or some code to reproduce it and we can consider to reopen.

@xabbuh xabbuh closed this as completed Dec 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0