/** * Adds a new item to the specified feed. * @param string $feedId * @param models\Item $item * @return boolean False if the addition is unsuccessful for some reason. * @throws \yii\base\InvalidConfigException */ public function addItemToFeed($feedId, models\Item $item) { if (empty($this->feeds[$feedId])) { throw new InvalidConfigException("Feed `{$feedId}` don`t set in `feeds` property."); } if (!$item->validate()) { $errorMessage = ''; foreach ($item->errors as $error) { $errorMessage = implode(PHP_EOL, $error); } throw new InvalidConfigException("RSS module: {$errorMessage}"); } Yii::$app->cache->delete("{$this->cacheKeyPrefix}-{$feedId}"); $model = new Feed(); $model->setAttributes($item->attributes, false); $model->feed_id = $feedId; return $model->save(); }