次のエラーが表示されます。
Fatal error: Class 'DBP\InterfazIcedbpBundle\Form\Type\PreferencesIcecatType' not found in C:\xampp\htdocs\InterfaceICEDBP\src\DBP\InterfazIcedbpBundle\Controller\PreferencesIcecatController.php on line 66
再利用できるようにeフォームクラスを作成しようとしており、マニュアルに従っています。
XAMPPを搭載したWindowsでsymfony 2.3.4を使用しています
両方の環境でキャッシュをクリアしようとしましたが、Apache と MariaDB を再起動しました。手がかりはありますか? どうもありがとうございました!
私が持っている他のフォームに対して他のタイプを実行しましたが、それは完全に機能するので、名前空間とは関係ありませんが、どこかで何か問題があると思います。
これは私のコントローラーです。フォルダー \src\DBP\InterfazIcedbpBundle\Controller にあります。
namespace DBP\InterfazIcedbpBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use DBP\InterfazIcedbpBundle\Entity\Preicedbp\category;
use DBP\InterfazIcedbpBundle\Entity\Preicedbp\supplier;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\ORM\Mapping as ORM;
use DBP\InterfazIcedbpBundle\Form\Type\PreferencesIcecatType;
class PreferencesIcecatController extends Controller
{
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$categories = $em->getRepository('DBPInterfazIcedbpBundle:Preicedbp\Category')->getAllCategories();
$categories = $em->getRepository('DBPInterfazIcedbpBundle:Preicedbp\Category')->getCategoriesJSON($categories);
$suppliers = $em->getRepository('DBPInterfazIcedbpBundle:Preicedbp\Supplier')->getAllSuppliers();
$distributors = $em->getRepository('DBPInterfazIcedbpBundle:Preicedbp\Distributor')->getAllDistributors();
$distributors = $em->getRepository('DBPInterfazIcedbpBundle:Preicedbp\Distributor')->getDistributorsJSON($distributors);
$query = $em->createQuery(
'SELECT c.catId FROM DBPInterfazIcedbpBundle:Preicedbp\ImpCategories c WHERE c.idImpPreferences=1
ORDER BY c.catId ASC');
$_selected = $query->getResult();
$categories_selected = "";
foreach($_selected as $cat) {
$categories_selected .= $cat['catId'].",";
}
//$categories_selected = $em->getRepository('DBPInterfazIcedbpBundle:Category')->getCategoriesSelectedJSON($categories_selected);
$query = $em->createQuery(
'SELECT c.distributorId FROM DBPInterfazIcedbpBundle:Preicedbp\ImpDistributors c WHERE c.idImpPreferences=1
ORDER BY c.distributorId ASC');
$_selected = $query->getResult();
$distributors_selected = "";
foreach($_selected as $dist) {
$distributors_selected .= $dist['distributorId'].",";
}
$query = $em->createQuery(
'SELECT c.supplierId FROM DBPInterfazIcedbpBundle:Preicedbp\ImpSuppliers c WHERE c.idImpPreferences=1
ORDER BY c.supplierId ASC');
$_selected = $query->getResult();
$suppliers_selected = "";
foreach($_selected as $sup) {
$suppliers_selected .= $sup['supplierId'].",";
}
$preferences = $this->getDoctrine()->getRepository('DBPInterfazIcedbpBundle:Preicedbp\ImpPreferences')->find(1);
$pref_id = $preferences->getId();
$options = array('suppliers_selected'=>$suppliers_selected, 'id'=>$pref_id);
$form = $this->createForm(new PreferencesIcecatType(),$options);
if ($request->isMethod('POST')) {
//Obtenemos los datos del formulario
$form->bind($request);
$datos = $form->getData();
$datos->setTypeUpdate(1);
//Guardamos imp_preferences automáticamente
$em->persist($datos);
$em->flush();
//Recogemos las categorias, suppliers y dist que se guardan a parte
$cat_selected = $form["cat_selected"]->getData();
$sup_selected = $form["sup_selected"]->getData();
$dist_selected = $form["dist_selected"]->getData();
//Primero borramos lo que hay para luego insertarlo de nuevo (así me olvido de mirar si está ya insertado o no).
$query = $em->createQuery('DELETE FROM DBPInterfazIcedbpBundle:Preicedbp\ImpSuppliers c WHERE c.idImpPreferences='.$pref_id);
$query->getResult();
$query = $em->createQuery('DELETE FROM DBPInterfazIcedbpBundle:Preicedbp\ImpDistributors c WHERE c.idImpPreferences='.$pref_id);
$query->getResult();
$query = $em->createQuery('DELETE FROM DBPInterfazIcedbpBundle:Preicedbp\ImpCategories c WHERE c.idImpPreferences='.$pref_id);
$query->getResult();
$categorias = explode(",",$cat_selected);
foreach($categorias as $cat) {
if(empty($cat)) continue;
$conn = $em->getConnection();
$query = "INSERT INTO imp_categories VALUES($pref_id,$cat)";
$stmt = $conn->prepare($query);
$stmt->execute(array());
}
$fabricantes = explode(",",$sup_selected);
foreach($fabricantes as $sup) {
if(empty($sup)) continue;
$conn = $em->getConnection();
$query = "INSERT INTO imp_suppliers VALUES($pref_id,$sup)";
$stmt = $conn->prepare($query);
$stmt->execute(array());
}
$distribuidores = explode(",",$dist_selected);
foreach($distribuidores as $dist) {
if(empty($dist)) continue;
$conn = $em->getConnection();
$query = "INSERT INTO imp_distributors VALUES($pref_id,$dist)";
$stmt = $conn->prepare($query);
$stmt->execute(array());
}
$this->get('session')->getFlashBag()->add('notice', 'La configuración se ha guardado con éxito!!');
}
//Aquí vuelvo a sacar las categorias seleccionadas porque al cambiar tengo que volver a sacarlas.
//$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery(
'SELECT c.catId FROM DBPInterfazIcedbpBundle:Preicedbp\ImpCategories c WHERE c.idImpPreferences=1
ORDER BY c.catId ASC');
$_selected = $query->getResult();
$categories_selected = "";
foreach($_selected as $cat) {
$categories_selected .= $cat['catId'].",";
}
//$categories_selected = $em->getRepository('DBPInterfazIcedbpBundle:Category')->getCategoriesSelectedJSON($categories_selected);
$query = $em->createQuery(
'SELECT c.distributorId FROM DBPInterfazIcedbpBundle:Preicedbp\ImpDistributors c WHERE c.idImpPreferences=1
ORDER BY c.distributorId ASC');
$_selected = $query->getResult();
$distributors_selected = "";
foreach($_selected as $dist) {
$distributors_selected .= $dist['distributorId'].",";
}
$query = $em->createQuery(
'SELECT c.supplierId FROM DBPInterfazIcedbpBundle:Preicedbp\ImpSuppliers c WHERE c.idImpPreferences=1
ORDER BY c.supplierId ASC');
$_selected = $query->getResult();
$suppliers_selected = "";
foreach($_selected as $sup) {
$suppliers_selected .= $sup['supplierId'].",";
}
return $this->render('DBPInterfazIcedbpBundle:Preferences:icecat_preicedbp.html.twig',
array('categories'=>$categories, 'suppliers'=>$suppliers, 'distributors'=>$distributors,
'categories_selected'=>$categories_selected, 'distributors_selected'=>$distributors_selected, 'suppliers_selected'=>$suppliers_selected,
'preferences'=>$preferences,'form' => $form->createView()));
}
}
そして、これは \src\DBP\InterfazIcedbpBundle\Form\Type の私のタイプです
<?php
namespace DBP\InterfazIcedbpBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use DBP\InterfazIcedbpBundle\Form\DataTransformer\StringToArrayTransformer;
class PreferencesIcecatType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$suppliers_selected = $options['suppliers_selected'];
$pref_id = $options['id'];
//añadimos las categorias, fabricantes y distribuidores en un campo hidden
$builder->add('cat_selected', 'hidden', array(
'data' => '', 'mapped'=>false,
));
$builder->add('sup_selected', 'hidden', array(
'data' => $suppliers_selected,'mapped'=>false,
));
$builder->add('dist_selected', 'hidden', array(
'data' => '','mapped'=>false,
));
$builder->add('id', 'hidden', array('data'=>$pref_id,'property_path'=>'id'));
//$builder->add('id', 'hidden', array());
//Añadimos el resto de campos
$builder->add('onMarket', 'choice', array('label'=>'Mercado','choices' => array(
'0' => 'Sólo productos que no estén en el mercado',
'1' => 'Sólo productos en el mercado',
'2' => 'Todos'),'multiple' => false));
$builder->add('quality', 'choice', array('label'=>'Calidad','choices' => array(
'ICECAT' => 'ICECAT',
'SUPPLIER' => 'SUPPLIER',
'NO-EDITOR' => 'NO-EDITOR',
'TODOS'=>'TODOS'),'multiple' => false));
$builder->add('importProducts', 'choice', array('label'=>'Filtrar por','choices' => array(
'1' => 'Categorias',
'2' => 'Fabricantes',
'3' => 'Distribuidores',
'0'=>'TODOS'),'multiple' => false,'expanded'=>true));
//$entityManager = $options['em'];
$transformer = new StringToArrayTransformer($em);
$builder->add($builder->create('languages', 'choice', array('label'=>'Lenguajes','choices' => array(
'ES' => 'ES',
'EN' => 'EN',
),'multiple' => true,'expanded'=>false))->addModelTransformer($transformer));
$builder->add($builder->create('countryMarket', 'choice', array('label'=>'Mercado','choices' => array(
'ES' => 'ES',
'EN' => 'EN',
),'multiple' => true,'expanded'=>false))->addModelTransformer($transformer));
$builder->add('onlyUpdateExistings', 'checkbox', array(
'label' => 'Actualizar sólo existentes',
'required' => false,
));
$builder->add('sel_cat', 'checkbox', array(
'label' => 'Seleccionar/Deseleccionar',
'required' => false, 'mapped'=>false,
));
$builder->add('sel_sup', 'checkbox', array(
'label' => 'Seleccionar/Deseleccionar',
'required' => false,'mapped'=>false,
));
$builder->add('sel_dist', 'checkbox', array(
'label' => 'Seleccionar/Deseleccionar',
'required' => false,'mapped'=>false,
));
$builder->add('show_only_cat', 'checkbox', array(
'label' => 'Mostrar sólo seleccionadas',
'required' => false,'mapped'=>false,
));
$builder->add('show_only_sup', 'checkbox', array(
'label' => 'Mostrar sólo seleccionados',
'required' => false,'mapped'=>false,
));
$builder->add('show_only_dist', 'checkbox', array(
'label' => 'Mostrar sólo seleccionados',
'required' => false,'mapped'=>false,
));
$builder->add('user_icecat', 'text', array( ));
$builder->add('pass_icecat', 'text', array( ));
$builder->add('icecat_route', 'text', array( ));
$builder->add('icecat_subdir', 'text', array( ));
}
public function getName()
{
return 'preferences_icecat';
}
}