Static method for retrieving the options-array.

@param   string  $destroy_callback
@param   string  $create_callback
@param   boolean $sticky
@param   integer $life
@param   string  $classname
@param   integer $width

@return  array
975240
public static function formatAttributes($destroy_callback = null, $create_callback = null, $sticky = null, $life = null, $classname = null, $width = null)
    {
        $options = [];

        if ($destroy_callback !== null)
        {
            $options['destroyed'] = $destroy_callback;
        } // if

        if ($create_callback !== null)
        {
            $options['created'] = $create_callback;
        } // if

        if ($sticky !== null)
        {
            $options['sticky'] = !!$sticky;
        } // if

        if ($life !== null)
        {
            $options['life'] = $life;
        } // if

        if ($classname !== null)
        {
            $options['className'] = $classname;
        } // if

        if ($width !== null)
        {
            $options['width'] = $width;
        } // if

        return $options;
    }
148328
public function of($name, $callback = null)
    {

        $type = $this->definition['name'];

        if (is_null($type) || !property_exists($this, $type)) {
            throw new RuntimeException('Not supported.');
        } elseif (!isset($this->keyMap[$name])) {
            throw new InvalidArgumentException("Name [{$name}] is not available.");
        }

        $id = $this->keyMap[$name];

        if (is_callable($callback)) {
            call_user_func($callback, $this->{$type}[$id]);
        }


        return $this->{$type}[$id];
    }
1203613
function (action, options) {
            var ret = this.callBase();

            if (action === "create" && ret.hasOwnProperty(this.idField) && [this.idField] === null) {
                delete ret[this.idField];
            }

            return ret;
        }
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;
    }
968801
def destroy
      run_callbacks(:before_destroy)
      new_data = self.class.all.reject { |item| item.persisted_attributes == self.persisted_attributes }.map { |item| item.persisted_attributes }
      self.class.write_contents(new_data)
      self.is_destroyed = true
      run_callbacks(:after_destroy)
      true
    rescue IOError
      false
    end
1114468
public static function select(string $description, $options, $default = null, $allowExit = true): array
    {
        if (!$description = \trim($description)) {
            Show::error('Please provide a description text!', 1);
        }

        $sep     = ','; // ',' ' '
        $options = \is_array($options) ? $options : \explode(',', $options);

        // If default option is error
        if (null !== $default && !isset($options[$default])) {
            Show::error("The default option [{$default}] don't exists.", true);
        }

        if ($allowExit) {
            $options['q'] = 'quit';
        }

        $text = "<comment>$description</comment>";
        foreach ($options as $key => $value) {
            $text .= "\n  <info>$key</info>) $value";
        }

        Console::write($text);
        $defText = $default ? "[default:<comment>{$default}</comment>]" : '';
        $filter  = function ($val) use ($options) {
            return $val !== 'q' && isset($options[$val]);
        };

        beginChoice:
        $r = Console::readln("Your choice{$defText} : ");
        $r = $r !== '' ? \str_replace(' ', '', \trim($r, $sep)) : '';

        // empty
        if ($r === '') {
            goto beginChoice;
        }

        // exit
        if ($r === 'q') {
            Console::write("\n  Quit,ByeBye.", true, true);
        }

        $rs = \strpos($r, $sep) ? \array_filter(\explode($sep, $r), $filter) : [$r];

        // error, try again
        if (!$rs) {
            goto beginChoice;
        }

        return $rs;
    }
595489
public function partition(callable $callback, $keepKey = false)
    {
        $true = [];
        $false = [];

        if (is_string($callback)) {
            $callback = function ($value) use ($callback) {
                return $callback($value);
            };
        }

        foreach ($this->convertArray($this) as $key => $value) {
            if ($callback($value, $key)) {
                $true[$key] = $value;
            } else {
                $false[$key] = $value;
            }
        }

        if (!$keepKey) {
            $true = array_values($true);
            $false = array_values($false);
        }

        return [
            $this->bindNewInstance($true),
            $this->bindNewInstance($false),
        ];
    }
