/**
  * @param VhostConfiguration $configuration
  */
 public function define(VhostConfiguration $configuration)
 {
     foreach ($configuration->getConfiguration('permissions') as $user => $permission) {
         try {
             $remotePermission = $configuration->getClient()->permissions()->get($configuration->getName(), $user);
         } catch (ClientErrorResponseException $e) {
             $this->handleNotFoundException($e);
             $configuration->getClient()->permissions()->create($configuration->getName(), $user, $permission);
         }
         if ($configuration->isDeleteAllowed() && isset($remotePermission) && !$this->isUpToDate($permission, $remotePermission)) {
             $configuration->getClient()->permissions()->delete($configuration->getName(), $user);
             $configuration->getClient()->permissions()->create($configuration->getName(), $user, $permission);
         }
     }
 }
 /**
  * @param VhostConfiguration $configuration
  */
 public function define(VhostConfiguration $configuration)
 {
     foreach ($configuration->getConfiguration('exchanges') as $exchange) {
         $name = $exchange['name'];
         unset($exchange['name']);
         try {
             $remoteExchange = $configuration->getClient()->exchanges()->get($configuration->getName(), $name);
         } catch (ClientErrorResponseException $e) {
             $this->handleNotFoundException($e);
             $configuration->getClient()->exchanges()->create($configuration->getName(), $name, $exchange);
         }
         if ($configuration->isDeleteAllowed() && isset($remoteExchange) && !$this->isUpToDate($exchange, $remoteExchange)) {
             $configuration->getClient()->exchanges()->delete($configuration->getName(), $name);
             $configuration->getClient()->exchanges()->create($configuration->getName(), $name, $exchange);
         }
     }
 }
 /**
  * @param VhostConfiguration $configuration
  */
 public function define(VhostConfiguration $configuration)
 {
     foreach ($configuration->getConfiguration('queues') as $queue) {
         $name = $queue['name'];
         unset($queue['name']);
         $bindings = $queue['bindings'];
         unset($queue['bindings']);
         $modulus = $queue['modulus'];
         unset($queue['modulus']);
         if (null !== $modulus) {
             for ($i = 0; $i < $modulus; $i++) {
                 $this->createQueue($configuration, $this->getModulusName($name, $i), $queue);
                 $modulusBindings = $bindings;
                 foreach ($modulusBindings as $key => $binding) {
                     $modulusBindings[$key]['routing_key'] = $this->getModulusName($binding['routing_key'], $i);
                 }
                 $this->bindingManager->define($configuration, $this->getModulusName($name, $i), $modulusBindings);
             }
         } else {
             $this->createQueue($configuration, $name, $queue);
             $this->bindingManager->define($configuration, $name, $bindings);
         }
     }
 }