alexmixaylov Posted February 18, 2020 Share Posted February 18, 2020 I am trying to make module with new symfony way. But get MappingException error. Quote The class 'Visix\Repository\CategoryRepository' was not found in the chain configured namespaces PrestaShopBundle\Entity, Visix\Entity my module name is "prodconf" namespase "Visix" <?php namespace Visix\Repository; use Doctrine\DBAL\Connection; class CategoryRepository { /** * @var Connection */ private $connection; /** * @var string */ private $dbPrefix; /** * @param Connection $connection * @param string $dbPrefix */ public function __construct(Connection $connection, $dbPrefix) { $this->connection = $connection; $this->dbPrefix = $dbPrefix; } public function getCategories() { $qb = $this->connection->createQueryBuilder(); $qb ->addSelect('c.id_category') ->addSelect('c.id_parent') ->from($this->dbPrefix . 'category', 'c'); $result = $qb->execute(); return $result->fetchAll(); } } <?php namespace Visix\Controllers\Admin; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Visix\Repository\CategoryRepository; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; class ScenarioController extends AbstractController { public function getCategories(Request $request) { $test = $this->getDoctrine()->getRepository(CategoryRepository::class)->getClassName(); return new JsonResponse($test); } } and services.yml visix_category_repository: class: 'Visix\Repository\ScenarioRepository' arguments: - '@doctrine.dbal.default_connection' - '%database_prefix%' what I am doing incorrectly? Link to comment Share on other sites More sharing options...
fbenoist.com Posted February 19, 2020 Share Posted February 19, 2020 Hi, Do you have a composer.json file in your module? Did you configure the autoload part of the composer.json file? "autoload": { "psr-4": { "Visix\\": "src/" }, "classmap": ["prodconf.php"], "exclude-from-classmap": [] }, Link to comment Share on other sites More sharing options...
alexmixaylov Posted February 19, 2020 Author Share Posted February 19, 2020 { "name": "Alex/prodconf", "description": "Product Configurator", "authors": [ { "name": "alex", "email": "[email protected]" } ], "require": { "php": ">=7.1.0" }, "autoload": { "psr-4": { "Visix\\": "src/" }, "classmap": [ "prodconf.php", "classes/" ], "exclude-from-classmap": [] }, "config": { "preferred-install": "dist", "prepend-autoloader": false } } yes I have composer.json in module folder Link to comment Share on other sites More sharing options...
Edvinas Posted November 11, 2021 Share Posted November 11, 2021 @alexmixaylov did you managed to fix the problem? Link to comment Share on other sites More sharing options...
Edvinas Posted April 21, 2023 Share Posted April 21, 2023 On 2/19/2020 at 11:48 AM, alexmixaylov said: { "name": "Alex/prodconf", "description": "Product Configurator", "authors": [ { "name": "alex", "email": "[email protected]" } ], "require": { "php": ">=7.1.0" }, "autoload": { "psr-4": { "Visix\\": "src/" }, "classmap": [ "prodconf.php", "classes/" ], "exclude-from-classmap": [] }, "config": { "preferred-install": "dist", "prepend-autoloader": false } } yes I have composer.json in module folder How about now? 😁 did you solve the problem? 😁 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now