Commit d7d6d4b9 authored by Simonas's avatar Simonas

merge conflict

parents 785ef064 e2129363
......@@ -12,7 +12,7 @@ class JsonDataCollector
'title' => 'pareigos',
'post_content' => 'aprasymas',
'slug' => 'seo_url',
'contact' => 'kontaktai',
'contact' => 'contacts',
'salary_from' => 'atlygis_nuo',
'salary_to' => 'atlygis_iki',
// 'email' => 'email',
......@@ -32,14 +32,21 @@ class JsonDataCollector
],
'field' => [
'slug' => 'kategorija',
'name' => 'sritis'
'name' => 'sritis',
'__primary' => true,
'additionalCategories' => [
'slug' => 'category_id',
'name' => 'category_name',
]
],
'company' => [
'name' => 'imone'
],
'type' => [
'slug' => 'type',
'name' => 'type'
'types' => [
'slug' => 'type_id',
'name' => 'type_name'
]
],
// 'tag'
// 'position',
......@@ -53,17 +60,6 @@ class JsonDataCollector
],
];
protected $collections = [
'city' => [
'name' => 'additionalCities',
'map' => [
'slug' => 'city_id',
'name' => 'city',
],
'append' => 'terms:city'
]
];
// Language map
protected $lang = 'kalba';
......@@ -139,25 +135,6 @@ class JsonDataCollector
$item['posts'] = $this->getPosts($ad);
$item['relations'] = $this->relationsMap;
// foreach ($this->dataMap as $mapKey => $dataKey) {
// $dataValue = $ad->{$dataKey};
// $itemValue = $this->getValue($dataValue);
// $postValue = $this->getValue($dataValue);
// $item[$mapKey] = $itemValue;
//
//// if (array_key_exists($mapKey, $this->relationsMap)) {
//// $item['related_items'][$mapKey] = $this->relationsMap[$mapKey];
//// }
// }
//
// foreach ($this->relationsMap as $keyItem => $valueItem) {
// if (array_key_exists($keyItem, $item) && array_key_exists($valueItem, $item)) {
// $item[$valueItem] = [$valueItem . '_' . $item[$keyItem] => $item[$valueItem]];
// unset($item[$keyItem]);
// }
// }
$result[] = $item;
};
......@@ -184,11 +161,18 @@ class JsonDataCollector
foreach ($this->terms as $termKey => $termProperties) {
$result[$termKey][] = $this->getEntity($ad, $termProperties);
$entity = $this->getEntity($ad, $termProperties);
if ( ! empty($entity)) {
$result[$termKey][] = $entity;
}
$appends = array_filter($termProperties, function($item) {
return is_array($item);
});
foreach ($appends as $propertyKey => $propertyValues) {
if (isset($ad->{$propertyKey})) {
......@@ -238,29 +222,6 @@ class JsonDataCollector
return $result;
}
private function getCollection($ad, $collectionMap)
{
$result = [];
foreach ($this->collections as $collection) {
if (isset($ad->{$collection['name']})) {
$data = $ad->{$collection['name']};
}
$entity = [];
foreach ($collection['map'] as $propertyKey => $propertyValue) {
if (preg_match('/^\_\_/', $propertyKey)) {
$entity[$propertyKey] = $propertyValue;
}
elseif (isset($data[$propertyValue])) {
$dataValue = $data[$propertyValue];
$entity[$propertyKey] = $this->getValue($dataValue);
}
}
}
}
private function getValue($value)
{
return (is_array($value)) ? $value : html_entity_decode($value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment