| @@ 19-36 (lines=18) @@ | ||
| 16 | use Webuni\Srazy\Crawler; |
|
| 17 | use Webuni\Srazy\Model\User; |
|
| 18 | ||
| 19 | class AttendeesPage extends AbstractPage |
|
| 20 | { |
|
| 21 | public function getAttendees() |
|
| 22 | { |
|
| 23 | $attendees = $this->crawler->filter('.attendee-name')->each(function (Crawler $node) { |
|
| 24 | $uri = $node->link()->getUri(); |
|
| 25 | ||
| 26 | $user = $this->client->model(User::class, $uri); |
|
| 27 | $user->setUri($uri); |
|
| 28 | $user->setName(trim($node->text())); |
|
| 29 | $user->setAvatar($node->filter('img')->image()->getUri()); |
|
| 30 | ||
| 31 | return $user; |
|
| 32 | }); |
|
| 33 | ||
| 34 | return new ArrayCollection($attendees); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | ||
| @@ 19-37 (lines=19) @@ | ||
| 16 | use Webuni\Srazy\Crawler; |
|
| 17 | use Webuni\Srazy\Model\User; |
|
| 18 | ||
| 19 | class CommunityPage extends AbstractPage |
|
| 20 | { |
|
| 21 | public function getUsers() |
|
| 22 | { |
|
| 23 | $users = $this->crawler->filter('.user-list a')->each(function (Crawler $node) { |
|
| 24 | $uri = $node->link()->getUri(); |
|
| 25 | ||
| 26 | /* @var $user User */ |
|
| 27 | $user = $this->client->model(User::class, $uri); |
|
| 28 | $user->setUri($uri); |
|
| 29 | $user->setName($node->attr('title')); |
|
| 30 | $user->setAvatar($node->filter('img')->image()->getUri()); |
|
| 31 | ||
| 32 | return $user; |
|
| 33 | }); |
|
| 34 | ||
| 35 | return new ArrayCollection($users); |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||