Reduces a menu item, and returns it as an array that can be used in a request to the WeChat API.

@param MenuItem $item

@return array
429226
protected function reduceItem (MenuItem $item)
    {
        $reduced = ['name' => $item->getTitle()];

        // Has children.
        if (count($item->getChildren()) > 0) {
            $reduced['sub_button'] = [];
            foreach ($item->getChildren() as $childItem) {
                $reduced['sub_button'][] = $this->reduceItem($childItem);
            }
        } // No children.
        else {
            $reduced['type'] = $item->getType();
            $reduced[$item->getType() === MenuItem::URL ? 'url' : 'key'] = $item->getKey();
        }

        return $reduced;
    }
1131566
public function remove( $item ) {

			for ( $i=0; $i<$this->len; $i++ ) {

				if ( $this->compare( $item, $this->items[$i] ) === 0 ) {
					
					$this->undecorate( $this->items[ $i ] );
				
					array_splice( $this->items, $i, 1 );
				
					$this->len--;

					break;
				}

			}

			return $this;

		}
122372
private function getFormattedItem(Item $item)
    {
        $data = [
            'type'       => $this->getFormattedName($item->getTransformer()),
            'id'         => $item->getData()->id,
            'attributes' => $item->sanitize(),
        ];

        if ($links = $item->getLinks()) {
            $data['links'] = $links;
        }

        return $data;
    }
898948
public static function delete($item)
	{
		if (isset(static::$itemcache[$item]))
		{
			unset(static::$itemcache[$item]);
		}
		return \Arr::delete(static::$items, $item);
	}
739229
protected function recursiveClone($item)
    {
        if (is_object($item)) {
            return clone $item;
        } elseif (is_array($item)) {
            return array_map([$this, 'recursiveClone'], $item);
        }
        return $item;
    }
1132882
public function transform($item)
    {
        if (null === $item) {
            return '';
        }

        $getter = 'get'.ucfirst($this->primaryKey);
        if ($this->multiple && (is_array($item) || $item instanceof \Traversable)) {
            $result = [];

            foreach ($item as $it) {
                if (method_exists($it, $getter)) {
                    $result[] = $it->$getter();
                } elseif (method_exists($it, 'getId')) {
                    $result[] = $it->getId();
                }
            }

            return implode($this->glue, $result);
        }

        if (method_exists($item, $getter)) {
            return $item->$getter();
        }
        if (method_exists($item, 'getId')) {
            return $item->getId();
        }

        return '';
    }
124716
public function fromItem(Item $item)
    {
        return Comment::createFromArray(array_filter([
            'id' => $item->getId(),
            'source' => $item->get('source'),
            'parent' => $item->get('parent'),
            'author_uuid' => $item->get('author_uuid'),
            'author_name' => $item->get('author_name'),
            'author_email' => $item->get('author_email'),
            'author_avatar' => $item->get('author_avatar'),
            'author_role' => $item->get('author_role'),
            'thumb' => $item->get('thumb'),
            'rating' => $item->get('rating'),
            'content' => $item->get('content'),
            'state' => $item->get('state'),
            'created_at' =>  $item->get('created_at'),
        ]));
    }
450900
public function getItems()
    {
        if (null === $this->items) {
            /** @var \Darvin\AdminBundle\Menu\Item[] $items */
            $items = $skipped = [];

            foreach ($this->itemFactories as $itemFactory) {
                foreach ($itemFactory->getItems() as $item) {
                    if (isset($items[$item->getName()])) {
                        throw new MenuException(sprintf('Menu item "%s" already exists.', $item->getName()));
                    }
                    if (null === $item->getIndexUrl() && null === $item->getNewUrl()) {
                        $skipped[$item->getName()] = true;

                        continue;
                    }

                    $associatedObject = $item->getAssociatedObject();

                    if (!empty($associatedObject)
                        && (!$this->authorizationChecker->isGranted(Permission::VIEW, $associatedObject) && !$this->authorizationChecker->isGranted(Permission::CREATE_DELETE, $associatedObject))
                    ) {
                        $skipped[$item->getName()] = true;

                        continue;
                    }

                    $items[$item->getName()] = $item;
                }
            }

            $this->sortItems($items);

            foreach ($items as $item) {
                if (!$item->hasParent()) {
                    continue;
                }

                $parentName = $item->getParentName();

                if (isset($skipped[$parentName])) {
                    continue;
                }
                if (!isset($items[$parentName])) {
                    $items[$parentName] = $this->createItemGroup($parentName, $item->getPosition());
                }

                $parent = $items[$parentName];
                $parent->addChild($item);
            }
            foreach ($items as $key => $item) {
                if ($item->hasParent() && !isset($skipped[$item->getParentName()])) {
                    unset($items[$key]);
                }
            }

            $this->sortItems($items);

            $this->items = $items;
        }

        return $this->items;
    }
