@param array $options

@return \Knp\Menu\ItemInterface

@throws \eZ\Publish\API\Repository\Exceptions\BadStateException
@throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
@throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
355634
public function createStructure(array $options): ItemInterface
    {
        /** @var \eZ\Publish\API\Repository\Values\Content\Location $parentLocation */
        $parentLocation = $options['parentLocation'];
        /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType */
        $contentType = $options['content_type'];
        $parentContentType = $parentLocation->getContent()->getContentType();
        /** @var \eZ\Publish\API\Repository\Values\Content\Language $language */
        $language = $options['language'];
        /** @var \Knp\Menu\ItemInterface|\Knp\Menu\ItemInterface[] $menu */
        $menu = $this->factory->createItem('root');

        $contentCreateStruct = $this->createContentCreateStruct($parentLocation, $contentType, $language);
        $locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocation->id);

        $canPublish = $this->permissionResolver->canUser('content', 'publish', $contentCreateStruct, [$locationCreateStruct]);
        $canCreate = $this->permissionResolver->canUser('content', 'create', $contentCreateStruct, [$locationCreateStruct]) && $parentContentType->isContainer;
        $canPreview = $this->permissionResolver->canUser('content', 'versionread', $contentCreateStruct, [$locationCreateStruct]);

        $publishAttributes = [
            'class' => self::BTN_TRIGGER_CLASS,
            'data-click' => '#ezrepoforms_content_edit_publish',
        ];
        $createAttributes = [
            'class' => self::BTN_TRIGGER_CLASS,
            'data-click' => '#ezrepoforms_content_edit_saveDraft',
        ];
        $previewAttributes = [
            'class' => self::BTN_TRIGGER_CLASS,
            'data-click' => '#ezrepoforms_content_edit_preview',
        ];

        $menu->setChildren([
            self::ITEM__PUBLISH => $this->createMenuItem(
                self::ITEM__PUBLISH,
                [
                    'attributes' => $canCreate && $canPublish
                        ? $publishAttributes
                        : array_merge($publishAttributes, self::BTN_DISABLED_ATTR),
                    'extras' => [
                        'icon' => 'publish',
                        'orderNumber' => 10,
                    ],
                ]
            ),
            self::ITEM__SAVE_DRAFT => $this->createMenuItem(
                self::ITEM__SAVE_DRAFT,
                [
                    'attributes' => $canCreate
                        ? $createAttributes
                        : array_merge($createAttributes, self::BTN_DISABLED_ATTR),
                    'extras' => [
                        'icon' => 'save',
                        'orderNumber' => 50,
                    ],
                ]
            ),
            self::ITEM__PREVIEW => $this->createMenuItem(
                self::ITEM__PREVIEW,
                [
                    'attributes' => $canPreview
                        ? $previewAttributes
                        : array_merge($previewAttributes, self::BTN_DISABLED_ATTR),
                    'extras' => [
                        'icon' => 'view-desktop',
                        'orderNumber' => 60,
                    ],
                ]
            ),
            self::ITEM__CANCEL => $this->createMenuItem(
                self::ITEM__CANCEL,
                [
                    'attributes' => [
                        'class' => self::BTN_TRIGGER_CLASS,
                        'data-click' => '#ezrepoforms_content_edit_cancel',
                    ],
                    'extras' => [
                        'icon' => 'circle-close',
                        'orderNumber' => 70,
                    ],
                ]
            ),
        ]);

        return $menu;
    }
342895
public function factory(array $options = [])
    {
        if (!array_key_exists(static::ENTITY_MANAGER_NAME, $options)) {
            $errMsg = sprintf('Option %s not found', static::ENTITY_MANAGER_NAME);
            throw new Exception\InvalidArgumentException($errMsg);
        }
        $emName = $options[static::ENTITY_MANAGER_NAME];

        return $this->getServiceLocator()->get($emName);
    }
755986
public function getItemConfigObject(array $options)
    {
        if ($this->type === 'settings') {
            return new SettingsConfig($this->validator, $this->customValidator, $options);
        } else {
            return new ModelConfig($this->validator, $this->customValidator, $options);
        }
    }
