コード例 #1
0
 /**
  * Loads available DataTypes from system config and converts some to cient format
  *
  * If optional data type array is passed as argument, this is used instead of all available types
  *
  * @param array|null $processingTypes
  * @return array
  */
 protected function getProcessingTypesForClient(array $processingTypes = null)
 {
     if (is_null($processingTypes)) {
         $processingTypes = $this->systemConfig->getAllAvailableProcessingTypes();
     }
     return array_map(function ($processingTypeClass) {
         return $this->prepareProcessingType($processingTypeClass);
     }, $processingTypes);
 }
コード例 #2
0
ファイル: Log.php プロジェクト: prooph/link-process-manager
 /**
  * @param mixed $id
  * @return array|mixed
  */
 public function get($id)
 {
     $processLog = $this->processLogFinder->getLoggedProcess($id);
     if ($processLog === null) {
         return $this->notFoundAction();
     }
     $processLog['events'] = $this->convertToClientProcessEvents($this->processStreamReader->getStreamOfProcess($id));
     $processDefinitions = $this->systemConfig->getProcessDefinitions();
     if (!isset($processDefinitions[$processLog['start_message']])) {
         //@TODO: Provide better error, so that the client can show the user a message that config is missing
         return $this->notFoundAction();
     }
     $processDefinition = $processDefinitions[$processLog['start_message']];
     $processDefinition = ProcessToClientTranslator::translate($processLog['start_message'], $processDefinition, $this->systemConfig->getAllAvailableProcessingTypes(), $this->scriptLocation);
     $processLog['tasks'] = $processDefinition['tasks'];
     $this->populateTaskEvents($processLog);
     return ['log' => $processLog];
 }
コード例 #3
0
 /**
  * @param string $connectorId
  * @param array $connectorConfig
  * @param \Prooph\Link\Application\Projection\ProcessingConfig $config
  * @param bool $isNewConnector
  * @throws \InvalidArgumentException
  */
 private function assertConnectorConfig($connectorId, array $connectorConfig, \Prooph\Link\Application\Projection\ProcessingConfig $config, $isNewConnector = false)
 {
     if (!is_string($connectorId) || empty($connectorId)) {
         throw new \InvalidArgumentException("Connector id must a non empty string");
     }
     if (!array_key_exists('name', $connectorConfig)) {
         throw new \InvalidArgumentException('Missing name in connector config ' . $connectorId);
     }
     if (!is_string($connectorConfig['name']) || empty($connectorConfig['name'])) {
         throw new \InvalidArgumentException('Name must be a non empty string in connector config ' . $connectorId);
     }
     if (!array_key_exists('allowed_messages', $connectorConfig)) {
         throw new \InvalidArgumentException('Missing allowed messages in connector config ' . $connectorId);
     }
     if (!is_array($connectorConfig['allowed_messages'])) {
         throw new \InvalidArgumentException('Allowed messages must be an array in connector config ' . $connectorId);
     }
     if (!array_key_exists('icon', $connectorConfig)) {
         throw new \InvalidArgumentException('Missing icon in connector config ' . $connectorId);
     }
     if (!array_key_exists('icon_type', $connectorConfig)) {
         throw new \InvalidArgumentException('Missing icon_type in connector config ' . $connectorId);
     }
     if (!array_key_exists('node_name', $connectorConfig)) {
         throw new \InvalidArgumentException('Missing node_name in connector config ' . $connectorId);
     }
     array_walk($connectorConfig['allowed_messages'], function ($allowedMessage) use($connectorId) {
         if (!in_array($allowedMessage, $this->getAvailableMessageTypes())) {
             throw new \InvalidArgumentException(sprintf('Allowed message %s is not a valid workflow message suffix in connector config %s', $allowedMessage, $connectorId));
         }
     });
     if (!array_key_exists('allowed_types', $connectorConfig)) {
         throw new \InvalidArgumentException('Missing allowed types in connector config ' . $connectorId);
     }
     if (!is_array($connectorConfig['allowed_types'])) {
         throw new \InvalidArgumentException('Allowed types must be an array in connector config ' . $connectorId);
     }
     if (!$isNewConnector) {
         array_walk($connectorConfig['allowed_types'], function ($allowedType) use($connectorId, $config) {
             if (!in_array($allowedType, $config->getAllAvailableProcessingTypes())) {
                 throw new \InvalidArgumentException(sprintf('Allowed data type %s is not known by the system in connector config %s', $allowedType, $connectorId));
             }
         });
     }
     if (isset($connectorConfig['metadata'])) {
         if (!is_array($connectorConfig['metadata'])) {
             throw new \InvalidArgumentException('Metadata must be an array in connector config ' . $connectorId);
         }
     }
     if (!$isNewConnector) {
         if (isset($connectorConfig['preferred_type'])) {
             if (!in_array($connectorConfig['preferred_type'], $config->getAllAvailableProcessingTypes())) {
                 throw new \InvalidArgumentException(sprintf('Preferred data type %s is not known by the system in connector config %s', $connectorConfig['preferred_type'], $connectorId));
             }
         }
     }
 }