/**
  * @inheritdoc
  */
 public function validateAttribute($model, $attribute)
 {
     $instance = Tag::className();
     if (!$this->{$attribute} instanceof $instance) {
         $given = get_class($this->{$attribute});
         $this->addError($model, $attribute, "{$attribute} must be an instance of '{$instance}', '{$given}' given.");
     }
 }
 /**
  * @param string|\Closure|array $key
  * @param Tag                   $model
  * @param bool                  $fast
  *
  * @return \Closure
  */
 public function getTagsParser($key, Tag $model, $fast = false)
 {
     /**
      * @param $array
      *
      * @return \romkaChev\yandexFotki\models\Tag[]
      */
     return function ($array) use($key, $model, $fast) {
         $login = $model->getYandexFotki()->getLogin();
         $entries = ArrayHelper::getValue($array, $key, []);
         $models = [];
         foreach ($entries as $id => $linkSelf) {
             $localModel = clone $model;
             $localModel->id = mb_strtolower($id);
             $localModel->loadWithData(['id' => "urn:yandex:fotki:{$login}:tag:{$id}", 'urn' => $localModel->defaultUrn(), 'title' => $localModel->defaultTitle(), 'authors' => $localModel->defaultAuthors(), 'links' => ['self' => $localModel->defaultLinkSelf(), 'edit' => $localModel->defaultLinkEdit(), 'photos' => $localModel->defaultLinkPhotos(), 'alternate' => $localModel->defaultLinkAlternate()]], $fast);
             $models[] = $localModel;
         }
         return ArrayHelper::index($models, 'id');
     };
 }
Beispiel #3
0
use romkaChev\yandexFotki\models\AlbumPhotosCollection;
use romkaChev\yandexFotki\models\AlbumsCollection;
use romkaChev\yandexFotki\models\Author;
use romkaChev\yandexFotki\models\Image;
use romkaChev\yandexFotki\models\options\album\CreateAlbumOptions;
use romkaChev\yandexFotki\models\options\album\DeleteAlbumOptions;
use romkaChev\yandexFotki\models\options\album\GetAlbumPhotosOptions;
use romkaChev\yandexFotki\models\options\album\GetAlbumsOptions;
use romkaChev\yandexFotki\models\options\album\UpdateAlbumOptions;
use romkaChev\yandexFotki\models\options\photo\CreatePhotoOptions;
use romkaChev\yandexFotki\models\options\photo\DeletePhotoOptions;
use romkaChev\yandexFotki\models\options\photo\UpdatePhotoOptions;
use romkaChev\yandexFotki\models\options\tag\DeleteTagOptions;
use romkaChev\yandexFotki\models\options\tag\GetTagPhotosOptions;
use romkaChev\yandexFotki\models\options\tag\UpdateTagOptions;
use romkaChev\yandexFotki\models\Photo;
use romkaChev\yandexFotki\models\Point;
use romkaChev\yandexFotki\models\Tag;
use romkaChev\yandexFotki\models\TagPhotosCollection;
use romkaChev\yandexFotki\validators\AddressBindingValidator;
use romkaChev\yandexFotki\validators\AlbumValidator;
use romkaChev\yandexFotki\validators\AuthorValidator;
use romkaChev\yandexFotki\validators\ImageValidator;
use romkaChev\yandexFotki\validators\PhotoValidator;
use romkaChev\yandexFotki\validators\PointValidator;
use romkaChev\yandexFotki\validators\TagValidator;
use romkaChev\yandexFotki\YandexFotki;
use yii\httpclient\Client;
use yii\i18n\Formatter;
return ['id' => 'testApp', 'basePath' => __DIR__, 'vendorPath' => __DIR__ . '/../../../vendor', 'aliases' => ['@web' => '/', '@webroot' => __DIR__ . '/../runtime', '@vendor' => __DIR__ . '/../../../vendor'], 'components' => ['yandexFotki' => ['class' => YandexFotki::className(), 'apiBaseUrl' => 'http://api-fotki.yandex.ru/api', 'serviceBaseUrl' => 'http://fotki.yandex.ru', 'login' => null, 'oauthToken' => null, 'apiHttpClient' => Client::className(), 'serviceHttpClient' => Client::className(), 'albums' => AlbumComponent::className(), 'photos' => PhotoComponent::className(), 'tags' => TagComponent::className(), 'formatter' => Formatter::className(), 'factory' => ['class' => Factory::className(), 'addressBindingModel' => AddressBinding::className(), 'albumModel' => Album::className(), 'albumsCollectionModel' => AlbumsCollection::className(), 'albumPhotosCollectionModel' => AlbumPhotosCollection::className(), 'authorModel' => Author::className(), 'photoModel' => Photo::className(), 'tagModel' => Tag::className(), 'tagPhotosCollectionModel' => TagPhotosCollection::className(), 'pointModel' => Point::className(), 'imageModel' => Image::className(), 'getAlbumsOptions' => GetAlbumsOptions::className(), 'getAlbumPhotosOptions' => GetAlbumPhotosOptions::className(), 'createAlbumOptions' => CreateAlbumOptions::className(), 'updateAlbumOptions' => UpdateAlbumOptions::className(), 'deleteAlbumOptions' => DeleteAlbumOptions::className(), 'createPhotoOptions' => CreatePhotoOptions::className(), 'updatePhotoOptions' => UpdatePhotoOptions::className(), 'deletePhotoOptions' => DeletePhotoOptions::className(), 'getTagPhotosOptions' => GetTagPhotosOptions::className(), 'updateTagOptions' => UpdateTagOptions::className(), 'deleteTagOptions' => DeleteTagOptions::className(), 'addressBindingValidator' => AddressBindingValidator::className(), 'albumValidator' => AlbumValidator::className(), 'authorValidator' => AuthorValidator::className(), 'pointValidator' => PointValidator::className(), 'photoValidator' => PhotoValidator::className(), 'imageValidator' => ImageValidator::className(), 'tagValidator' => TagValidator::className()]]]];
 /**
  * @inheritdoc
  */
 public function getTagModel()
 {
     $this->preProcessConfigurableItem('tagModel', Tag::className());
     return clone $this->tagModel;
 }