create menu item by ui component attributes

@param array $component
@return null
557478
protected function createItem(array $component)
    {
        $classname = array_get($component, 'data.classname');


        if (!$this->dispatchable($classname)) {
            return;
        }
        $id   = $component['id'];
        $attr = array_get($component, 'data', []);

        $this->handler->add($id, '^:ui-components-selector')
                ->title($attr['name'])
                ->link(handles("antares/ui-components::ui-components/view/{$id}", ['csrf' => true]))
                ->icon('fa fa-plus-circle')
                ->attributes(array_only($attr, ['x', 'y', 'width', 'height', 'disabled']) + ['rel' => $id, 'classname' => $classname]);
    }
471432
public function createFromMenuItem(MenuItem $menuItem)
    {
        if ($path = $menuItem->getPath()) {
            $uri = $this->request->getBaseUrl().$path;
        } elseif ($menuItem->getRedirectUrl()) {
            $uri = $menuItem->getRedirectUrl();
        } elseif ($menuItem->getInternalUrl()) {
            $uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
        } elseif ($contentRoute = $menuItem->getContentRoute()) {
            $route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
            $uri = $this->request->getBaseUrl().$route->getPath();
        } else {
            $uri = '#';
        }

        $options = [
            'uri' => $uri,
            'label' => $menuItem->getName(),
            'attributes' => [],
            'linkAttributes' => $menuItem->getLinkAttributes(),
            'childrenAttributes' => [],
            'labelAttributes' => [],
            'extras' => [],
            'display' => true,
            'displayChildren' => true,

        ];
        $item = $this->factory->createItem($menuItem->getId(), $options);

        if ($menuItem->isHidden()) {
            $item->setDisplay(false);
        }

        return $item;
    }
1040283
public function createStructure(array $options): ItemInterface
    {
        /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType */
        $contentType = $options['content_type'];

        /** @var \Knp\Menu\ItemInterface $menu */
        $menu = $this->factory->createItem('root');

        $editAttributes = [
            'class' => 'ez-btn--extra-actions ez-btn--edit',
            'data-actions' => 'edit',
        ];
        $canEdit = $this->permissionResolver->canUser(
            'class',
            'update',
            $contentType
        ) && $this->permissionResolver->hasAccess('class', 'create');

        $menu->addChild(
            $this->createMenuItem(
                self::ITEM__EDIT,
                [
                    'extras' => ['icon' => 'edit'],
                    'attributes' => $canEdit
                        ? $editAttributes
                        : array_merge($editAttributes, ['disabled' => 'disabled']),
                ]
            )
        );

        return $menu;
    }
676895
private function menuBuilder(array $menu)
    {
        foreach ($menu as $key => $item) {
            $menu[$key] = $this->menuHelper($item);
            if (isset($item['submenu'])) {
                $menu[$key]['submenu'] = $this->menuBuilder($item['submenu']);
            }
        }

        return $menu;
    }
1326148
public function addComponent(ComponentInterface $component)
    {
        $this->getComponents()->push($component);
        $component->attachTo($this);
        return $this;
    }
1308649
public static function build($component, array $options = [])
    {
        $ret = $component->type . ' ';
        if (! empty($component->name)) {
            $ret .= Context::escape($component->name) . ' ';
        }

        $columns = [];
        foreach ($component->columns as $column) {
            $tmp = Context::escape($column['name']);
            if (isset($column['length'])) {
                $tmp .= '(' . $column['length'] . ')';
            }
            $columns[] = $tmp;
        }

        $ret .= '(' . implode(',', $columns) . ') ' . $component->options;

        return trim($ret);
    }
460781
public function set_component($component) {
        $this->areacache = null;
        list($type, $name) = core_component::normalize_component($component);
        $this->component = $type.'_'.$name;
    }
