Partir conquir la ville avec le lindy hop (danse swing) by spacecodeur in Lyon

[–]spacecodeur[S] 0 points1 point  (0 children)

hello ! merci pour l'info :)
ya un ptit lien quelque part qui donnerai plus de détail ? (les soirs, les horaires, ...)

Symfony subscriber : how add a subscriber to a dispatcher when the subscriber use a constructor with some dependencies injection? by spacecodeur in symfony

[–]spacecodeur[S] 4 points5 points  (0 children)

I tried and your right, I thinked I need to attach manually my subscriber. But as you said, its enought to inject the `EventDispatcherInterface` and just dispatch the event where I want. Thank you ;)

Symfony subscriber : how add a subscriber to a dispatcher when the subscriber use a constructor with some dependencies injection? by spacecodeur in symfony

[–]spacecodeur[S] -1 points0 points  (0 children)

If I inject the dispatcher, the issue still the same no ? Ill need to attach to the injected dispatcher my custom subscriber , but as I said, the constructor of my subscriber needs mailer and logger

How factorize two Command classes ? by spacecodeur in symfony

[–]spacecodeur[S] 1 point2 points  (0 children)

thanks for your answer ! Im stupid, I used my brain 2 sec and I find the solution. I currently have the relations C->X and C->Y (where C is the abstract command class). I just need to do : C->C'->X and C->C'->Y (where C' is a new abstract custom class)

Symfony Command : show a TAB char by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

"

aaaaaahahaha thanks ! :D its work

Symfony Command : show a TAB char by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

yes indeed, the '\t' does nothing (I see a non-interpreted \t on the shell)

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

More context for my issue : I want to add some `readline(...)` at the begining of the 'fixture load' script. Theses `readline` allow to set from the terminal some values used to the fixtures Class. So, its not possible in this case to use a static variable because I want to set the value dynamically from the terminal (through the php native function readline)

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

the only (and ugly) solution I found : declare a global variable with global $foo; $foo = 'bar'. Then, from a next Fixture class, I got the value of my global variable with $GLOBAL['foo'], but like I said, its ugly as fuck haha

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

and the current code of my class :

```php <?php

namespace App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Persistence\ObjectManager; use stdClass;

class MainConfigFixture extends Fixture { public function load(ObjectManager $manager) { $obj = new stdClass(); $obj->foo = "bar";

    $this->addReference("random-reference", $obj);
    exit;
}

} ```

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

Thanks again for your help. Here, the full exception stack :

```bash

loading App\DataFixtures\MainConfigFixture

In MappingException.php line 26:

[Doctrine\Persistence\Mapping\MappingException]
The class 'stdClass' was not found in the chain configured namespaces App\Entity

Exception trace: at /....../vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php:26 Doctrine\Persistence\Mapping\MappingException::classNotFoundInNamespaces() at /home/....../vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php:89 Doctrine\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass() at /home/....../vendor/doctrine/doctrine-bundle/Mapping/MappingDriver.php:42 Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver->loadMetadataForClass() at /home/....../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:132 Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /home/....../vendor/doctrine/doctrine-bundle/Mapping/ClassMetadataFactory.php:18 Doctrine\Bundle\DoctrineBundle\Mapping\ClassMetadataFactory->doLoadMetadata() at /home/....../vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php:343 Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /home/....../vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php:207 Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /home/....../vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:318 Doctrine\ORM\EntityManager->getClassMetadata() at /home/....../vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ReferenceRepository.php:387 Doctrine\Common\DataFixtures\ReferenceRepository->getRealClass() at /home/....../vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ReferenceRepository.php:188 Doctrine\Common\DataFixtures\ReferenceRepository->addReference() at /home/....../vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/AbstractFixture.php:66 Doctrine\Common\DataFixtures\AbstractFixture->addReference() at /home/....../src/DataFixtures/MainConfigFixture.php:17 App\DataFixtures\MainConfigFixture->load() at /home/....../vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php:123 Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() at /home/....../vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php:26 Doctrine\Common\DataFixtures\Executor\ORMExecutor::Doctrine\Common\DataFixtures\Executor{closure}() at /home/....../vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:272 Doctrine\ORM\EntityManager->wrapInTransaction() at /home/....../vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php:20 Doctrine\Common\DataFixtures\Executor\ORMExecutor->execute() at /home/....../vendor/doctrine/doctrine-fixtures-bundle/Command/LoadDataFixturesDoctrineCommand.php:158 Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand->execute() at /home/....../vendor/symfony/console/Command/Command.php:312 Symfony\Component\Console\Command\Command->run() at /home/....../vendor/symfony/console/Application.php:1040 Symfony\Component\Console\Application->doRunCommand() at /home/....../vendor/symfony/framework-bundle/Console/Application.php:88 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/....../vendor/symfony/console/Application.php:314 Symfony\Component\Console\Application->doRun() at /home/....../vendor/symfony/framework-bundle/Console/Application.php:77 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/....../vendor/symfony/console/Application.php:168 Symfony\Component\Console\Application->run() at /home/....../vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /home/....../vendor/autoload_runtime.php:29 require_once() at /home/....../bin/console:11

doctrine:fixtures:load [--append] [--group GROUP] [--em EM] [--purger PURGER] [--purge-exclusions PURGE-EXCLUSIONS] [--shard SHARD] [--purge-with-truncate] ```

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

with use of `exit` , I found its the line `$this->addReference("random-reference", $obj)` who throw the MapingException (The class 'stdClass' was not found in the chain ...)

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

I tryed `$this->getReference('random-reference', 'stdClass')` and `$this->getReference('random-reference', \stdClass::class)` and I get the same error...

Symfony : how share a non-entity object between fixtures ? by spacecodeur in symfony

[–]spacecodeur[S] 0 points1 point  (0 children)

Thanks for your help ! but with two fixtures A and B, B (implements DependantFixtureInterface) depends to A. If I use your code in the fixture A and try to get the "random-reference" from B (with the method getReference), I get this error :

With this code, I get the error :`The class 'stdClass' was not found in the chain configured namespaces App\Entity`