1344791
public static function radioList($name, $selection = null, $items = [], $options = [])
    {
        if (!isset($options['item'])) {
            $itemOptions = ArrayHelper::remove($options, 'itemOptions', []);
            $encode = ArrayHelper::getValue($options, 'encode', true);
            $options['item'] = function ($index, $label, $name, $checked, $value) use ($itemOptions, $encode) {
                $options = array_merge([
                    'label' => $encode ? static::encode($label) : $label,
                    'value' => $value
                ], $itemOptions);
                return '<div class="radio">' . static::radio($name, $checked, $options) . '</div>';
            };
        }

        return parent::radioList($name, $selection, $items, $options);
    }
1248341
public static function make($name, Closure $callback = null)
    {
        $menu = new self($name);
        if ( ! is_null($callback)) {
            call_user_func($callback, $menu);
        }

        return $menu;
    }
343035
public function createTable($name, callable $callback, $ifNotExists = true, $options = [])
    {
        $options = $this->prepareBCOptions($options);

        return $this->getTable($name)->create($callback, $ifNotExists, $options);
    }
1116407
function (items, options) {
            options = options || {};

            this.$items = [];
            this.$itemEventMap = {};

            this.callBase(options);

            if (items) {
                this.add(items);
            }

            var self = this;

            function updateLength() {
                self.length = self.size();
            }

            // TODO: allow array here to give multiple event hin
            this.bind('add', updateLength);
            this.bind('remove', updateLength);
            this.bind('reset', updateLength);

            this.length = this.size();
        }
210613
private function getOptionsResolver()
    {
        if (null === self::$optionsResolver) {
            $classExists = function ($class) {
                if (!class_exists($class)) {
                    throw new InvalidOptionsException(sprintf('Class %s does not exists.', $class));
                }
                return true;
            };
            $classExistsAndImplements = function($class, $interface) use ($classExists) {
                $classExists($class);
                if (!in_array($interface, class_implements($class))) {
                    throw new InvalidOptionsException(sprintf('Class %s must implement %s.', $class, $interface));
                }
                return true;
            };
            $validOperator = function ($class) use ($classExistsAndImplements) {
                return $classExistsAndImplements($class, self::OPERATOR_INTERFACE);
            };
            $validController = function ($class) use ($classExistsAndImplements) {
                return $classExistsAndImplements($class, self::CONTROLLER_INTERFACE);
            };
            $validForm = function ($class) use ($classExistsAndImplements) {
                return $classExistsAndImplements($class, self::FORM_INTERFACE);
            };
            $validTable = function ($class) use ($classExistsAndImplements) {
                return $classExistsAndImplements($class, self::TABLE_INTERFACE);
            };
            $validEvent = function ($class) use ($classExistsAndImplements) {
                if (null === $class) {
                    return true;
                }
                return $classExistsAndImplements($class, self::EVENT_INTERFACE);
            };

            self::$optionsResolver = new OptionsResolver();
            /** @noinspection PhpUnusedParameterInspection */
            self::$optionsResolver
                ->setDefaults([
                    'entity'      => null,
                    'repository'  => null,
                    'operator'    => self::DEFAULT_OPERATOR,
                    'controller'  => self::DEFAULT_CONTROLLER,
                    'templates'   => null,
                    'form'        => null,
                    'table'       => null,
                    'event'       => null,
                    'parent'      => null,
                    'translation' => null,
                ])

                ->setAllowedTypes('entity',      'string')
                ->setAllowedTypes('repository',  ['null', 'string'])
                ->setAllowedTypes('operator',    'string')
                ->setAllowedTypes('controller',  'string')
                ->setAllowedTypes('templates',   ['null', 'string', 'array'])
                ->setAllowedTypes('form',        'string')
                ->setAllowedTypes('table',       'string')
                ->setAllowedTypes('event',       ['null', 'string'])
                ->setAllowedTypes('parent',      ['null', 'string'])
                ->setAllowedTypes('translation', ['null', 'array'])

                ->setAllowedValues('entity',     $classExists)
                ->setAllowedValues('operator',   $validOperator)
                ->setAllowedValues('controller', $validController)
                ->setAllowedValues('form',       $validForm)
                ->setAllowedValues('table',      $validTable)
                ->setAllowedValues('event',      $validEvent)

                ->setNormalizer('repository', function($options, $value) use ($classExistsAndImplements) {
                    $translatable = is_array($options['translation']);
                    $interface = $translatable ? self::TRANSLATABLE_REPOSITORY_INTERFACE : self::REPOSITORY_INTERFACE;
                    if (null === $value) {
                        if ($translatable) {
                            $value = self::TRANSLATABLE_DEFAULT_REPOSITORY;
                        } else {
                            $value = self::DEFAULT_REPOSITORY;
                        }
                    }
                    $classExistsAndImplements($value, $interface);
                    return $value;
                })
                ->setNormalizer('translation', function ($options, $value) use ($classExistsAndImplements) {
                    if (is_array($value)) {
                        if (!array_key_exists('entity', $value)) {
                            throw new InvalidOptionsException('translation.entity must be defined.');
                        }
                        if (!array_key_exists('fields', $value)) {
                            throw new InvalidOptionsException('translation.fields must be defined.');
                        }
                        if (!is_array($value['fields']) || empty($value['fields'])) {
                            throw new InvalidOptionsException('translation.fields can\'t be empty.');
                        }
                        if (!array_key_exists('repository', $value)) {
                            $value['repository'] = self::DEFAULT_REPOSITORY;
                        }
                        $classExistsAndImplements($value['repository'], self::REPOSITORY_INTERFACE);
                    }
                    return $value;
                })
                // TODO templates normalization ?
            ;
        }
        return self::$optionsResolver;
    }
