/**
  * {@inheritDoc}
  */
 public function setManyToOne($data, $model, $property)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setManyToOne', array($data, $model, $property));
     return parent::setManyToOne($data, $model, $property);
 }
Пример #2
0
 /**
  * @param Locale $locale
  * @param int $limit
  * @return array
  */
 private function fetchRssFeedData(Locale $locale, $limit = 5)
 {
     $lang = 'de';
     if ($locale->getLocale() != 'de_DE') {
         $lang = 'en';
     }
     $result = [];
     try {
         $xml = new \SimpleXMLElement(file_get_contents('https://' . $lang . '.shopware.com/news/?sRss=1', false, stream_context_create(['http' => ['timeout' => 20]])));
     } catch (Exception $e) {
         return $result;
     }
     /**
      * @var \SimpleXMLElement $news
      */
     foreach ($xml->channel->item as $news) {
         $tmp = (array) $news->children();
         $date = new \DateTime($tmp['pubDate']);
         $result[] = ['title' => $tmp['title'], 'link' => $tmp['link'], 'linkHash' => md5($tmp['link']), 'pubDate' => $date->format('Y-m-d\\TH:i:s')];
     }
     if ($limit) {
         $result = array_slice($result, 0, $limit);
     }
     return $result;
 }
Пример #3
0
 /**
  * Helper function which translates associated array data.
  *
  * @param array $association
  * @param Locale $locale
  * @param $type
  * @return array
  */
 protected function translateAssociation(array $association, Locale $locale, $type)
 {
     foreach ($association as &$item) {
         $translation = $this->getSingleTranslation($type, $locale->getId(), $item['id']);
         if (empty($translation)) {
             continue;
         }
         $item = $this->mergeTranslation($item, $translation['data']);
     }
     return $association;
 }