Because each message creative can only attach to 1 broadcast so we'll create message creative each time we send

@param Broadcast $broadcast

@return Mixed
509570
public static function createMessageCreative(BroadcastModel $broadcast)
    {
        
        if (is_numeric($broadcast->content)) {
            $template             = Node::find($broadcast->content)->answers;
        }
        else {
            $model = new Model;
            $template = $model->parse(json_decode($broadcast->content, true));
        }

        $messages = [];

        foreach ($template as $answer) {
            if (!in_array($answer['type'], ['text', 'receipt'])) {
                $messages[] = $answer['content'];
            }

            if ($answer['type'] === 'text') {
                // Convert to Dynamic Text
                if (str_contains($answer['content']['text'], '{{')) {
                    $messages[] = [
                    'dynamic_text' => [
                        'text'          => $answer['content']['text'],
                        'fallback_text' => $answer['content']['text']
                    ]
                ];
                } else {
                    $messages[] = $answer['content'];
                }
            }
        }

        // Create message creative
        $response = giga_facebook_post('me/message_creatives', compact('messages'));

        if (isset($response->message_creative_id)) {
            return $response->message_creative_id;
        } else {
            throw new \Exception("Cannot create message creative!", 1);
        }
    }
85259
protected function createReceiveVoiceMsg(array $data)
    {
        $result = new WxReceiveVoiceMsg();
        $this->initReceiveMsg($result, $data);
        $result->setMediaId(isset($data['MediaId']) ? trim($data['MediaId']) : '');
        $result->setFormat(isset($data['Format']) ? trim($data['Format']) : '');
        return $result;
    }
377974
public function getBroadcast(): ?Broadcaster
    {
        if (!$this->hasBroadcast()) {
            $this->setBroadcast($this->getDefaultBroadcast());
        }
        return $this->broadcast;
    }
1315464
public function copy(CopyResourceEvent $event)
    {
        /** @var AnnouncementAggregate $aggregate */
        $aggregate = $event->getResource();

        $this->om->startFlushSuite();
        $copy = $event->getCopy();
        $announcements = $aggregate->getAnnouncements();

        foreach ($announcements as $announcement) {
            $newAnnouncement = $this->manager->serialize($announcement);
            $newAnnouncement['id'] = Uuid::uuid4()->toString();
            $this->crud->create('Claroline\AnnouncementBundle\Entity\Announcement', $newAnnouncement, [
              'announcement_aggregate' => $copy,
              Options::NO_LOG => Options::NO_LOG,
            ]);
        }

        $this->om->endFlushSuite();

        $event->setCopy($copy);
        $event->stopPropagation();
    }
361719
public function getPayload()
    {
        // GCM base payload structure
        $payload = array();

        // Payload for single recipient or multicast?
        if (count($tokens = $this->getTokens()) == 1) {
            $payload['to'] = reset($tokens);
        } else {
            $payload['registration_ids'] = $tokens;
        }

        // Build notification
        if ($this->getNotificationTitle()) {
            $payload['notification']['title'] = $this->getNotificationTitle();
        }
        if ($this->getNotificationBody()) {
            $payload['notification']['body'] = $this->getNotificationBody();
        }
        if ($this->getNotificationIcon()) {
            $payload['notification']['icon'] = $this->getNotificationIcon();
        }
        if ($this->getNotificationSound()) {
            $payload['notification']['sound'] = $this->getNotificationSound();
        }
        if ($this->getNotificationTag()) {
            $payload['notification']['tag'] = $this->getNotificationTag();
        }
        if ($this->getNotificationBadge()) {
            $payload['notification']['badge'] = $this->getNotificationBadge();
        }
        if ($this->getNotificationColor()) {
            $payload['notification']['color'] = $this->getNotificationColor();
        }
        if ($this->getNotificationClickAction()) {
            $payload['notification']['click_action'] = $this->getNotificationClickAction();
        }
        if ($this->getNotificationBodyLocKey()) {
            $payload['notification']['body_loc_key'] = $this->getNotificationBodyLocKey();
        }
        if ($this->getNotificationBodyLocArgs()) {
            $payload['notification']['body_loc_args'] = $this->getNotificationBodyLocArgs();
        }
        if ($this->getNotificationTitleLocKey()) {
            $payload['notification']['title_loc_key'] = $this->getNotificationTitleLocKey();
        }
        if ($this->getNotificationTitleLocArgs()) {
            $payload['notification']['title_loc_args'] = $this->getNotificationTitleLocArgs();
        }

        // Build extra content
        if ($this->getCollapseKey()) {
            $payload['collapse_key'] = $this->getCollapseKey();
        }
        if ($this->getPriority() !== self::DEFAULT_PRIORITY) {
            $payload['priority'] = $this->getPriority();
        }
        if ($this->getRestrictedPackageName()) {
            $payload['restricted_package_name'] = $this->getRestrictedPackageName();
        }
        if (!is_null($this->getContentAvailable())) {
            $payload['content_available'] = $this->getContentAvailable();
        }
        if (!is_null($this->getDelayWhileIdle())) {
            $payload['delay_while_idle'] = $this->getDelayWhileIdle();
        }
        if (!is_null($this->getDryRun())) {
            $payload['dry_run'] = $this->getDryRun();
        }
        if (!is_null($this->getTimeToLive())) {
            $payload['time_to_live'] = $this->getTimeToLive();
        }
        if ($this->getData()) {
            $payload['data'] = $this->getData();
        }

        // Return payload
        return $payload;
    }
