Get options for Select field in form.

@param \Closure|null $closure
@param string        $rootText

@return array
513633
public static function selectOptions(\Closure $closure = null, $rootText = 'Root')
    {
        $options = (new static())->withQuery($closure)->buildSelectOptions();

        return collect($options)->prepend($rootText, 0)->all();
    }
73812
public function dropdown($title, $url, \Closure $callback, $order = 0, array $attributes = array())
    {
        $properties = compact('title', 'url', 'order', 'attributes');

        if (func_num_args() == 4) {
            $arguments = func_get_args();

            $title = array_get($arguments, 0);
            $attributes = array_get($arguments, 3);

            $properties = compact('title', 'attributes');
        }

        $child = static::make($properties);

        call_user_func($callback, $child);

        $this->childs[] = $child;

        return $child;
    }
1211136
public function select($options = [])
    {
        $useClosure = false;

        if ($options instanceof \Closure) {
            $useClosure = true;
            $options = $options->call($this, $this->row);
        }

        $source = [];

        foreach ($options as $value => $text) {
            $source[] = compact('value', 'text');
        }

        if ($useClosure) {
            $this->addAttributes(['data-source' => json_encode($source)]);
        } else {
            $this->addOptions(compact('source'));
        }
    }
1197355
private function parseTextFile($filePath, \Closure $handler)
    {
        if (!file_exists($filePath) || !is_readable($filePath)) {
            throw new \InvalidArgumentException("File '{$filePath}' does not exist");
        }

        $data = file($filePath);

        $countryData = array();

        foreach ($data as $line) {
            // Remove \n
            $line = str_replace(array("\n", "\r"), '', $line);
            $line = trim($line);

            if (strlen($line) == 0 || substr($line, 0, 1) == '#') {
                continue;
            }
            if (strpos($line, '|')) {
                // Valid line
                $parts = explode('|', $line);


                $prefix = $parts[0];
                $location = $parts[1];

                $handler($prefix, $location);
            }
        }

        return $countryData;
    }
807565
final public function getArray($closure=NULL) {
      $type_fetch = $this->type_fetch;
      $this->type_fetch = 'assoc';
      $this->get();
      $this->type_fetch = $type_fetch;
      // $this->data = array_map(function($v){return(array)$v;},$this->data);
      if ($closure instanceof \Closure) {
         $this->data = $closure( $this->data, $this );
      }
      return $this->data ?: [];
   }
581849
public function findCallback(Closure $callback, $columns = ['*'])
    {
        /** @var EloquentBuilder $result */
        $result = $callback( $this->query() );

        $this->checkValidCustomCallback($result);

        return $result->first($columns);
    }
248693
public function call(Closure $callback = null, $caller = null)
    {
        if ($callback instanceof Closure) {
            // Make dependency injection possible
            $parameters = $this->resolveMethodDependencies(
                [$caller], new ReflectionFunction($callback)
            );
            call_user_func_array($callback, $parameters);
        }

        return $caller;
    }
1161403
final public function queryArray( string $sql, $closure=NULL ) {
      $type_fetch = $this->type_fetch;
      $this->type_fetch = 'assoc';
      $this->query( $sql );
      $this->type_fetch = $type_fetch;
      // $this->data = array_map(function($v){return(array)$v;},$this->data);
      if ($closure instanceof \Closure) {
         $this->data = $closure( $this->data, $this );
      }
      return $this->data ?: [];
   }
1202831
public static function prop(string $property, Closure $closure)
  {
    $trace = debug_backtrace()[1];

    if (
      $trace['class'] == 'Modulus\Framework\Upstart\Prototype' &&
      $trace['function'] == 'prop' &&
      count($trace['args']) == 3
    ) {
      if (!array_key_exists($property, Self::$properties)) {
        return Self::$properties[$property] = [$property => $closure];
      }

      throw new CannotAddPropertyException;
    }

    throw new CannotCallMethodException('Call to ' . self::class . '::prop() is not allowed');
  }
1238844
protected function getOptions()
	{
		$options = array();

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $option */
		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			$text = $this->translateOptions
				? $this->getText()->alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname))
				: trim((string) $option);

			// Create a new option object based on the <option /> element.
			$tmp = $select->option((string) $option['value'], $text, 'value', 'text', ((string) $option['disabled'] == 'true'));

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
25607
protected function filterJSInline(\Closure $callback)
    {
        if ($this->js) {
            $filteredJs = array();
            foreach ($this->js as $position => $jsGroup) {
                $filteredJs[$position] = array();
                foreach ($jsGroup as $key => $jsCode) {
                    if (call_user_func($callback, $jsCode, RSmartLoad::RESOURCE_TYPE_JS_INLINE)) {
                        $filteredJs[$position][$key] = $jsCode;
                    }
                }
            }
            $this->js = $filteredJs;
        }
    }
277779
public function find(\Closure $closure)
    {
        foreach ($this->getGenerator() as $key => $value) {
            if ($closure($value, $key)) {
                return $value;
            }
        }

        return false;
    }
516198
public function getRelation($subRelation = '', $closure = null)
    {
        if ($closure) {
            $closure($this->query);
        }

        $this->baseQuery();

        $list   = $this->query->relation($subRelation)->select();
        $parent = clone $this->parent;

        foreach ($list as &$model) {
            $model->setParent($parent);
        }

        return $list;
    }
459760
function first(callable $closure = null) {
        if($closure === null) {
            if(empty($this->data)) {
                return null;
            }
            
            $keys = \array_keys($this->data);
            return ($this->data[$keys[0]] ?? null);
        }
        
        foreach($this->data as $key => $val) {
            $feed = (bool) $closure($val, $key);
            if($feed) {
                return $val;
            }
        }
        
        return null;
    }
784420
public function extendInline($inlineName, Closure $closure)
    {
        $blockName  = ucfirst(strtolower($inlineName));
        $methodName = camel_case("inline_{$inlineName}");

        return $this->bindElementClosure($methodName, $closure);
    }
310523
protected function getExtender($abstract, Closure $closure)
		{
			// To "extend" a binding, we will grab the old "resolver" Closure and pass it
			// into a new one. The old resolver will be called first and the result is
			// handed off to the "new" resolver, along with this container instance.
			$resolver = $this->bindings[$abstract]['concrete'];

			return function($container) use ($resolver, $closure) {
				$args = array();
				$res = call_user_func_array($resolver, array($container));
				array_push($args, $res);
				array_push($args, $container);
				return call_user_func_array($closure, $args);
			};
		}
477765
public function filter(\Closure $callback)
    {
        $result = [];
        foreach ($this->value as $entity) {
            if ($callback($entity)) {
                $result[] = $entity;
            }
        }

        return $result;
    }