本文整理汇总了PHP中Knp\Menu\ItemInterface::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface::getUri方法的具体用法?PHP ItemInterface::getUri怎么用?PHP ItemInterface::getUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\ItemInterface
的用法示例。
在下文中一共展示了ItemInterface::getUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: matchItem
public function matchItem(ItemInterface $item)
{
$route = substr($this->container->get('request')->getRequestUri(), 0, strlen($item->getUri()));
$method = substr(strrchr($this->container->get('request')->getRequestUri(), '/'), 1);
if ($route == $item->getUri() && ($method == 'modifier' || $method == 'importer' || $method == 'ajouter')) {
return true;
}
return null;
}
示例2: matchItem
public function matchItem(ItemInterface $item)
{
if (null === $this->uri || null === $item->getUri()) {
return null;
}
if ($item->getUri() === $this->uri) {
return true;
}
return null;
}
示例3: matchItem
public function matchItem(ItemInterface $item)
{
if (null === $this->regexp || null === $item->getUri()) {
return null;
}
if (preg_match($this->regexp, $item->getUri())) {
return true;
}
return null;
}
示例4: matchItem
public function matchItem(ItemInterface $item)
{
if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
return true;
} else {
if ($item->getUri() !== '/' && substr($this->container->get('request')->getRequestUri(), 0, strlen($item->getUri())) === $item->getUri()) {
return true;
}
}
return null;
}
示例5: matchItem
public function matchItem(ItemInterface $item)
{
if (null === $this->uri || null === $item->getUri()) {
return null;
}
$urlLength = strlen($item->getUri());
$currentUrlTrimmed = substr($this->uri, 0, $urlLength);
if ($item->getUri() === $currentUrlTrimmed) {
return true;
}
return null;
}
示例6: matchItem
public function matchItem(ItemInterface $item)
{
if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
// URL's completely match
return true;
} else {
if ($item->getUri() !== $this->container->get('request')->getBaseUrl() . '/' && substr($this->container->get('request')->getRequestUri(), 0, strlen($item->getUri())) === $item->getUri()) {
// URL isn't just "/" and the first part of the URL match
return true;
}
}
return null;
}
示例7: matchItem
public function matchItem(ItemInterface $item)
{
$request = $this->requestStack->getCurrentRequest();
if ($item->getUri() === $request->getRequestUri()) {
// URL's completely match
return true;
} else {
if ($item->getUri() !== $request->getBaseUrl() . '/' && substr($request->getRequestUri(), 0, strlen($item->getUri())) === $item->getUri()) {
// URL isn't just "/" and the first part of the URL match
return true;
}
}
return null;
}
示例8: matchItem
/**
* {@inheritDoc}
*/
public function matchItem(ItemInterface $item)
{
if ($item->getUri() === $this->getRequestUri()) {
return true;
}
return null;
}
示例9: render
public function render(ItemInterface $item, array $options = array())
{
$options = array_merge($this->defaultOptions, $options);
$translator = $options['translator'];
$itemIterator = new \Knp\Menu\Iterator\RecursiveItemIterator($item);
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
$items = [];
foreach ($iterator as $item) {
$translatedLabel = $translator->trans($item->getLabel());
$id = $item->getName();
$itemData = ['id' => strtolower($item->getName()), 'name' => $translatedLabel, 'uri' => $item->getUri()];
$itemData['has_children'] = $item->hasChildren();
$parentId = $item->getParent()->getName();
if ($parentId !== $id) {
$itemData['parent'] = strtolower($parentId);
if (!isset($items[$parentId]['children'])) {
$items[$parentId]['children'] = [];
}
$items[$parentId]['children'][] = $itemData;
}
if (isset($items[$id])) {
$items[$id] = array_merge($itemData, $items[$id]);
} else {
$items[$id] = $itemData;
}
}
return $items;
}
示例10: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param \Knp\Menu\ItemInterface $item The item
*
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
return true;
}
return false;
}
示例11: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param \Knp\Menu\ItemInterface $item The item
*
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
$uri = str_replace(array('/', '.'), array('\\/', '\\.'), $item->getUri());
if (preg_match('/' . $uri . '/', $this->container->get('request')->getRequestUri())) {
return true;
}
return false;
}
示例12: matchItem
/**
* {@inheritDoc}
*/
public function matchItem(ItemInterface $item)
{
if ($prefix = $item->getExtra('prefix_match', $this->defaultActive)) {
if (strpos($this->getRequestUri(), $item->getUri()) === 0) {
return true;
}
}
return null;
}
示例13: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param ItemInterface $item
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
/* @var $request \Symfony\Component\HttpFoundation\Request */
$request = $this->container->get('request');
if ($item->getUri() === $request->getRequestUri()) {
return true;
}
if ($item->getExtra('routes') !== null && in_array($request->attributes->get('_route'), $item->getExtra('routes'))) {
return true;
}
return null;
}
示例14: matchItem
/**
* @param ItemInterface $item
*
* @return bool
*/
public function matchItem(ItemInterface $item)
{
$requestUri = $this->request->getRequestUri();
$baseUrl = $this->request->getBaseUrl() . '/';
$uri = $item->getUri();
if ($uri === $requestUri) {
return true;
} else {
if ($uri !== $baseUrl && substr($requestUri, 0, strlen($uri)) === $uri) {
return true;
}
}
return null;
}
示例15: processMenuItem
private function processMenuItem(ItemInterface $menu)
{
$uri = $menu->getUri();
if (!empty($uri) || $uri !== '#') {
if (false === $this->hasAccess($uri)) {
$menu->getParent()->removeChild($menu);
return;
}
}
if ($menu->hasChildren()) {
foreach ($menu->getChildren() as $item) {
$this->processMenuItem($item);
}
}
if ((empty($uri) || $uri === '#') && $menu->getName() !== 'root' && !$menu->hasChildren()) {
$menu->getParent()->removeChild($menu);
}
}