public function subToTopic($topic, $subName)
 {
     $subService = $this->googlePubSubService->projects_subscriptions;
     $sub = new \Google_Service_Pubsub_Subscription();
     $sub->setName($subName);
     //projects/io-anvil/topics/media-update
     $sub->setTopic($this->topicStub . $topic);
     //projects/io-anvil/subscriptions/sub-23
     $subService->create($this->subStub . $subName, $sub);
     return true;
 }
 /**
  * @param \Google_Client $client
  * @param string         $projectId
  * @param string         $topicName
  * @param string|null    $subscriptionName
  * @param int|null       $ackDeadlineSeconds
  */
 public function __construct(\Google_Client $client, $projectId, $topicName, $subscriptionName = null, $ackDeadlineSeconds = null)
 {
     $this->_client = $client;
     $this->_projectId = $projectId;
     $this->_topicShortName = $topicName;
     $this->_subscriptionShortName = $subscriptionName;
     // For v1 API (currently on v1beta)
     //$topicPath = 'projects/' . $this->_project . '/topics/' . $this->_topic;
     $topicPath = '/topics/' . $projectId . '/' . $topicName;
     $this->_topic = new \Google_Service_Pubsub_Topic();
     $this->_topic->setName($topicPath);
     if ($subscriptionName) {
         $this->_subscription = new \Google_Service_Pubsub_Subscription();
         $this->_subscription->setTopic($topicPath);
         $this->_subscription->setName('/subscriptions/' . $projectId . '/' . $subscriptionName);
         if ($ackDeadlineSeconds) {
             $this->_subscription->setAckDeadlineSeconds($ackDeadlineSeconds);
         }
         // for v1 API
         //$this->_subscription->setName(
         //  'projects/' . $this->_project . '/subscriptions/' . $this->_subscription
         //);
     }
 }