Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SymfonyCasts] Added new bridge #2000

Merged
merged 6 commits into from
Feb 28, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions bridges/SymfonyCastsBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class SymfonyCastsBridge extends BridgeAbstract {
const NAME = 'SymfonyCasts Bridge';
const URI = 'https://symfonycasts.com/';
const DESCRIPTION = 'Follow new updates on symfonycasts.com';
const MAINTAINER = 'No maintainer';
Park0 marked this conversation as resolved.
Show resolved Hide resolved
const CACHE_TIMEOUT = 3600;

public function collectData() {
$html = getSimpleHTMLDOM('https://symfonycasts.com/updates/find')
or returnServerError('Unable to get page.');
$dives = $html->find('div');

/* @var simple_html_dom $div */
foreach ($dives as $div) {
//var_dump($div);die();
//dump_html_tree($div);die();
Park0 marked this conversation as resolved.
Show resolved Hide resolved
$id = $div->getAttribute('data-mark-update-id-value');
$type = $div->find('h5', 0);
$title = $div->find('span', 0);
$dateString = $div->find('h5.font-gray', 0);
$href = $div->find('a', 0);
Park0 marked this conversation as resolved.
Show resolved Hide resolved
$url = 'https://symfonycasts.com' . $href->getAttribute('href');

$item = array(); // Create an empty item
$item['uid'] = $id;
$item['title'] = $title->innertext;
Park0 marked this conversation as resolved.
Show resolved Hide resolved
$item['timestamp'] = $dateString->innertext;
$item['content'] = $type->plaintext. '<a href="' . $url . '">' . $title . '</a>';
Park0 marked this conversation as resolved.
Show resolved Hide resolved
$item['uri'] = $url;
$this->items[] = $item; // Add item to the list
}

}
}