Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @param type $systemType
- * @param type $roleList
- * @return ActiveDataProvider
- */
- public function searchTag($systemType = 'sector', $roleList = [], $recursive = true)
- {
- $seedList = $this->getSeedList($recursive);
- $class = $this->getClass();
- $query = $class::find();
- $query->select([
- $this->mode . '_tag.id as id',
- "concat($systemType.code,' - ', tag.name) as tagName",
- "tag.id as tag",
- $this->mode . '_tag_role.id as role',
- $this->mode . '_tag_role.name as roleName'
- ]);
- $query->joinWith('relatedTag', true, 'INNER JOIN');
- $query->joinWith('relatedTag.' . $systemType, true, 'INNER JOIN');
- $query->joinWith('tagRole', true, 'INNER JOIN');
- //mode: subject or object
- if (empty($roleList)) {
- $roleList = array_keys($this->getRoleList());
- }
- $query->andWhere([
- 'in', $this->mode . '_tag_role.id', $roleList,
- ]);
- $query->andWhere([
- 'in', $this->mode, $seedList,
- ]);
- return new ActiveDataProvider([
- 'query' => $query,
- ]);
- }
- private function getQuery($systemType = 'sector', $roleList = [], $recursive = true)
- {
- $seedList = $this->getSeedList($recursive);
- $class = $this->getClass();
- $query = $class::find();
- $query->select([
- $this->mode . '_tag.id as id',
- "concat($systemType.code,' - ', tag.name) as tagName",
- "tag.id as tag",
- $this->mode . '_tag_role.id as role',
- $this->mode . '_tag_role.name as roleName'
- ]);
- $query->joinWith('relatedTag', true, 'INNER JOIN');
- $query->joinWith('relatedTag.' . $systemType, true, 'INNER JOIN');
- $query->joinWith('tagRole', true, 'INNER JOIN');
- //mode: subject or object
- if (empty($roleList)) {
- $roleList = array_keys($this->getRoleList());
- }
- $query->andWhere([
- 'in', $this->mode . '_tag_role.id', $roleList,
- ]);
- $query->andWhere([
- 'in', $this->mode, $seedList,
- ]);
- return $query;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement