public function startWorkflow(WorkflowInterface $flow)
    {
        $canonical = null;
        // if $flow is a versionned workflow
        if ($flow instanceof VersionedWorkflow) {
            // store canonical name
            $canonical = get_class($flow);
            // replace by true current implementation
            $flow = $flow->getCurrentImplementation();
        }

        // custom id management
        $customId = null;
        if (method_exists($flow, 'getId')) {
            $customId = $flow->getId();
            if (!is_string($customId) && !is_int($customId)) {
                throw new InvalidArgumentException('Provided Id must be a string or an integer');
            }
            // at the end, it's a string
            $customId = (string) $customId;
            // should be not more than 256 bytes;
            if (strlen($customId) > self::MAX_ID_SIZE) {
                throw new InvalidArgumentException('Provided Id must not exceed '.self::MAX_ID_SIZE.' bytes');
            }
        }

        // start workflow
        $this->http->post($this->getInstanceWorkerUrl(), [
            self::ATTR_PROG => self::PROG,
            self::ATTR_CANONICAL => $canonical,
            self::ATTR_NAME => get_class($flow),
            self::ATTR_DATA => $this->serializer->encode($this->properties->getPropertiesFromObject($flow)),
            self::ATTR_ID => $customId,
        ]);
    }
public function startWorkflow(WorkflowInterface $flow)
    {
        $canonical = null;
        // if $flow is a versionned workflow
        if ($flow instanceof VersionedWorkflow) {
            // store canonical name
            $canonical = get_class($flow);
            // replace by true current implementation
            $flow = $flow->getCurrentImplementation();
        }

        // custom id management
        $customId = null;
        if (method_exists($flow, 'getId')) {
            $customId = $flow->getId();
            if (!is_string($customId) && !is_int($customId)) {
                throw new InvalidArgumentException('Provided Id must be a string or an integer');
            }
            // at the end, it's a string
            $customId = (string) $customId;
            // should be not more than 256 bytes;
            if (strlen($customId) > self::MAX_ID_SIZE) {
                throw new InvalidArgumentException('Provided Id must not exceed '.self::MAX_ID_SIZE.' bytes');
            }
        }

        // start workflow
        $this->http->post($this->getInstanceWorkerUrl(), [
            self::ATTR_PROG => self::PROG,
            self::ATTR_CANONICAL => $canonical,
            self::ATTR_NAME => get_class($flow),
            self::ATTR_DATA => $this->serializer->encode($this->properties->getPropertiesFromObject($flow)),
            self::ATTR_ID => $customId,
        ]);
    }
public function startWorkflow ( WorkflowInterface $ flow ) { $ canonical = null ; // if $flow is a versionned workflow if ( $ flow instanceof VersionedWorkflow ) { // store canonical name $ canonical = get_class ( $ flow ) ; // replace by true current implementation $ flow = $ flow -> getCurrentImplementation ( ) ; } // custom id management $ customId = null ; if ( method_exists ( $ flow , 'getId' ) ) { $ customId = $ flow -> getId ( ) ; if ( ! is_string ( $ customId ) && ! is_int ( $ customId ) ) { throw new InvalidArgumentException ( 'Provided Id must be a string or an integer' ) ; } // at the end, it's a string $ customId = ( string ) $ customId ; // should be not more than 256 bytes; if ( strlen ( $ customId ) > self :: MAX_ID_SIZE ) { throw new InvalidArgumentException ( 'Provided Id must not exceed ' . self :: MAX_ID_SIZE . ' bytes' ) ; } } // start workflow $ this -> http -> post ( $ this -> getInstanceWorkerUrl ( ) , [ self :: ATTR_PROG => self :: PROG , self :: ATTR_CANONICAL => $ canonical , self :: ATTR_NAME => get_class ( $ flow ) , self :: ATTR_DATA => $ this -> serializer -> encode ( $ this -> properties -> getPropertiesFromObject ( $ flow ) ) , self :: ATTR_ID => $ customId , ] ) ; }
Start a workflow instance.

@param WorkflowInterface $flow Workflow to start
Start a workflow instance .