/**
  * Test action.
  */
 public function actionVk()
 {
     $wall = file_get_contents("https://api.vk.com/method/wall.get?owner_id=-120504421&filter=others");
     $wall = json_decode($wall);
     foreach ($wall->response as $item) {
         if (is_object($item)) {
             $advert = new Advert();
             $advert->setScenario(Advert::SCENARIO_CREATE_FROM_SERVICE);
             $advert->content = $item->text;
             $advert->created_at = $item->date;
             $advert->save();
             if (isset($item->attachments)) {
                 foreach ($item->attachments as $a) {
                     $type = $a->type;
                     $f = $a->{$type};
                     $file = new \common\models\Image();
                     $file->remote_url = $f->src_big;
                     $file->created_at = $f->created;
                     $file->save();
                     $file->attachOwner($advert->id, 'Advert', 'files');
                 }
             }
         }
     }
 }