public function createConsumer($name, $key = false, $secret = false)
    {
        /* scan through existing consumers to be sure we're not creating a duplicate */
        $consumers = $this->getConsumers();
        $consumerExists = false;
        foreach ($consumers as $consumer) {
            if ($consumer->name == $name) {
                $consumerExists = true;
                break;
            }
        }

        if (!$consumerExists) {
            $consumer = new LTI_Tool_Consumer(
                ($key ? $key : hash('md5', 'key' . time())),
                $this->data_connector,
                true
            );
            $consumer->name = $name;
            $consumer->secret = ($secret ? $secret : hash('md5', 'secret' . time()));
            $consumer->save();
            return true;
        }
        return false;
    }
public function createConsumer($name, $key = false, $secret = false)
    {
        /* scan through existing consumers to be sure we're not creating a duplicate */
        $consumers = $this->getConsumers();
        $consumerExists = false;
        foreach ($consumers as $consumer) {
            if ($consumer->name == $name) {
                $consumerExists = true;
                break;
            }
        }

        if (!$consumerExists) {
            $consumer = new LTI_Tool_Consumer(
                ($key ? $key : hash('md5', 'key' . time())),
                $this->data_connector,
                true
            );
            $consumer->name = $name;
            $consumer->secret = ($secret ? $secret : hash('md5', 'secret' . time()));
            $consumer->save();
            return true;
        }
        return false;
    }
public function createConsumer ( $ name , $ key = false , $ secret = false ) { /* scan through existing consumers to be sure we're not creating a duplicate */ $ consumers = $ this -> getConsumers ( ) ; $ consumerExists = false ; foreach ( $ consumers as $ consumer ) { if ( $ consumer -> name == $ name ) { $ consumerExists = true ; break ; } } if ( ! $ consumerExists ) { $ consumer = new LTI_Tool_Consumer ( ( $ key ? $ key : hash ( 'md5' , 'key' . time ( ) ) ) , $ this -> data_connector , true ) ; $ consumer -> name = $ name ; $ consumer -> secret = ( $ secret ? $ secret : hash ( 'md5' , 'secret' . time ( ) ) ) ; $ consumer -> save ( ) ; return true ; } return false ; }
Create a new tool consumer, optionally with specific key and shared
secret.

@param string $name Human-readable Tool Consumer name (e.g. "My School
Canvas")
@param string $key (Optional) A unique key to identify this consumer
within the database
@param string $secret (Optional) A shared secret to authenticate this tool
consumer
@return void
Create a new tool consumer optionally with specific key and shared secret .