390859
public static function create(array $options)
    {
        if (isset($options['url'])) {
            $urlParts = parse_url($options['url']);

            foreach ($urlParts as $part => $value) {
                switch ($part) {
                    case 'host':
                    case 'user':
                    case 'port':
                        $options[$part] = $value;
                        break;

                    case 'path':
                        $path = explode('/', $value);
                        $options['dbname'] = array_pop($path);
                        $options['path'] = trim(implode('/', $path), '/');
                        break;

                    case 'pass':
                        $options['password'] = $value;
                        break;

                    case 'scheme':
                        $options['ssl'] = ($value === 'https');
                        break;

                    default:
                        break;
                }
            }
        }

        if (!isset($options['dbname'])) {
            throw new \InvalidArgumentException("'dbname' is a required option to create a CouchDBClient");
        }

        $defaults = [
            'type'     => 'socket',
            'host'     => 'localhost',
            'port'     => 5984,
            'user'     => null,
            'password' => null,
            'ip'       => null,
            'ssl'      => false,
            'path'     => null,
            'logging'  => false,
            'timeout'  => 10,
            'headers'  => [],
        ];
        $options = array_merge($defaults, $options);

        if (!isset(self::$clients[$options['type']])) {
            throw new \InvalidArgumentException(sprintf('There is no client implementation registered for %s, valid options are: %s',
                $options['type'], implode(', ', array_keys(self::$clients))
            ));
        }
        $connectionClass = self::$clients[$options['type']];
        $connection = new $connectionClass(
            $options['host'],
            $options['port'],
            $options['user'],
            $options['password'],
            $options['ip'],
            $options['ssl'],
            $options['path'],
            $options['timeout'],
            $options['headers']
        );
        if ($options['logging'] === true) {
            $connection = new HTTP\LoggingClient($connection);
        }

        return new static($connection, $options['dbname']);
    }
261773
public function createOptions(Array $options) {

		$this->options = [];

		foreach($options as $k => $v) {
			$this->appendOption(new SelectOptionElement($k, $v, $this));
		}

		$this->setValue();

		return $this;

	}
1003813
public static function initElement($type, array $options = [])
    {
        if (strpos($type, '\\') !== false) {
            $class = $type;
        } elseif ($description = self::getDescription($type)) {
            $class = $description['type'];
            unset($description['type']);
            $options = array_merge($description, $options);
        } elseif (!empty($type)) {
            $class = $type;
        }
        if (self::checkClass($class)) {
            $item = self::configObject(new $class(), $options);
        } else {
            throw new InvalidArgumentException('Wrong class: ' . $class);
        }

        return $item;
    }
76627
public function setOptions($options)
    {
        if ($this->options !== $options) {
            if (!$options instanceof AdapterOptions) {
                $options = new AdapterOptions($options);
            }

            if ($this->options) {
                $this->options->setAdapter(null);
            }
            $options->setAdapter($this);
            $this->options = $options;
        }

        return $this;
    }
60064
public function createItemMenu(array $options)
    {
        if (empty($options['item']) || !($options['item'] instanceof Item)) {
            throw new \InvalidArgumentException('Item is not found');
        }

        /* @var $item Item */
        $item = $options['item'];

        /* @var $menu ItemInterface */
        $menu = $this->factory
            ->createItem('root')
            ->setUri($this->request_stack->getMasterRequest()->getRequestUri());
        $params = [
            'id' => $item->getId(),
            'name' => $item->getUrlName(),
        ];

        $menu
            ->addChild('Change record', ['route' => 'item_change', 'routeParameters' => $params])
            ->setLinkAttribute('class', 'icon-label icon-edit');

        // add settings plugin items
        /* @var $plugin ItemPluginInterface */
        foreach ($this->plugin_item->getPlugins() as $plugin) {
            $plugin->buildMenu($menu, $options['item']);
        }

        $menu->addChild('Delete record', ['route' => 'item_delete', 'routeParameters' => $params])
            ->setLinkAttribute('class', 'icon-label icon-delete')
            ->setLinkAttribute('data-message', $this->translator->trans(
                'Are you sure want to delete %name%?',
                ['%name%' => $item->getName()]
            ));

        return $menu;
    }
740120
protected function configureOptions(array $options = [])
    {
        try {
            $resolver = new OptionsResolver();
            // We set all global options as defined options, otherwise we would get a lot of exceptions
            $resolver->setDefined(array_keys($options));
            $this->resolveOptions($resolver);
            return $resolver->resolve($options);
        } catch (MissingOptionsException $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        } catch (InvalidOptionsException $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        } catch (NoConfigurationException $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        } catch (NoSuchOptionException $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        } catch (OptionDefinitionException $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        } catch (UndefinedOptionsException $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        } catch (ExceptionInterface $e) {
            throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
        }
    }
940849
public function createOptions(Array $options) {

		$this->options = [];

		foreach($options as $value => $label) {
			$this->appendOption(new RadioOptionElement($value, new LabelElement($label)));
		}
		
		return $this;

	}
326315
public function options($options = [])
    {
        if ($options instanceof Arrayable) {
            $options = $options->toArray();
        }

        $this->options = array_merge($this->options, $options);

        return $this;
    }
1352958
public function setAdapterOptions($options)
    {
        if (!is_array($options) && !$options instanceof AbstractOptions) {
            throw new Exception\InvalidArgumentException(sprintf(
                '"%s" expects an array or a valid instance of "%s"; received "%s"',
                __METHOD__,
                'Zend\Stdlib\AbstractOptions',
                is_object($options) ? get_class($options) : gettype($options)
            ));
        }
        $this->adapterOptions = $options;
        $this->options = $options;

        return $this;
    }
392839
protected function parseOptions(array $options)
    {
        $options = array_merge($this->defaultOptions, $options);

        foreach ($options as $option => $value) {
            if (! in_array($option, $this->allowedOptions, true)) {
                throw new \InvalidArgumentException("Option [$option] is not allowed.");
            }
        }

        return $options;
    }
363374
protected function createNavbarContainerClass(array $options)
    {
        // Create navbar container class
        $containerClass = 'navbar';
        if ($options['inverse']) {
            $containerClass .= ' navbar-inverse';
        }
        if ($options['fixed']) {
            $containerClass .= ' navbar-fixed-';
            switch ($options['fixed']) {
                case 'top':
                case 'bottom':
                    $containerClass .= $options['fixed'];
                    break;
                default:
                    throw new Exception\InvalidArgumentException(
                        'Only top and bottom are acceptable navbarFixed options'
                    );
            }
        }
        return $containerClass;
    }
593151
public function createStructure(array $options): ItemInterface
    {
        /** @var bool $location */
        $canDelete = $this->permissionResolver->hasAccess('content', 'cleantrash');
        /** @var int $trashItemsCount */
        $trashItemsCount = $this->trashService->findTrashItems(new Query())->count;
        /** @var ItemInterface|ItemInterface[] $menu */
        $menu = $this->factory->createItem('root');

        $menu->addChild(
            $this->createMenuItem(self::ITEM__EMPTY, [
                'extras' => ['icon' => 'trash-empty'],
                'attributes' => $canDelete > 0 && $trashItemsCount > 0
                    ? ['data-toggle' => 'modal', 'data-target' => '#confirmEmptyTrash']
                    : ['class' => 'disabled'],
            ])
        );

        return $menu;
    }
481138
public function createUserMenu(array $options)
    {
        $menu = $this->factory->createItem('root');
        $menu->setLabel($this->token_storage->getToken()->getUser()->__toString());

        $event = new UserMenuCollectionEvent($menu);
        $this->dispatcher->dispatch(UserMenuCollectionEvent::NAME, $event);

        return $menu;
    }
597079
protected function createElement(array $options)
    {
        $type = isset($options['type']) ? $options['type'] : null;
        unset($options['type']);

        return FactoryFields::initElement($type, $options);
    }