1369474
def delete
      options = self.class.merge_options()
      response = self.class.delete(self.href, options)
      begin 
        self.class.check_status_code(response)
      rescue
        return false
      end
      return true
    end
1150225
function (options, callback) {
  var deleteOps = []
  options.indexes.createKeyStream({gte: '0', lte: '￮'})
    .on('data', function (data) {
      deleteOps.push({type: 'del', key: data})
    })
    .on('error', function (err) {
      options.log.error(err, ' failed to empty index')
      return callback(err)
    })
    .on('end', function () {
      options.indexes.batch(deleteOps, callback)
    })
}
728128
protected function handleClassCallback(string $callback): array
    {
        list($class, $method) = $this->parseCallback($callback);
        $instance = $this->container->make($class);

        return [$instance, $method];
    }
854056
public function consume($queueName, array $options = [], callable $callback)
    {
        $consumerTag = array_key_exists('consumerTag', $options) ? $options['consumerTag'] : null;
        $noLocal = array_key_exists('noLocal', $options) ? (bool)$options['noLocal'] : null;
        $noAck = array_key_exists('noAck', $options) ? (bool)$options['noAck'] : null;
        $exclusive = array_key_exists('exclusive', $options) ? (bool)$options['exclusive'] : null;
        $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null;
        $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null;

        $outputFrame = Basic\BasicConsumeFrame::create(
            $queueName,
            $consumerTag,
            $noLocal,
            $noAck,
            $exclusive,
            $noWait,
            $arguments
        );
        $outputFrame->frameChannelId = $this->id;
        $this->connection->command($outputFrame);

        if (is_callable($callback)) {
            $this->on(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, function (Basic\BasicConsumeOkFrame $incomingFrame) use ($callback) {
                $this->consumers[$incomingFrame->consumerTag] = $callback;
            });
        }
    }
800358
public function createSearchForm(
        SearchData $data = null,
        ?string $name = null,
        array $options = []
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(SearchData::class);

        return $this->formFactory->createNamed($name, SearchType::class, $data, $options);
    }