/**
  * Instantiates a service.
  *
  * @return Service
  */
 public function createService()
 {
     return new Service($this->_config->get('components.ironedge/activemq'));
 }
 /**
  * Creates a message instance from a file.
  *
  * @param string $file - File.
  *
  * @return Message
  */
 public function createMessageFromFile(string $file) : Message
 {
     if (!is_file($file)) {
         throw new \InvalidArgumentException('File "' . $file . '" does not exist!');
     }
     $config = new Config();
     $config->load(['file' => $file]);
     if (!$config->has('body')) {
         throw new \RuntimeException('File has no "body" element.');
     }
     return $this->createMessage($config->get('body'), $config->get('headers', []), $config->get('options', []));
 }
Exemple #3
0
 /**
  * Exports a graph to a graphviz image.
  *
  * @param NodeInterface $node    - Graph.
  * @param array         $options - Options.
  *
  * @throws InvalidWriterTypeException
  *
  * @return Response
  */
 public function export(NodeInterface $node, array $options = [])
 {
     $options = array_replace_recursive(['writer' => 'graphviz'], $options);
     if (is_string($options['writer'])) {
         switch ($options['writer']) {
             case 'graphviz':
                 $options['path'] = $options['path'] ?? $this->generateRandomFilePath();
                 $options['writer'] = new GraphvizWriter();
                 break;
             default:
                 throw InvalidWriterTypeException::create($options['writer']);
         }
     }
     $config = new Config(['node' => $node], ['writer' => $options['writer']]);
     $config->save(['writerOptions' => $options]);
     $response = new Response();
     $response->setPath($options['path']);
     return $response;
 }