本文整理汇总了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();
}
}
}
}
}