1177268
protected function getItemLine($item)
    {
        $result = array();

        // @todo: add property source(s) for this item line.
        $this->addPropertySource('item', $item);

        $this->addProductInfo($result);
        $sign = $this->invoiceSource->getSign();

        // @todo: add other tags and available meta tags (* = required):
        // * quantity
        // * unitprice and/or unitpriceinc
        // * vat related tags:
        //     * vatrate and/or vatamount
        //     * vat range tags (call method getVatRangeTags()
        //     * vat rate source
        // - meta-unitprice-recalculate: if admin enters product prices inc vat
        //   (which is normal) then the product price ex vat may be imprecise.
        //   If the exact vat rate is not yet known, it may be recalculated in
        //   the Completor phase.
        // - line totals
        // Should result in something like this:

        // Check for cost price.
        $productPriceEx = $sign * $item->priceEx;
        $precisionEx = 0.01;
        $productVat = $sign * $item->productTax;
        $precisionVat = 0.01;
        $productPriceInc = $sign * $item->priceInc;
        $quantity = $item->quantity;

        // Check for cost price and margin scheme.
        if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
            // Margin scheme:
            // - Do not put VAT on invoice: send price incl VAT as unitprice.
            // - But still send the VAT rate to Acumulus.
            $result[Tag::UnitPrice] = $productPriceInc;
        } else {
            $result += array(
                Tag::UnitPrice => $productPriceEx,
                Meta::UnitPriceInc => $productPriceInc,
                Meta::RecalculatePrice => $productPricesIncludeTax ? Tag::UnitPrice : Meta::UnitPriceInc,
            );
        }
        $result[Tag::Quantity] = $quantity;

        // Add tax info.
        $result += $this->getVatRangeTags($productVat, $productPriceEx, $precisionVat, $precisionEx);

        // @todo: remove property source(s) for this item line.
        $this->removePropertySource('item');

        return $result;
    }
1023072
protected function renderItem($item) {
        $linkTemplate = empty($item['items']) ? $this->linkTemplate : $this->itemSubmenuLinkTemplate;
        $labelTemplate = empty($item['items']) ? $this->labelTemplate : $this->itemSubmenuLabelTemplate;

        if (isset($item['url'])) {
            $template = ArrayHelper::getValue($item, 'template', $linkTemplate);

            $params = [
                '{url}' => Html::encode(Url::to($item['url'])),
                '{label}' => $item['label'],
                '{icon}' => isset($item['icon']) ? "<i class='{$item['icon']}'></i>" : '',
            ];

            return strtr($template, $params);
        } else {
            $template = ArrayHelper::getValue($item, 'template', $labelTemplate);

            return strtr($template, [
                '{label}' => $item['label'],
                '{icon}' => isset($item['icon']) ? "<i class='{$item['icon']}'></i>" : '',
            ]);
        }
    }
996252
protected function activateItems(&$item)
	{
		$hasActiveChild = false;
		if (isset($item['items'])) {
			foreach ($item['items'] as &$childItem) {
				if ($this->activateItems($childItem)) $hasActiveChild = true;
			}
		}

		$isActive = isset($item['active']) ? $item['active'] : $this->isItemActive($item);
		if (!$isActive && $hasActiveChild) $isActive = true;
		$item['active'] = $isActive;

		return $isActive;
	}
1216149
protected function getItemOrderOptions($item)
    {
        $result = array();
        if ($options = $item->getProductOptions()) {
            if (isset($options['options'])) {
                $result = array_merge($result, $options['options']);
            }
            if (isset($options['additional_options'])) {
                $result = array_merge($result, $options['additional_options']);
            }
            if (!empty($options['attributes_info'])) {
                $result = array_merge($options['attributes_info'], $result);
            }
        }
        return $result;
    }
225116
public static function menuLink($item)
    {
        $app = \JFactory::getApplication();
        $menu = $app->getMenu();
        $item = $menu->getItem($item);

        return \JRoute::_($item->link . '&Itemid=' . $item->id);
    }
521788
public function renderItem($item)
    {
        if (isset($item['header'])) {
            Html::addCssClass($item['options'], 'header');
            return Html::tag('div', $item['header'], $item['options']);
        } else {
            if (isset($item['url'])) {
                return Html::a($item['label'], Url::to($item['url']), $item['options']);
            } else {
                return Html::tag('div', $item['label'], $item['options']);
            }
        }
    }
850722
public function getMultiLevelDropdownWrapper(MenuItem $item): string
    {
        return '<li class="treeview'.($item->hasActiveOnChild() ? ' active' : '').'">
                    <a href="#">
                        '.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').'
                        <span>'.$item->title.'</span>
                        <span class="pull-right-container">
                            <i class="fa fa-angle-left pull-right"></i>
                        </span>
                    </a>
                    <ul class="treeview-menu">
                        '.$this->getChildMenuItems($item).'
                    </ul>
                </li>';
    }
794223
public function getItemUrl($item)
    {
        $item = $this->getItem($item);
        return $item ? $item->normalizedUrl : null;
    }
808839
public function normalizeValue($item)
    {
        if (is_array($item)) {
            $normalized = [];

            foreach ($item as $key => $value) {
                $key = $this->recursive ? $this->normalizeKey($key) : $key;

                if (is_array($value)) {
                    $normalized[$key] = $this->normalizeValue($value);
                } elseif ($value instanceof \stdClass) {
                    $normalized[$key] = $this->normalizeValue(
                        Arr::convertFromStdClass($value)
                    );
                } else {
                    $normalized[$key] = $value;
                }
            }
        } elseif ($item instanceof \stdClass) {
            $normalized = $this->normalizeValue(
                Arr::convertFromStdClass($item)
            );
        } else {
            $normalized = $item;
        }

        return $normalized;
    }