当前位置: 首页>>代码示例>>PHP>>正文


PHP Publisher::fromArray方法代码示例

本文整理汇总了PHP中Publisher::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::fromArray方法的具体用法?PHP Publisher::fromArray怎么用?PHP Publisher::fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Publisher的用法示例。


在下文中一共展示了Publisher::fromArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 protected function parse()
 {
     $data = array();
     $details = $this->getResponseObject()->query('//*[@id="gameDetailsSection"]/div/ul[@class="fields"]')->item(0);
     if ($details) {
         $items = $this->nodeToXPath($details)->query('//li');
         if ($items->length > 0) {
             foreach ($items as $bundle_item) {
                 $val = $this->cleanData($bundle_item->nodeValue);
                 //pre($val);
                 //continue;
                 if (stristr($val, 'release')) {
                     $date = $this->parseValue($val, '/^.+:\\040?(.+)$/');
                     $data['release_date'] = date('Y-m-d H:i:s', strtotime($date));
                 } elseif (stristr($val, 'developer')) {
                     $data['developer'] = $this->parseValue($val, '/^.+:\\040?(.+)$/');
                 } elseif (stristr($val, 'publisher')) {
                     $data['publisher'] = $this->parseValue($val, '/^.+:\\040?(.+)$/');
                 } elseif (stristr($val, 'genre')) {
                     $genres = $this->parseValue($val, '/^.+:\\040?(.+)$/');
                     if ($genres) {
                         $data['genres'] = explode(',', $genres);
                     }
                 } elseif (stristr($val, 'size')) {
                     $val = $this->parseValue($val, '/^.+:\\040?(.+)$/');
                     $data['size'] = $this->parseSize($val);
                 }
             }
         }
         $data['description'] = $this->parseDescription();
         $data['price'] = $this->parsePrice();
         //$data['facebook_iframe_url'] = $this->parseFacebookIframeUrl();
         //pre($data,1);
         if (isset($data['developer'])) {
             $dobject = DeveloperModel::findOneByTitle($data['developer']);
             if (!$dobject) {
                 $dobject = new Developer();
                 $dobject->fromArray(array('title' => $data['developer']));
                 $developer_id = $dobject->save();
             } else {
                 $developer_id = $dobject->id;
             }
             $data['developer_id'] = $developer_id;
         }
         if (isset($data['publisher'])) {
             $dobject = PublisherModel::findOneByTitle($data['publisher']);
             if (!$dobject) {
                 $dobject = new Publisher();
                 $dobject->fromArray(array('title' => $data['publisher']));
                 $publisher_id = $dobject->save();
             } else {
                 $publisher_id = $dobject->id;
             }
             $data['publisher_id'] = $publisher_id;
         }
         $data = $this->cleanData($data);
         pre($data, 1);
         $data['processed'] = 1;
         $this->content_object->fromArray($data);
         $this->content_object->save();
         if (isset($data['genres'])) {
             // remove old genres associations
             $res = ContentToGenreModel::deleteByContentId($this->content_object->id);
             if ($res) {
                 foreach ($data['genres'] as $genre) {
                     $gobject = GenreModel::findOneByTitle($genre);
                     if (!$gobject) {
                         $gobject = new Genre();
                         $gobject->fromArray(array('title' => $genre));
                         $genre_id = $gobject->save();
                     } else {
                         $genre_id = $gobject->id;
                     }
                     $ctg = new ContentToGenre();
                     $ctg->fromArray(array('content_id' => $this->content_object->id, 'genre_id' => $genre_id));
                     $ctg->save();
                 }
             }
         }
     }
 }
开发者ID:typ6a,项目名称:newhtf,代码行数:81,代码来源:XboxOneDLCContentDetailsPageParser.php


注:本文中的Publisher::fromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。