当前位置: 首页>>代码示例>>PHP>>正文


PHP MenuItem::setUri方法代码示例

本文整理汇总了PHP中MenuItem::setUri方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::setUri方法的具体用法?PHP MenuItem::setUri怎么用?PHP MenuItem::setUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MenuItem的用法示例。


在下文中一共展示了MenuItem::setUri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createItem

    public function createItem($name, array $options = array())
    {
        $item = new MenuItem($name, $this);

        $options = array_merge(
            array(
                'uri' => null,
                'label' => null,
                'attributes' => array(),
                'linkAttributes' => array(),
                'childrenAttributes' => array(),
                'labelAttributes' => array(),
                'display' => true,
                'displayChildren' => true,
            ),
            $options
        );

        $item
            ->setUri($options['uri'])
            ->setLabel($options['label'])
            ->setAttributes($options['attributes'])
            ->setLinkAttributes($options['linkAttributes'])
            ->setChildrenAttributes($options['childrenAttributes'])
            ->setLabelAttributes($options['labelAttributes'])
            ->setDisplay($options['display'])
            ->setDisplayChildren($options['displayChildren'])
        ;

        return $item;
    }
开发者ID:naderman,项目名称:KnpMenu,代码行数:31,代码来源:MenuFactory.php

示例2: isset

    // validation for country_id
    $country_id = isset($_POST['country_id']) ? strip_tags($_POST['country_id']) : null;
    /// proceed submission
    // proceed for $name
    $object->setName($name);
    // proceed for $country_id
    $object->setCountryId($country_id);
    if ($error_flag == false) {
        if ($object->save()) {
            // create root menu_it
            $menu_item = new MenuItem();
            $menu_item->setWeight(0);
            $menu_item->setMenuId($object->getId());
            $menu_item->setName('root');
            $menu_item->setParentId(null);
            $menu_item->setUri('');
            $menu_item->save();
            $object->setRootMenuItemId($menu_item->getId());
            $object->save();
            Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
            HTML::forwardBackToReferer();
        } else {
            Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败"))));
        }
    }
}
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Menu', 'zh' => 'Create 菜单'))));
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$html->renderOut('menu/backend/menu_create', array('object' => $object));
开发者ID:jeffreycai,项目名称:ct21,代码行数:31,代码来源:menu_create.php

示例3: MenuItem

    $menu_item->setUri('');
    $menu_item->save();
    $menu_item = new MenuItem();
    $menu_item->setWeight($weight++);
    $menu_item->setMenuId($menu->getId());
    $menu_item->setName('NEWS');
    $menu_item->setParentId($root_id);
    $menu_item->setUri('news');
    $menu_item->save();
    $menu_item = new MenuItem();
    $menu_item->setWeight($weight++);
    $menu_item->setMenuId($menu->getId());
    $menu_item->setName('OUR SERVICES');
    $menu_item->setParentId($root_id);
    $menu_item->setUri('services');
    $menu_item->save();
    $menu_item = new MenuItem();
    $menu_item->setWeight($weight++);
    $menu_item->setMenuId($menu->getId());
    $menu_item->setName('ABOUT US');
    $menu_item->setParentId($root_id);
    $menu_item->setUri('about');
    $menu_item->save();
    $menu_item = new MenuItem();
    $menu_item->setWeight($weight++);
    $menu_item->setMenuId($menu->getId());
    $menu_item->setName('CONTACT');
    $menu_item->setParentId($root_id);
    $menu_item->setUri('contact');
    $menu_item->save();
}
开发者ID:jeffreycai,项目名称:ct21,代码行数:31,代码来源:fixture.php

示例4: isset

 $menu_id = isset($_POST["menu_id"]) ? strip_tags($_POST["menu_id"]) : null;
 if (empty($menu_id)) {
     Message::register(new Message(Message::DANGER, i18n(array("en" => "menu_id is required.", "zh" => "请填写menu_id"))));
     $error_flag = true;
 }
 // validation for $parent_id
 $parent_id = isset($_POST["parent_id"]) ? strip_tags($_POST["parent_id"]) : null;
 if (empty($parent_id)) {
     Message::register(new Message(Message::DANGER, i18n(array("en" => "parent_id is required.", "zh" => "请填写parent_id"))));
     $error_flag = true;
 }
 /// proceed submission
 // proceed for $name
 $object->setName($name);
 // proceed for $uri
 $object->setUri($uri);
 // proceed for $menu_id
 if (!empty($menu_id)) {
     $object->setMenuId($menu_id);
 }
 // proceed for $parent_id
 if (!empty($parent_id)) {
     $object->setParentId($parent_id);
 }
 if ($error_flag == false) {
     if ($object->save()) {
         Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
         HTML::forwardBackToReferer();
     } else {
         Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败"))));
     }
开发者ID:jeffreycai,项目名称:ct21,代码行数:31,代码来源:menu_item_create.php


注:本文中的MenuItem::setUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。