前提・実現したいこと
既存のシステムのsymfonyバージョンアップ(2.8->3.0)作業をしておりまして、
エラーが発生しました。
どこに問題があるのか、自分では見つけきれず、どのように問題を探るべきかアドバイスをいただきたいです。
発生している問題・エラーメッセージ
Warning: Missing argument 1 for Ahi\Sp\PublicBundle\Form\Type\Common\BrandChoiceType::__construct(), called in /home/vagrant/Symfony2/vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php on line 87 and defined
該当のソースコード
PHP
1 2namespace Ahi\Sp\PublicBundle\Form\Type\Common; 3 4use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\FormBuilderInterface; 6use Symfony\Component\Form\FormEvents; 7use Symfony\Component\OptionsResolver\OptionsResolver; 8use Symfony\Component\DependencyInjection\ContainerInterface; 9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Bridge\Doctrine\Form\Type\EntityType; 11 12/** 13 * ブランド選択フォームタイプ 14 */ 15class BrandChoiceType extends AbstractType 16{ 17 /** 18 * @var ContainerInterface $container 19 */ 20 protected $container; 21 22 /** 23 * Constructer 24 * 25 * @param ContainerInterface $container 26 */ 27 public function __construct($container) 28 { 29 $this->container = $container; 30 } 31 32 /** 33 * {@inheritdoc} 34 */ 35 public function buildForm(FormBuilderInterface $builder, array $options) 36 { 37 } 38 39 /** 40 * {@inheritdoc} 41 */ 42 public function configureOptions(OptionsResolver $resolver) 43 { 44 $param = array('dispFlg' => 1); 45 $brands = $this->container->get('doctrine')->getManager() 46 ->getRepository('AhiSpCommonBundle:Brand') 47 ->findBy($param, array("sortKey" => "asc")); 48 49 // @TODO 定数化 50 $choices = array( 51 1 => array(), 52 0 => array(), 53 2 => array() 54 ); 55 56 foreach ($brands as $brand) { 57 $sex = $brand->getBrandSex(); 58 $choices[$sex][] = $brand; 59 } 60 61 $resolver->setDefaults(array( 62 'class' => 'AhiSpCommonBundle:Brand', 63 'attr' => array('class' => 'brandChoice'), 64 'choices' => $choices, 65 'required' => false, 66 )); 67 } 68 69 /** 70 * {@inheritdoc} 71 */ 72 public function getParent() 73 { 74 return EntityType::class; 75 } 76 77 /** 78 * {@inheritdoc} 79 */ 80 public function getBlockPrefix() 81 { 82 return 'brandChoice'; 83 } 84} 85
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form; use Symfony\Component\Form\Exception\ExceptionInterface; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\component\Form\Extension\Core\Type\EmailType; use Symfony\component\Form\Extension\Core\Type\FormType; /** * The central registry of the Form component. * * @author Bernhard Schussek <bschussek@gmail.com> */ class FormRegistry implements FormRegistryInterface { /** * Extensions. * * @var FormExtensionInterface[] An array of FormExtensionInterface */ private $extensions = array(); /** * @var FormTypeInterface[] */ private $types = array(); /** * @var FormTypeGuesserInterface|false|null */ private $guesser = false; /** * @var ResolvedFormTypeFactoryInterface */ private $resolvedTypeFactory; /** * Constructor. * * @param FormExtensionInterface[] $extensions An array of FormExtensionInterface * @param ResolvedFormTypeFactoryInterface $resolvedTypeFactory The factory for resolved form types * * @throws UnexpectedTypeException if any extension does not implement FormExtensionInterface */ public function __construct(array $extensions, ResolvedFormTypeFactoryInterface $resolvedTypeFactory) { foreach ($extensions as $extension) { if (!$extension instanceof FormExtensionInterface) { throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormExtensionInterface'); } } $this->extensions = $extensions; $this->resolvedTypeFactory = $resolvedTypeFactory; } /** * {@inheritdoc} */ public function getType($name) { if (!isset($this->types[$name])) { $type = null; foreach ($this->extensions as $extension) { if ($extension->hasType($name)) { $type = $extension->getType($name); break; } } if (!$type) { // Support fully-qualified class names if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) { $type = new $name(); //line 87 } else { throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name)); } } $this->types[$name] = $this->resolveType($type); } return $this->types[$name]; } /** * Wraps a type into a ResolvedFormTypeInterface implementation and connects * it with its parent type. * * @param FormTypeInterface $type The type to resolve * * @return ResolvedFormTypeInterface The resolved type */ private function resolveType(FormTypeInterface $type) { $typeExtensions = array(); $parentType = $type->getParent(); $fqcn = get_class($type); foreach ($this->extensions as $extension) { $typeExtensions = array_merge( $typeExtensions, $extension->getTypeExtensions($fqcn) ); } return $this->resolvedTypeFactory->createResolvedType( $type, $typeExtensions, $parentType ? $this->getType($parentType) : null ); } /** * {@inheritdoc} */ public function hasType($name) { if (isset($this->types[$name])) { return true; } try { $this->getType($name); } catch (ExceptionInterface $e) { return false; } return true; } /** * {@inheritdoc} */ public function getTypeGuesser() { if (false === $this->guesser) { $guessers = array(); foreach ($this->extensions as $extension) { $guesser = $extension->getTypeGuesser(); if ($guesser) { $guessers[] = $guesser; } } $this->guesser = !empty($guessers) ? new FormTypeGuesserChain($guessers) : null; } return $this->guesser; } /** * {@inheritdoc} */ public function getExtensions() { return $this->extensions; } }
yaml
1#services.yml 2 # ブランド選択フォームタイプ 3 common.form.type.brandChoiceType: 4 class: Ahi\Sp\CommonBundle\Form\Type\BrandChoiceType 5 arguments: ['@service_container'] 6 tags: 7 - { name: form.type, alias: brandChoice }
補足情報(FW/ツールのバージョンなど)
PHP 5.6
Symfony 3.0.9
Cent OS 6.7
回答1件
あなたの回答
tips
プレビュー