Commit 6e6353e2 by Carsten Brandt

fixed indentation

parent dc7aa25a
...@@ -29,13 +29,13 @@ use yii\test\BaseActiveFixture; ...@@ -29,13 +29,13 @@ use yii\test\BaseActiveFixture;
*/ */
class ActiveFixture extends BaseActiveFixture class ActiveFixture extends BaseActiveFixture
{ {
/** /**
* @var Connection|string the DB connection object or the application component ID of the DB connection. * @var Connection|string the DB connection object or the application component ID of the DB connection.
* After the DbFixture object is created, if you want to change this property, you should only assign it * After the DbFixture object is created, if you want to change this property, you should only assign it
* with a DB connection object. * with a DB connection object.
*/ */
public $db = 'elasticsearch'; public $db = 'elasticsearch';
/** /**
* @var string the name of the index that this fixture is about. If this property is not set, * @var string the name of the index that this fixture is about. If this property is not set,
* the name will be determined via [[modelClass]]. * the name will be determined via [[modelClass]].
* @see modelClass * @see modelClass
...@@ -66,14 +66,14 @@ class ActiveFixture extends BaseActiveFixture ...@@ -66,14 +66,14 @@ class ActiveFixture extends BaseActiveFixture
if (!isset($this->modelClass) && (!isset($this->index) || !isset($this->type))) { if (!isset($this->modelClass) && (!isset($this->index) || !isset($this->type))) {
throw new InvalidConfigException('Either "modelClass" or "index" and "type" must be set.'); throw new InvalidConfigException('Either "modelClass" or "index" and "type" must be set.');
} }
/* @var $modelClass ActiveRecord */ /* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass; $modelClass = $this->modelClass;
if ($this->index === null) { if ($this->index === null) {
$this->index = $modelClass::index(); $this->index = $modelClass::index();
} }
if ($this->type === null) { if ($this->type === null) {
$this->type = $modelClass::type(); $this->type = $modelClass::type();
} }
} }
/** /**
...@@ -90,21 +90,21 @@ class ActiveFixture extends BaseActiveFixture ...@@ -90,21 +90,21 @@ class ActiveFixture extends BaseActiveFixture
$this->resetIndex(); $this->resetIndex();
$this->data = []; $this->data = [];
$mapping = $this->db->createCommand()->getMapping($this->index, $this->type); $mapping = $this->db->createCommand()->getMapping($this->index, $this->type);
if (isset($mapping[$this->index]['mappings'][$this->type]['_id']['path'])) { if (isset($mapping[$this->index]['mappings'][$this->type]['_id']['path'])) {
$idField = $mapping[$this->index]['mappings'][$this->type]['_id']['path']; $idField = $mapping[$this->index]['mappings'][$this->type]['_id']['path'];
} else { } else {
$idField = '_id'; $idField = '_id';
} }
foreach ($this->getData() as $alias => $row) { foreach ($this->getData() as $alias => $row) {
$options = []; $options = [];
$id = isset($row[$idField]) ? $row[$idField] : null; $id = isset($row[$idField]) ? $row[$idField] : null;
$response = $this->db->createCommand()->insert($this->index, $this->type, $row, $id, $options); $response = $this->db->createCommand()->insert($this->index, $this->type, $row, $id, $options);
if ($id === null) { if ($id === null) {
$row[$idField] = $response['_id']; $row[$idField] = $response['_id'];
} }
$this->data[$alias] = $row; $this->data[$alias] = $row;
} }
} }
...@@ -136,10 +136,10 @@ class ActiveFixture extends BaseActiveFixture ...@@ -136,10 +136,10 @@ class ActiveFixture extends BaseActiveFixture
*/ */
protected function resetIndex() protected function resetIndex()
{ {
$this->db->createCommand([ $this->db->createCommand([
'index' => $this->index, 'index' => $this->index,
'type' => $this->type, 'type' => $this->type,
'queryParts' => ['query' => ['match_all' => new \stdClass()]], 'queryParts' => ['query' => ['match_all' => new \stdClass()]],
])->deleteByQuery(); ])->deleteByQuery();
} }
} }
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