1058405
public function menu( $parent ) {

		global $submenu;

		$custom_component_menus = array();

		$pods_component_menu_items = array();

		foreach ( $this->components as $component => $component_data ) {
			$component_id = $component_data['ID'];

			$component_data['MustUse'] = apply_filters( "pods_component_require_{$component_id}", $component_data['MustUse'], $component_data );

			if ( empty( $component_data['MustUse'] ) && ( ! isset( $this->settings['components'][ $component ] ) || 0 === $this->settings['components'][ $component ] ) ) {
				continue;
			}

			if ( ! empty( $component_data['Hide'] ) ) {
				continue;
			}

			if ( ! empty( $component_data['DeveloperMode'] ) && ! pods_developer() ) {
				continue;
			}

			if ( empty( $component_data['TablelessMode'] ) && pods_tableless() ) {
				continue;
			}

			if ( empty( $component_data['MenuPage'] ) ) {
				if ( ! isset( $component_data['object'] ) ) {
					continue;
				} elseif ( ! method_exists( $component_data['object'], 'admin' ) && ! method_exists( $component_data['object'], 'options' ) ) {
					continue;
				}
			}

			if ( false === $component_data['External'] ) {
				$component_data['File'] = realpath( $this->components_dir . $component_data['File'] );
			}

			if ( ! file_exists( $component_data['File'] ) ) {
				pods_message( 'Pods Component not found: ' . $component_data['File'] );

				pods_transient_clear( 'pods_components' );

				continue;
			}

			$capability = 'pods_component_' . str_replace( '-', '_', sanitize_title( $component ) );

			if ( 0 < strlen( $component_data['Capability'] ) ) {
				$capability = $component_data['Capability'];
			}

			if ( ! pods_is_admin( array( 'pods', 'pods_components', $capability ) ) ) {
				continue;
			}

			$menu_page = 'pods-component-' . $component;

			if ( ! empty( $component_data['MenuPage'] ) ) {
				$custom_component_menus[ $menu_page ] = $component_data;
			}

			$pods_component_menu_items[ $component_data['MenuName'] ] = array(
				'menu_page'  => $menu_page,
				'page_title' => $component_data['Name'],
				'capability' => 'read',
				'callback'   => array( $this, 'admin_handler' ),
			);

			if ( isset( $component_data['object'] ) && method_exists( $component_data['object'], 'admin_assets' ) ) {
				$pods_component_menu_items[ $component_data['MenuName'] ]['assets'] = array(
					$component_data['object'],
					'admin_assets',
				);
			}
		}//end foreach

		/**
		 * Add or change the items in the Pods Components Submenu.
		 *
		 * Can also be used to change which menu components is a submenu of or change title of menu.
		 *
		 * @param array $pods_component_menu_items {
		 *      An array of arguments for add_submenu_page
		 *
		 *     @type string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
		 *     @type string $page_title  The text to be displayed in the title tags of the page when the menu is selected
		 *     @type string $menu_title  The text to be used for the menu
		 *     @type string $capability  The capability required for this menu to be displayed to the user.
		 *     @type string $menu_slug   The slug name to refer to this menu by (should be unique for this menu)
		 *     @type string $function    The function to be called to output the content for this page.
		 * }
		 *
		 * @since  2.4.1
		 */
		$pods_component_menu_items = apply_filters( 'pods_admin_components_menu', $pods_component_menu_items );

		ksort( $pods_component_menu_items );

		foreach ( $pods_component_menu_items as $menu_title => $menu_data ) {
			if ( ! is_callable( $menu_data['callback'] ) ) {
				continue;
			}

			$page = add_submenu_page( $parent, strip_tags( $menu_data['page_title'] ), '- ' . strip_tags( $menu_title ), pods_v( 'capability', $menu_data, 'read', true ), $menu_data['menu_page'], $menu_data['callback'] );

			if ( isset( $menu_data['assets'] ) && is_callable( $menu_data['assets'] ) ) {
				add_action( 'admin_print_styles-' . $page, $menu_data['assets'] );
			}
		}

		if ( ! empty( $custom_component_menus ) ) {
			foreach ( $custom_component_menus as $menu_page => $component_data ) {
				if ( isset( $submenu[ $parent ] ) ) {
					foreach ( $submenu[ $parent ] as $sub => &$menu ) {
						if ( $menu[2] === $menu_page ) {
							$menu_page = $component_data['MenuPage'];

							$menu[2] = $menu_page;

							$page = current( explode( '?', $menu[2] ) );

							if ( isset( $component_data['object'] ) && method_exists( $component_data['object'], 'admin_assets' ) ) {
								add_action(
									'admin_print_styles-' . $page, array(
										$component_data['object'],
										'admin_assets',
									)
								);
							}

							break;
						}//end if
					}//end foreach
				}//end if
			}//end foreach
		}//end if
	}
