Last active
March 22, 2016 09:48
-
-
Save webdevilopers/c94295b790b3ea5d3043 to your computer and use it in GitHub Desktop.
Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.dbal.default_connection".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\AppBundle\Service; | |
use Doctrine\ORM\EntityManager; | |
use GuzzleHttp\Exception\RequestException; | |
/** | |
* @todo Inject mailer | |
*/ | |
abstract class Api | |
{ | |
public $client; | |
public $mailer; | |
public $entityManager; | |
public function getClient() { | |
return $this->client; | |
} | |
public function setClient($client) { | |
$this->client = $client; | |
} | |
public function getMailer() { | |
return $this->mailer; | |
} | |
public function setMailer(\Swift_Mailer $mailer) { | |
$this->mailer = $mailer; | |
} | |
function getEntityManager() { | |
return $this->entityManager; | |
} | |
function setEntityManager(EntityManager $entityManager) { | |
$this->entityManager = $entityManager; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\AppBundle\EventListener; | |
use Doctrine\ORM\Event\LifecycleEventArgs; | |
// for Doctrine 2.4: Doctrine\Common\Persistence\Event\LifecycleEventArgs; | |
use Acme\AppBundle\Service\Api\Configuration as ApiService; | |
use Acme\AppBundle\Entity\Configuration; | |
class ConfigurationListener | |
{ | |
private $apiService; | |
public function __construct(ApiService $apiService) | |
{ | |
$this->apiService = $apiService; | |
} | |
public function getApiService() { | |
return $this->apiService; | |
} | |
public function setApiService($apiService) { | |
$this->apiService = $apiService; | |
} | |
public function postPersist(LifecycleEventArgs $args) | |
{ | |
$entity = $args->getEntity(); | |
$entityManager = $args->getEntityManager(); | |
if ($entity instanceof Configuration) { | |
$apiService = $this->getApiService(); | |
$apiService->sendConfiguration(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\AppBundle\EventListener; | |
use Doctrine\ORM\Event\LifecycleEventArgs; | |
// for Doctrine 2.4: Doctrine\Common\Persistence\Event\LifecycleEventArgs; | |
use Acme\AppBundle\Entity\Configuration; | |
class ConfigurationListener | |
{ | |
private $apiService; | |
public function __construct($container) | |
{ | |
$this->container = $container; | |
} | |
public function postPersist(LifecycleEventArgs $args) | |
{ | |
$entity = $args->getEntity(); | |
$entityManager = $args->getEntityManager(); | |
if ($entity instanceof Configuration) { | |
$apiService = $this->container->get('api.configuration'); | |
$apiService->sendConfiguration(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
api.listener.configuration: | |
class: Acme\AppBundle\EventListener\ConfigurationListener | |
arguments: | |
api_service: "@api.configuration" | |
tags: | |
- { name: doctrine.event_listener, event: postPersist } | |
writer.configuration_request: | |
class: Acme\AppBundle\Writer\ConfigurationRequest | |
api.abstract: | |
abstract: true | |
class: Acme\AppBundle\Service\Api | |
calls: | |
- [setClient, ["@api.client"]] | |
- [setMailer, ["@mailer"]] | |
- [setEntityManager, ["@doctrine.orm.entity_manager"]] | |
api.configuration: | |
class: "Acme\AppBundle\Service\Api\Configuration" | |
parent: api.abstract | |
calls: | |
- [setWriter, ["@writer.configuration_request"]] | |
api.client: | |
class: GuzzleHttp\Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
api.listener.configuration: | |
class: Acme\AppBundle\EventListener\ConfigurationListener | |
tags: | |
- { name: doctrine.event_listener, event: postPersist } | |
calls: | |
- [setApiService, ["@api.configuration"]] | |
writer.configuration_request: | |
class: Acme\AppBundle\Writer\ConfigurationRequest | |
api.abstract: | |
abstract: true | |
class: Acme\AppBundle\Service\Api | |
calls: | |
- [setClient, ["@api.client"]] | |
- [setMailer, ["@mailer"]] | |
- [setEntityManager, ["@doctrine.orm.entity_manager"]] | |
api.configuration: | |
class: "Acme\AppBundle\Service\Api\Configuration" | |
parent: api.abstract | |
calls: | |
- [setWriter, ["@writer.configuration_request"]] | |
api.client: | |
class: GuzzleHttp\Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
api.listener.configuration: | |
class: Acme\AppBundle\EventListener\ConfigurationListener | |
arguments: | |
container: "@service_container" | |
tags: | |
- { name: doctrine.event_listener, event: postPersist } | |
writer.configuration_request: | |
class: Acme\AppBundle\Writer\ConfigurationRequest | |
api.abstract: | |
abstract: true | |
class: Acme\AppBundle\Service\Api | |
calls: | |
- [setClient, ["@api.client"]] | |
- [setMailer, ["@mailer"]] | |
- [setEntityManager, ["@doctrine.orm.entity_manager"]] | |
api.configuration: | |
class: "Acme\AppBundle\Service\Api\Configuration" | |
parent: api.abstract | |
calls: | |
- [setWriter, ["@writer.configuration_request"]] | |
api.client: | |
class: GuzzleHttp\Client |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any progress on this? Came across the same issue.
Could it be simplified to: doctrine subscriber/listener with dependency?