Skip to content

Commit 456b8a3

Browse files
committed
adapter for lavozdegalicia.es
1 parent 7fe103f commit 456b8a3

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

src/Adapters/Adapter.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,21 @@ public function __construct(Request $request, array $config = null)
7272
$this->imageConfig = $config['image']['config'];
7373
}
7474

75+
$this->init();
76+
}
77+
78+
/**
79+
* Init the adapter
80+
*/
81+
protected function init()
82+
{
7583
$this->run();
7684

7785
//if the canonical url is different, repeat the proccess
7886
$canonical = $this->getUrl();
7987

80-
if ($request->getUrl() !== $canonical) {
81-
$request = $request->withUrl($canonical);
88+
if ($this->request->getUrl() !== $canonical) {
89+
$request = $this->request->withUrl($canonical);
8290

8391
if ($request->isValid()) {
8492
$this->request = $request;

src/Adapters/Lavozdegalicia.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Adapter to provide all information from lavozdegalicia.es that needs a special query parameter to generate a session cookie
4+
*/
5+
namespace Embed\Adapters;
6+
7+
use Embed\Request;
8+
use Embed\Providers;
9+
10+
class Lavozdegalicia extends Webpage implements AdapterInterface
11+
{
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
public static function check(Request $request)
16+
{
17+
return $request->match([
18+
'http://www.lavozdegalicia.es/*',
19+
]);
20+
}
21+
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
protected function init()
26+
{
27+
$this->request = $this->request->withQueryParameter('piano_d', '1');
28+
29+
$this->run();
30+
}
31+
}

tests/LavozdegaliciaTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
class Lavozdegalicia extends PHPUnit_Framework_TestCase
3+
{
4+
public function testOne()
5+
{
6+
$info = Embed\Embed::create('http://www.lavozdegalicia.es/noticia/cultura/2015/07/26/desenadores-galegos-organizan-seu-primeiro-encontro-rianxo/0003_201507G26P46995.htm');
7+
8+
$this->assertEquals($info->title, 'Deseñadores galegos organizan o seu primeiro encontro en Rianxo');
9+
$this->assertEquals($info->type, 'link');
10+
$this->assertEquals($info->providerName, 'La Voz de Galicia');
11+
$this->assertEquals($info->providerUrl, 'http://lavozdegalicia.es');
12+
}
13+
}

0 commit comments

Comments
 (0)