/** * Get interface. * * @return Item The data interface */ public function getDataInterface() { if (!$this->started) { return $this->_interface; } if (is_null($this->_interface)) { $interfaces = ArrayHelper::map(Yii::$app->collectors['dataInterfaces']->getAll(), 'systemId', 'object.name'); $this->dataInterface = $this->select("Choose interface", $interfaces); } return $this->_interface; }
/** * {@inheritdocs}. */ public function generate() { $this->type = 'dropDownList'; $baseOptions = []; if (!$this->modelField->taxonomy->required) { $baseOptions[''] = ''; } $this->options = array_merge($baseOptions, ArrayHelper::map($this->modelField->taxonomy->taxonomies, 'id', 'name')); if ($this->modelField->taxonomy->multiple) { $this->htmlOptions['multiple'] = true; } return parent::generate(); }
/** * Get taxonomy list. * * @return unknown */ public function getTaxonomyList() { return ArrayHelper::map($this->getTaxonomies(), 'id', 'name'); }
/** * @inheritdoc */ public function getItems() { $instructions = $this->instructions; $items = []; if (!isset($instructions['typeFilters'])) { $instructions['typeFilters'] = []; } elseif (!is_array($instructions['typeFilters'])) { $instructions['typeFilters'] = [$instructions['typeFilters']]; } if (!isset($instructions['modules'])) { $instructions['modules'] = false; } if (isset($instructions['relationshipRole'])) { if (!isset($instructions['relationship'])) { throw new InvalidConfigException("Relationship type tasks require a relationship ID"); } $relationship = Relationship::getById($instructions['relationship']); if (empty($relationship)) { throw new InvalidConfigException("Relationship type tasks require a relationship"); } if ($instructions['relationshipRole'] === 'parent') { $relationships = $relationship->parent->collectorItem->parents; $baseType = $relationship->parent; } else { $relationships = $relationship->child->collectorItem->parents; $baseType = $relationship->child; } $types = ArrayHelper::map($relationships, 'parent.systemId', 'parent'); $types[$baseType->systemId] = $baseType; } else { $typesRaw = Yii::$app->collectors['types']->getAll(); $types = ArrayHelper::map($typesRaw, 'object.systemId', 'object'); } unset($types['']); foreach ($types as $typeKey => $type) { if (isset($instructions['limitTypes'])) { if (!in_array($typeKey, $instructions['limitTypes'])) { continue; } } if (in_array('hasDashboard', $instructions['typeFilters']) && !$type->hasDashboard) { continue; } if (in_array('authority', $instructions['typeFilters']) && $type->getBehavior('Authority') === null) { continue; } $item = ['type' => 'type', 'id' => $type->systemId, 'descriptor' => $type->title->upperPlural, 'hasChildren' => !empty($type->collectorItem->children) || $instructions['modules'] !== false && in_array($type->systemId, $instructions['modules'])]; if ($item['hasChildren'] && (!$this->filterQuery || preg_match('/' . preg_quote($this->filterQuery) . '/i', $item['descriptor']) === 1)) { $items[] = $item; } } if (!$this->filterQuery) { ArrayHelper::multisort($items, 'descriptor', SORT_ASC); } else { $filterQuery = $this->filterQuery; usort($items, function ($a, $b) use($filterQuery) { $a = levenshtein($a['descriptor'], $filterQuery); $b = levenshtein($b['descriptor'], $filterQuery); return $a < $b ? -1 : 1; }); } return $items; }