Search for a url in the message,
if we find one, then we fetch it

@param NewsItemEntity $newsItem entity from the DB or the form context
@param NewsItemEntity $data entity from the form
@return NewsItemEntity
343507
private function searchUrl(NewsItemEntity $newsItem)
    {
        $pattern = '/[-a-zA-Z0-9:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,10}\b(\/[-a-zA-Z0-9:%_\+.~#?&\/\/=]*)?/i';

        if (!preg_match($pattern, $newsItem->getMessage(), $matches)) {
            // No link found, so set link data to null.
            return $this->unsetUrl($newsItem);
        }

        $url = $matches[0];

        $result = $this->scrapeUrl($url);

        if (empty($result)) {
            return $this->unsetUrl($newsItem);
        }

        $newsItem->setLinkUrl(ParserUtil::sanitizeUrl($url));
        $newsItem->setLinkTitle($result['title']);
        $newsItem->setLinkDescription($result['description']);

        return $newsItem;
    }
107635
public function index(NewsRequest $request)
    {
        $view = $this->response->theme->listView();

        if ($this->response->typeIs('json')) {
            $function = camel_case('get-' . $view);
            return $this->repository
                ->setPresenter(\Litecms\News\Repositories\Presenter\NewsPresenter::class)
                ->$function();
        }

        $news = $this->repository->paginate();

        return $this->response->title(trans('news::news.names'))
            ->view('news::news.index', true)
            ->data(compact('news'))
            ->output();
    }
853
public function getWithNsQuery($ns, array $data, $mark = true)
    {
        if ($this->hasQuery($ns)) {
            $query = $this->getQuery($ns);
            $url = null;

            if ($mark === true) {
                $url = '?';
            }

            $url .= http_build_query(array($ns => array_merge($query, $data)));
            $url = str_replace('%25s', '%s', $url);

            return $url;
        } else {
            return null;
        }
    }
1244887
public function news($newsData=array())
	{

		$count = count($newsData);

		$msg = array(
			'ToUserName' => $this->getRevFrom(),
			'FromUserName'=>$this->getRevTo(),
			'MsgType'=>self::MSGTYPE_NEWS,
			'CreateTime'=>time(),
			'ArticleCount'=>$count,
			'Articles'=>$newsData,

		);
		$this->Message($msg);
		return $this;
	}
234133
protected function addUrl($contact, $data)
    {
        $success = true;

        $urlType = $this->em->getRepository(
            self::$urlTypeEntityName
        )->find($data['urlType']['id']);

        if (isset($data['id'])) {
            throw new EntityIdAlreadySetException(self::$urlEntityName, $data['id']);
        } elseif (!$urlType) {
            throw new EntityNotFoundException(self::$urlTypeEntityName, $data['urlType']['id']);
        } else {
            $url = new Url();
            $url->setUrl($data['url']);
            $url->setUrlType($urlType);
            $this->em->persist($url);
            $contact->addUrl($url);
        }

        return $success;
    }
1169218
public function get($url, $data = array(), $dataType = null)
    {
        return $this->processMethod($url, $data, $dataType, 'GET');
    }
785212
public function findBy($data)
    {
        $qb = $this->repository->createQueryBuilder('p');
        $qb->select('p');
        $qb->where('p.queue = :queue');
        $qb->setParameter('queue', $this->name);

        $field = (isset($data['field'])) ? $data['field'] : 'message';

        if (isset($data['search']) && $data['search'] !== null) {
            $qb->andWhere('p.' . $field . ' LIKE :contains');
            $qb->setParameter('contains', '%' . $data['search'] . '%');
        }

        if (isset($data['from']) && $data['from'] !== null && isset($data['to']) && $data['to'] !== null) {
            $qb->andWhere('p.created BETWEEN :from AND :to');
            $qb->setParameter('from', $data['from']);
            $qb->setParameter('to', $data['to']);
        } 

        return $qb->getQuery();
    }
541201
public function get($url, array $data = array(), array $extra = array())
    {
        if (!empty($data)) {
            $url = $url . '?' . http_build_query($data);
        }

		$curl = new Curl(array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => false
        ), $extra);

        return $curl->exec();
    }
45883
public function get($url, $data = []) {
        if (!empty($data)) {
            if (is_array($data)) {
                $data = http_build_query($data);
            }
            if (strpos($url, '?') !== false) {
                $url .= '&' . $data;
            }
            else {
                $url .= '?' . $data;
            }
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);

        $this->_parse_result($ch);

        $content = curl_exec($ch);
        curl_close($ch);

        if ($this->handle_referer) {
            $this->referer = $url;
        }

        return $this->_parse_result($content);
    }
993314
public function getNews4Id($newsId)
    {
        /** @var \PServerCore\Entity\Repository\News $repository */
        $repository = $this->entityManager->getRepository($this->collectionOptions->getEntityOptions()->getNews());
        return $repository->getNews4Id($newsId);
    }
1026036
function getContentItemSelection($data=false)
    {
        $selection = json_encode($this->json);
        $parms = array();
        $parms["lti_message_type"] = "ContentItemSelection";
        $parms["lti_version"] = "LTI-1p0";
        $parms["content_items"] = $selection;
        if ( $data ) $parms['data'] = $data;
        return $parms;
    }
1290722
public function createSite(
        Site $newSite
    ) {
        $newSite = $this->prepareNewSite($newSite);

        $entityManager = $this->getEntityManager();

        /** @var \Rcm\Repository\Page $pageRepo */
        $pageRepo = $entityManager->getRepository(\Rcm\Entity\Page::class);

        $user = $this->getCurrentUserTracking();

        $entityManager->persist($newSite);
        $entityManager->flush($newSite);

        $this->siteVersionRepo->publish(
            new SiteLocator($newSite->getDomainName()),
            $this->siteToImmutableSiteContent($newSite),
            $this->getCurrentUserTracking()->getId(),
            __CLASS__ . '::' . __FUNCTION__,
            $newSite->getSiteId()
        );

        foreach ($this->getDefaultSitePageSettings($user) as $name => $pageData) {
            $createdPage = $this->pageMutationService->createNewPage(
                $user,
                $newSite->getSiteId(),
                $pageData['name'],
                $pageData['pageType'],
                //Axosoft ticket #22776 was created to fix this @TODO. it is a pretty low priority issue
                $pageData //@TODO this is probably not in the correct format for plugins/blocks/pluginWrapper data
            );
            $this->pageMutationService->publishPageRevision(
                $user,
                $newSite->getSiteId(),
                $pageData['name'],
                $pageData['pageType'],
                $createdPage->getStagedRevision()->getRevisionId(),
                function ($pageName, $pageType = PageTypes::NORMAL, $pageRevision = null) {
                    if ($pageType !== PageTypes::NORMAL || $pageRevision !== null) {
                        throw new \Exception('Unsupported Case');

                        return '/' . $pageName;
                    }
                }
            );
        }

        return $newSite;
    }
1044533
private function applyUrls(Siteroot $siteroot, array $data)
    {
        if (!array_key_exists('mappings', $data)) {
            // noting to save
            return $this;
        }

        $urlsData = $data['mappings'];

        foreach ($urlsData['created'] as $row) {
            $url = new Url();
            $url
                ->setSiteroot($siteroot)
                ->setDefault(!empty($row['default']))
                ->setGlobalDefault(!empty($row['global_default']))
                ->setHostname($row['hostname'])
                ->setLanguage($row['language'])
                ->setTarget($row['target']);

            $siteroot->addUrl($url);
        }

        foreach ($urlsData['modified'] as $row) {
            foreach ($siteroot->getUrls() as $url) {
                if ($url->getId() === $row['id']) {
                    $url
                        ->setSiteroot($siteroot)
                        ->setDefault(!empty($row['default']))
                        ->setGlobalDefault(!empty($row['global_default']))
                        ->setHostname($row['hostname'])
                        ->setLanguage($row['language'])
                        ->setTarget($row['target']);

                    break;
                }
            }
        }

        foreach ($urlsData['deleted'] as $id) {
            foreach ($siteroot->getUrls() as $url) {
                if ($url->getId() === $id) {
                    $siteroot->removeUrl($url);
                    break;
                }
            }
        }

        return $this;
    }
907991
public function get($url, array $data = [])
    {
        if (count($data) > 0) {
            $this->setopt(CURLOPT_URL, $url.'?'.http_build_query($data));
        } else {
            $this->setopt(CURLOPT_URL, $url);
        }
        $this->setopt(CURLOPT_HTTPGET, true);
        $this->_exec();
    }
319147
public function updatePartials(int $articleId, array $data): ArticleInterface
    {
        $this->shopware()->put('/api/articles/' . $articleId, [], $data);

        return $this->find($articleId);
    }
1070341
public function serialize(ContentItem $contentItem, array $options = [])
    {
        $serialized = [];

        if (1 === preg_match('#^text\/[^/]+$#', $contentItem->getQuestion()->getMimeType())) {
            $serialized['data'] = $contentItem->getData();
        } else {
            $serialized['url'] = $contentItem->getData();
        }

        return $serialized;
    }
503771
public function parseUrl($url, array $data)
    {
        return (empty($data)) ? $url : $url . '?' . $this->parseData($data);
    }