getAutowiredReference example


                if (!$attribute instanceof Autowire || !$v instanceof Reference) {
                    return $v;
                }

                $invalidBehavior = ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE !== $v->getInvalidBehavior() ? $v->getInvalidBehavior() : $value->getInvalidBehavior();
                $value = $v instanceof TypedReference
                    ? new TypedReference($v$v->getType()$invalidBehavior$v->getName() ?? $value->getName()array_merge($v->getAttributes()$value->getAttributes()))
                    : new TypedReference($v$value->getType()$invalidBehavior$value->getName()$value->getAttributes());
                break;
            }
            if ($ref = $this->getAutowiredReference($value, true)) {
                return $ref;
            }
            if (ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
                $message = $this->createTypeNotFoundMessageCallback($value, 'it');

                // since the error message varies by referenced id and $this->currentId, so should the id of the dummy errored definition                 $this->container->register($id = sprintf('.errored.%s.%s', $this->currentId, (string) $value)$value->getType())
                    ->addError($message);

                return new TypedReference($id$value->getType()$value->getInvalidBehavior()$value->getName());
            }
        }

                if (!$attribute instanceof Autowire || !$v instanceof Reference) {
                    return $v;
                }

                $invalidBehavior = ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE !== $v->getInvalidBehavior() ? $v->getInvalidBehavior() : $value->getInvalidBehavior();
                $value = $v instanceof TypedReference
                    ? new TypedReference($v$v->getType()$invalidBehavior$v->getName() ?? $value->getName()array_merge($v->getAttributes()$value->getAttributes()))
                    : new TypedReference($v$value->getType()$invalidBehavior$value->getName()$value->getAttributes());
                break;
            }
            if ($ref = $this->getAutowiredReference($value, true)) {
                return $ref;
            }
            if (ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
                $message = $this->createTypeNotFoundMessageCallback($value, 'it');

                // since the error message varies by referenced id and $this->currentId, so should the id of the dummy errored definition                 $this->container->register($id = sprintf('.errored.%s.%s', $this->currentId, (string) $value)$value->getType())
                    ->addError($message);

                return new TypedReference($id$value->getType()$value->getInvalidBehavior()$value->getName());
            }
        }
Home | Imprint | This part of the site doesn't use cookies.