public function start($id, Parameters $parameters = null)
    {
        if (null !== $id) {
            $resource = str_replace('{id}', $id, static::RESOURCE_OBJECT_START);
        } else {
            $key = $parameters->getKey();
            $tenantId = $parameters->getTenantId();

            switch (true) {
                case null !== $key && null !== $tenantId:
                    $resource = str_replace(['{key}', '{tenant-id}'], [$key, $tenantId], static::RESOURCE_OBJECT_START_BY_KEY_AND_TENANT_ID);
                    break;

                case null !== $key:
                    $resource = str_replace('{key}', $key, static::RESOURCE_OBJECT_START_BY_KEY);
                    break;

                default:
                    throw new LogicException('"Key" and/or "TenantId" parameters are not defined.');
            }
        }

        $options = [
            'headers' => [
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
            ]
        ];

        if ($parameters) {
            $parameters = (array) $parameters->toObject(true);

            foreach ($parameters as $name => $value) {
                switch ($name) {
                    case 'variables':
                        foreach ($value as $variable) {
                            $options['json'][$name][$variable->name] = [
                                'value' => Variable::TYPE_JSON === $variable->type ? json_encode($variable->value) : $variable->value,
                                'type' => $variable->type
                            ];
                        }

                        break;

                    case 'key':
                        break;

                    default:
                        $options['json'][$name] = $value;
                }
            }
        }

        $object = $this->execute('POST', $resource, $options);
        $model = ProcessInstanceService::toModel($object);

        return $model;
    }
public function start($id, Parameters $parameters = null)
    {
        if (null !== $id) {
            $resource = str_replace('{id}', $id, static::RESOURCE_OBJECT_START);
        } else {
            $key = $parameters->getKey();
            $tenantId = $parameters->getTenantId();

            switch (true) {
                case null !== $key && null !== $tenantId:
                    $resource = str_replace(['{key}', '{tenant-id}'], [$key, $tenantId], static::RESOURCE_OBJECT_START_BY_KEY_AND_TENANT_ID);
                    break;

                case null !== $key:
                    $resource = str_replace('{key}', $key, static::RESOURCE_OBJECT_START_BY_KEY);
                    break;

                default:
                    throw new LogicException('"Key" and/or "TenantId" parameters are not defined.');
            }
        }

        $options = [
            'headers' => [
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
            ]
        ];

        if ($parameters) {
            $parameters = (array) $parameters->toObject(true);

            foreach ($parameters as $name => $value) {
                switch ($name) {
                    case 'variables':
                        foreach ($value as $variable) {
                            $options['json'][$name][$variable->name] = [
                                'value' => Variable::TYPE_JSON === $variable->type ? json_encode($variable->value) : $variable->value,
                                'type' => $variable->type
                            ];
                        }

                        break;

                    case 'key':
                        break;

                    default:
                        $options['json'][$name] = $value;
                }
            }
        }

        $object = $this->execute('POST', $resource, $options);
        $model = ProcessInstanceService::toModel($object);

        return $model;
    }
public function start ( $ id , Parameters $ parameters = null ) { if ( null !== $ id ) { $ resource = str_replace ( '{id}' , $ id , static :: RESOURCE_OBJECT_START ) ; } else { $ key = $ parameters -> getKey ( ) ; $ tenantId = $ parameters -> getTenantId ( ) ; switch ( true ) { case null !== $ key && null !== $ tenantId : $ resource = str_replace ( [ '{key}' , '{tenant-id}' ] , [ $ key , $ tenantId ] , static :: RESOURCE_OBJECT_START_BY_KEY_AND_TENANT_ID ) ; break ; case null !== $ key : $ resource = str_replace ( '{key}' , $ key , static :: RESOURCE_OBJECT_START_BY_KEY ) ; break ; default : throw new LogicException ( '"Key" and/or "TenantId" parameters are not defined.' ) ; } } $ options = [ 'headers' => [ 'Accept' => 'application/json' , 'Content-Type' => 'application/json' ] ] ; if ( $ parameters ) { $ parameters = ( array ) $ parameters -> toObject ( true ) ; foreach ( $ parameters as $ name => $ value ) { switch ( $ name ) { case 'variables' : foreach ( $ value as $ variable ) { $ options [ 'json' ] [ $ name ] [ $ variable -> name ] = [ 'value' => Variable :: TYPE_JSON === $ variable -> type ? json_encode ( $ variable -> value ) : $ variable -> value , 'type' => $ variable -> type ] ; } break ; case 'key' : break ; default : $ options [ 'json' ] [ $ name ] = $ value ; } } } $ object = $ this -> execute ( 'POST' , $ resource , $ options ) ; $ model = ProcessInstanceService :: toModel ( $ object ) ; return $ model ; }
Start a process definition instance

@param string $id
@param \Ds\Component\Camunda\Query\ProcessDefinitionParameters $parameters
@return \Ds\Component\Camunda\Model\ProcessInstance
Start a process definition instance