1027451
public static function create($host, $port)
  {
    $transceiver = new SocketTransceiver();
    $transceiver->createSocket($host, $port);
    
    return $transceiver;
  }
633506
public static function make($rules = [], $message = [])
    {
        if (is_null(self::$instance)) {
            self::$instance = new self($rules, $message);
        }
        return self::$instance;
    }
79583
protected function uniqueMessages($messageBag, $messageBagFromCustom = null)
    {
        if (is_null($messageBagFromCustom)) {
            return $messageBag;
        }
        $messages = $messageBagFromCustom->getMessages();
        foreach ($messages as $key => $value) {
            if (empty($value)) {
                continue;
            }
            foreach ($value as $messageName) {
                if ($messageBag->has($key, $messageName)) {
                    continue;
                }
                $messageBag->add($key, $messageName);
            }
        }
        return $messageBag;
    }
1157274
public function broadcastType()
    {
        return method_exists($this->notification, 'broadcastType')
                    ? $this->notification->broadcastType()
                    : get_class($this->notification);
    }
542009
public function flashMessage($message, $type = 'default', $comment=null, $icon=null, $width=50, $iconSize="lg", $timeout=5)
    {
        $id = $this->getParameterId('flash');
        $presenter = $this->getPresenter();
        if($presenter instanceof Presenter){
            $messages = $presenter->getFlashSession()->$id;
        } else {
            $messages = null;
        }

        $messages[] = $flash = (object) [
             'title' => $message,
             'type' => $type,
             'comment' => $comment,
             'icon' => $icon,
             'width' => $width,
             'iconSize' =>$iconSize,
             'timeout' => $timeout
         ];
        $this->getTemplate()->flashes = $messages;
        if($presenter instanceof Presenter){
            $presenter->getFlashSession()->$id = $messages;
        }
        return $flash;
    }
300443
public function transmission(Message $message)
    {
        if (!$this->pusher) {
            return false;
        }

        $sender = $message->sender->toArray();
        $messageArray = $message->toArray();
        $messageArray['sender'] = $sender;
        $this->dispatch(new Webcast($messageArray));
    }
1308292
public function getCreatedAt($format = 'Y-m-d H:i:s')
    {
        if ($this->createdAt instanceof \DateTime && $format !== null) {
            return $this->createdAt->format($format);
        }

        return $this->createdAt;
    }
1063000
public function channel(string $channel): Observable
    {
        // Only join a channel once
        if (isset($this->channels[$channel])) {
            return $this->channels[$channel];
        }

        // Ensure we only get messages for the given channel
        $channelMessages = $this->messages->filter(function (Event $event) use ($channel) {
            return $event->getChannel() !== '' && $event->getChannel() === $channel;
        });

        $subscribe = $this->connected
            ->do(function () use ($channel) {
                // Subscribe to pusher channel after connected
                $this->send(Event::subscribeOn($channel));
            })
            ->flatMapTo(Observable::empty());

        // Observable representing channel events
        $this->channels[$channel] = $channelMessages
            ->merge($subscribe)
            ->filter([Event::class, 'subscriptionSucceeded'])
            ->retryWhen(function (Observable $errors) {
                return $errors->flatMap(function (Throwable $throwable) {
                    return $this->handleLowLevelError($throwable);
                });
            })
            ->finally(function () use ($channel) {
                // Send unsubscribe event
                $this->send(Event::unsubscribeOn($channel));

                // Remove our channel from the channel list so we don't resubscribe in case we reconnect
                unset($this->channels[$channel]);
            })
            ->singleInstance();

        return $this->channels[$channel];
    }
460029
public function dispatch(Event $event)
        {
            $message = sprintf(self::FMT_INF_DISPATCHING, $event->getId(), count($this->subscriptions));
            $this->logger->info($message);

            $dispatchCount = 0;

            foreach ($this->subscriptions as $subscription) {
                $result = $this->tryDispatch($subscription, $event);

                $dispatchCount += (int)$result;
            }

            $message = sprintf(self::FMT_INF_DISPATCHED, $event->getId(), $dispatchCount);
            $this->logger->info($message);

            return $dispatchCount;
        }
1361674
public function unique($message = null)
    {
        $this->addValidationRule('_unique');

        if (! is_null($message)) {
            $this->addValidationMessage('unique', $message);
        }

        return $this;
    }
963873
protected function transform($messages, $format, $messageKey)
    {
        $messages = (array) $messages;

        // We will simply spin through the given messages and transform each one
        // replacing the :message place holder with the real message allowing
        // the messages to be easily formatted to each developer's desires.
        foreach ($messages as $key => &$message) {
            $replace = [':message', ':key'];

            $message = str_replace($replace, [$message, $messageKey], $format);
        }

        return $messages;
    }
1248274
protected function broadcastEvent($event)
    {
        $connection = ($event instanceof ShouldBroadcastNowInterface) ? 'sync' : null;

        $queue = method_exists($event, 'onQueue') ? $event->onQueue() : null;

        $this->resolveQueue()->connection($connection)->pushOn($queue, 'Nova\Broadcasting\BroadcastEvent', array(
            'event' => serialize(clone $event),
        ));
    }