62829
public function show(string $component, array $params = [])
    {
        $path = $this->buildComponentsPath($component);

        return $this->get($path, $params);
    }
16741
public static function build($component, array $options = [])
    {
        if (is_array($component)) {
            return "(\n" . implode(",\n", $component) . "\n)";
        }

        if ($component->isSubpartition) {
            return trim('SUBPARTITION ' . $component->name . ' ' . $component->options);
        }

        $subpartitions = empty($component->subpartitions) ? '' : ' ' . self::build($component->subpartitions);

        return trim(
            'PARTITION ' . $component->name
            . (empty($component->type) ? '' : ' VALUES ' . $component->type . ' ' . $component->expr . ' ')
            . ((! empty($component->options) && ! empty($component->type)) ? '' : ' ') . $component->options . $subpartitions
        );
    }
721136
public function add(HtmlComponent $component)
    {

        if (isset($this->components[$component->id]) || isset($this->components[$component->id . ":" . $this->number])) {
            //   $id = substr($component->id,0,strpos($component->id,':'));
            //   $pid = substr($this->id,0,strpos($this->id,':'));
            throw new ZE(sprintf(ERROR_DATAROW_COMPONENT_EXISTS, $component->id, $pid));
        }
        $this->components[$component->id] = $component;
        $component->setOwner($this);
        return $component;
    }
1300309
public function findComponentPlugin($component)
    {
        $className = Str::normalizeClassName(get_class($component));
        if (isset($this->pluginMap[$className])) {
            return $this->pluginMap[$className];
        }

        return null;
    }
260398
public function create(string $name, array $configuration): Menu
    {
        $resolver = new OptionsResolver();
        $menuConfiguration = new MenuConfiguration($name, $this->applicationConfiguration->getParameter('title'));
        $menuConfiguration->configureOptions($resolver);

        $menuConfiguration->setParameters($resolver->resolve($configuration));
        $menu = new Menu($name, $menuConfiguration);

        foreach ($menuConfiguration->getParameter('items') as $itemName => $item) {
            $menu->addItem($this->createMenuItem($itemName, $item, $menuConfiguration));
        }
        $this->menus[$name] = $menu;

        return $menu;
    }
879076
public function options( $component, $options ) {

		if ( ! isset( $this->settings['components'][ $component ] ) || ! is_array( $this->settings['components'][ $component ] ) ) {
			$this->settings['components'][ $component ] = array();
		}

		foreach ( $options as $option => $data ) {
			if ( ! isset( $this->settings['components'][ $component ][ $option ] ) && isset( $data['default'] ) ) {
				$this->settings['components'][ $component ][ $option ] = $data['default'];
			}
		}
	}
203376
public static function createFromComponents(array $components = []): self
    {
        $components += [
            'scheme' => null, 'user' => null, 'pass' => null, 'host' => null,
            'port' => null, 'path' => '', 'query' => null, 'fragment' => null,
        ];

        return new self(
            $components['scheme'],
            $components['user'],
            $components['pass'],
            $components['host'],
            $components['port'],
            $components['path'],
            $components['query'],
            $components['fragment']
        );
    }
655565
public function insert($component)
    {
        if (is_string($component)) {
            $component = $this->getRepository()->fetch(array('component' => $component));
        }

        if ($component->isAssignable()) {
            $assignment = $component->assignments->findOrAddNew(array('actor' => $this->_actor));
        }

        if ($this->isLoaded()) {
            parent::insert($component);
        }
    }
980374
protected function marshall(QtiComponent $component)
    {
        $element = self::getDOMCradle()->createElement('img');

        $this->setDOMElementAttribute($element, 'src', $component->getSrc());
        $this->setDOMElementAttribute($element, 'alt', $component->getAlt());

        if ($component->hasWidth() === true) {
            $this->setDOMElementAttribute($element, 'width', $component->getWidth());
        }

        if ($component->hasHeight() === true) {
            $this->setDOMElementAttribute($element, 'height', $component->getHeight());
        }

        if ($component->hasLongdesc() === true) {
            $this->setDOMElementAttribute($element, 'longdesc', $component->getLongdesc());
        }

        if ($component->hasXmlBase() === true) {
            self::setXmlBase($element, $component->getXmlBase());
        }

        $this->fillElement($element, $component);

        return $element;
    }