2016-05-31 16 views

答えて

1

ここでいくつかのものを混在させています。これはあなたのエンティティでなければなりません:

docコメントアノテーションでは、カスタムレポジトリクラスの場所をDoctrineに伝えます。 Doctrineはあなたのためにそれを読み込みます。 レポジトリにコンストラクタは必要ありません。 Doctrineはあなたのためにこれを処理します。

<?php 

namespace App\Entity\Repository; 

use App\Entity\Categories; 
use Doctrine\ORM\EntityRepository; 

class CategoriesRepository extends EntityRepository implements CategoriesRepositoryInterface 
{ 
    // No constructor here 

    public function fetchAll() 
    { 
     // ... 
    } 
} 

そして、あなたの工場は次のようになります。あなたがこれを使用する設定で

<?php 

namespace App\Panel\Factory; 

use Doctrine\ORM\EntityManager; 
use Interop\Container\ContainerInterface; 
use App\Entity\Categories; 

class CategoriesRepositoryFactory 
{ 
    /** 
    * @param ContainerInterface $container 
    * @return CategoriesRepository 
    */ 
    public function __invoke(ContainerInterface $container) 
    { 
     // Get the entitymanager and load the repository for the categories entity 
     return $container->get(EntityManager::class)->getRepository(Categories::class); 
    } 
} 

<?php 

return [ 
    'dependencies' => [ 
     'invokables' => [ 
     ], 
     'abstract_factories' => [ 
     ], 
     'factories' => [ 
      App\Entity\Repository\CategoriesRepositoryInterface::class => App\Panel\Factory\CategoriesRepositoryFactory::class, 
     ], 
    ], 
]; 
+0

は、あなたはいつもに来ているか、非常に多くのGeert Eltinkをありがとうレスキュー! 設定の文字列も変更されました: 'App \ Panel \ Service \ CategoriesServiceInterface :: class => App \ Panel \ Factory \ CategoriesServiceFactory :: class、 – Drakulitka

関連する問題