Find options

@param   string  $term
@return  array
199474
public function findOptions( $term = null )
    {
        $term = mb_strtolower( $term, 'UTF-8' );

        return $this->getMapper()
                    ->findOptions(
                        array(
                            'id'        => 'id',
                            'value'     => 'name',
                            'locale'    => 'locale',
                        ),
                        array(
                            new TypedParameters(
                                'POSITION( ? IN LOWER( ? ) ) > 0',
                                array(
                                    $term,
                                    'name',
                                ),
                                array(
                                    TypedParameters::TYPE_VALUE,
                                    TypedParameters::TYPE_IDENTIFIER,
                                )
                            ),
                        ),
                        array(
                            new Sql\Expression(
                                'POSITION( ? IN LOWER( ? ) ) ASC',
                                array(
                                    $term,
                                    'name',
                                ),
                                array(
                                    Sql\Expression::TYPE_VALUE,
                                    Sql\Expression::TYPE_IDENTIFIER,
                                )
                            ),
                            'name' => 'ASC',
                        )
                    );
    }
283897
public function getOptions(): array
    {
        $oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
        return [
            [
                'key'     => 'state',
                'label'   => 'State',
                'type'    => 'dropdown',
                'class'   => 'select2',
                'options' => [
                    ''                                    => 'All',
                    $oInvoiceModel::STATE_DRAFT           => 'Draft',
                    $oInvoiceModel::STATE_OPEN            => 'Open',
                    $oInvoiceModel::STATE_PAID_PARTIAL    => 'Partially Paid',
                    $oInvoiceModel::STATE_PAID_PROCESSING => 'Payments processing',
                    $oInvoiceModel::STATE_PAID            => 'Paid',
                    $oInvoiceModel::STATE_WRITTEN_OFF     => 'Written Off',
                ],
            ],
            [
                'key'   => 'date_start',
                'label' => 'Date Start',
                'info'  => 'This value is inclusive',
                'type'  => 'date',
            ],
            [
                'key'   => 'date_end',
                'label' => 'Date End',
                'info'  => 'This value is inclusive',
                'type'  => 'date',
            ],
        ];
    }
305749
protected function _extractFinder($options)
    {
        $type = !empty($options['finder']) ? $options['finder'] : 'all';
        unset($options['finder'], $options['maxLimit']);

        if (is_array($type)) {
            $options = (array)current($type) + $options;
            $type = key($type);
        }

        return [$type, $options];
    }
581661
protected function getOrCreateTag($term)
    {
        // Check if existing record can be found
        $source = $this->getSourceList();
        $titleField = $this->getTitleField();
        $record = $source
            ->filter($titleField, $term)
            ->first();
        if ($record) {
            return $record;
        }

        // Create new instance if not yet saved
        if ($this->getCanCreate()) {
            $dataClass = $source->dataClass();
            $record = Injector::inst()->create($dataClass);
            $record->{$titleField} = $term;
            $record->write();
            if ($source instanceof SS_List) {
                $source->add($record);
            }
            return $record;
        }

        return false;
    }
906084
protected function prepare_links( $term ) {
		$base = $this->namespace . '/' . $this->rest_base;
		$links = array(
			'self'       => array(
				'href' => rest_url( trailingslashit( $base ) . $term->term_id ),
			),
			'collection' => array(
				'href' => rest_url( $base ),
			),
			'about'      => array(
				'href' => rest_url( sprintf( 'wp/v2/taxonomies/%s', $this->taxonomy ) ),
			),
		);

		if ( $term->parent ) {
			$parent_term = get_term( (int) $term->parent, $term->taxonomy );
			if ( $parent_term ) {
				$links['up'] = array(
					'href'       => rest_url( trailingslashit( $base ) . $parent_term->term_id ),
					'embeddable' => true,
				);
			}
		}

		$taxonomy_obj = get_taxonomy( $term->taxonomy );
		if ( empty( $taxonomy_obj->object_type ) ) {
			return $links;
		}

		$post_type_links = array();
		foreach ( $taxonomy_obj->object_type as $type ) {
			$post_type_object = get_post_type_object( $type );
			if ( empty( $post_type_object->show_in_rest ) ) {
				continue;
			}
			$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
			$post_type_links[] = array(
				'href' => add_query_arg( $this->rest_base, $term->term_id, rest_url( sprintf( 'wp/v2/%s', $rest_base ) ) ),
			);
		}
		if ( ! empty( $post_type_links ) ) {
			$links['https://api.w.org/post_type'] = $post_type_links;
		}

		return $links;
	}
404936
public function actionList($type, $term)
    {
    	$tags = Tag::find()->where('type = :type AND LOWER(name) LIKE :term AND status<>"deleted"', [':type' => $type, ':term' => '%' . strtolower($term) . '%'])->all();
    	$response = [];
    	foreach($tags as $tag) {
    		$response[] = ["id" => $tag->id, "label" => $tag->name, "value" => $tag->name];
    	}
        Yii::$app->response->format = 'json';
        return $response;
    }
278462
public function addTerm(Term $term)
    {
        $term->addContentItem($this);
        $this->terms->add($term);

        return $this;
    }
258642
protected function fullTextWildcards($term)
    {
        // removing symbols used by MySQL
        $reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
        $term = str_replace($reservedSymbols, '', $term);

        $words = explode(' ', $term);

        foreach ($words as $key => $word) {
            /*
             * applying + operator (required word) only big words
             * because smaller ones are not indexed by mysql
             */
            if (strlen($word) >= 3) {
                // $words[$key] = '+' . $word . '*';
                $words[$key] = $word.'*';
            }
        }

        $searchTerm = implode(' ', $words);

        return $searchTerm;
    }
1018502
public static function getPairs($args = array())
    {
        $terms = static::getWhere($args);
        if (!Arr::iterable($terms)) {
            return array();
        }

        return array_combine(
            Collection::pluck($terms, 'term_id'),
            Collection::pluck($terms, 'name')
        );
    }
1060810
public function update(Term $term)
    {
        return wp_update_term($term->id, $this->getSlug(), (array) $term->getAdaptee());
    }
317412
public static function getOptions($optionName = null)
    {
        $options = array();
        foreach (ini_get_all('session') as $sysOptionName => $sysOptionValues) {
            $options[substr($sysOptionName, 8)] = $sysOptionValues['local_value'];
        }
        foreach (self::$_localOptions as $localOptionName => $localOptionMemberName) {
            $options[$localOptionName] = self::${$localOptionMemberName};
        }

        if ($optionName) {
            if (array_key_exists($optionName, $options)) {
                return $options[$optionName];
            }
            return null;
        }

        return $options;
    }
935650
public function imageSearch($term)
    {
        return $this->browser->get(
            $this->uri->expand(
                '/images/search{?term}',
                array(
                    'term' => $term
                )
            )
        )->then(array($this->parser, 'expectJson'));
    }
1345872
private function getOptionByRegExpr(string $pattern): array
    {
        $purgedArgs = $this->getRawArgs(true);
        return preg_grep("/" . $pattern . "/", $purgedArgs);
    }
876623
function get_suggestions($word)
    {
        $matches = $word ? $this->check($word) : $this->matches;

        if ($matches[0][4]) {
            return $matches[0][4];
        }

        return array();
    }
240569
public function getOptions() {

		$options = $this->options;

		unset($options['type']);
		$options['types'] = [$this->getEntityType()];

		$filters = $this->filters;
		if (!empty($filters)) {
			foreach ($filters as $filter) {
				$name = $filter['filter'];
				$target = $filter['target'];
				$options = $this->addFilterQuery($options, $name, $target);
			}
		}

		$sorts = $this->sorts;
		if (empty($sorts)) {
			$sorts[] = [
				'field' => 'time_created',
				'direction' => 'DESC',
			];
		}

		foreach ($sorts as $sort) {
			$field = $sort['field'];
			$direction = $sort['direction'];
			$options = $this->addSortQuery($options, $field, $direction);
		}

		if ($this->search_query) {
			$options = $this->addSearchQuery($options, $this->search_query, $this->search_options);
		}

		if ($this->search_query || !empty($this->filters)) {
			if (!isset($options['no_results'])) {
				$options['no_results'] = elgg_echo('sort:search:empty');
			}
		}

		return $options;
	}
1267733
private function findSelectOptions($field)
    {
        \PHPUnit_Framework_Assert::assertNotNull(
            $select = $this->getPage()->findField($field),
            sprintf('The select field "%s" does not exist.', $field)
        );

        $options = [];

        foreach ($select->find('xpath', '/option') as $option) {
            $options[] = $option->getValue();
        }

        return $options;
    }
133155
public function termLinks( string $taxonomy ): array {
		$res   = [];
		$terms = $this->terms( $taxonomy );
		if ( is_array( $terms ) ) {
			foreach ( $terms as $term ) {
				$res[] = Html::a( $term->name, get_term_link( $term->term_id ) );
			}
		}
		
		return $res;
	}