/**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Menu $value A Menu object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Menu $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #2
0
 /**
  * Declares an association between this object and a Menu object.
  *
  * @param      Menu $v
  * @return     MenuItem The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setMenu(Menu $v = null)
 {
     if ($v === null) {
         $this->setMenuId(NULL);
     } else {
         $this->setMenuId($v->getId());
     }
     $this->aMenu = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Menu object, it will not be re-added.
     if ($v !== null) {
         $v->addMenuItem($this);
     }
     return $this;
 }
Example #3
0
 $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();
 $menu = new Menu();
 $menu->setName('页脚底部菜单');
 $menu->setReserved(1);
 $menu->save();
 $menu_item = new MenuItem();
 $menu_item->setWeight($weight++);
 $menu_item->setMenuId($menu->getId());
 $menu_item->setName('root');
 $menu_item->setParentId(null);
 $menu_item->setUri('');
 $menu_item->save();
 $root_id = $menu_item->getId();
 $menu->setRootMenuItemId($root_id);
 $menu->save();
 $menu_item = new MenuItem();
 $menu_item->setWeight($weight++);
 $menu_item->setMenuId($menu->getId());
 $menu_item->setName('HOME');
 $menu_item->setParentId($root_id);
 $menu_item->setUri('');
 $menu_item->save();
 $menu_item = new MenuItem();
Example #4
0
 /**
  * @corvers InakaPhper\Lunchlog\Entity\Menu::setId
  * @corvers InakaPhper\Lunchlog\Entity\Menu::getId
  */
 public function testSetIdAndGetId()
 {
     $this->entity->setId(20);
     $this->assertEquals(20, $this->entity->getId());
 }
Example #5
0
        Message::register(new Message(Message::DANGER, i18n(array("en" => "name is required.", "zh" => "请填写name"))));
        $error_flag = true;
    }
    // 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 菜单'))));
Example #6
0
 /**
  * Exclude object from result
  *
  * @param   Menu $menu Object to remove from the list of results
  *
  * @return MenuQuery The current query, for fluid interface
  */
 public function prune($menu = null)
 {
     if ($menu) {
         $this->addUsingAlias(MenuPeer::ID, $menu->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Example #7
0
 /**
  * Filter the query by a related Menu object
  *
  * @param   Menu|PropelObjectCollection $menu The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return   PerfilMenuQuery The current query, for fluid interface
  * @throws   PropelException - if the provided filter is invalid.
  */
 public function filterByMenu($menu, $comparison = null)
 {
     if ($menu instanceof Menu) {
         return $this->addUsingAlias(PerfilMenuPeer::MENU_ID, $menu->getId(), $comparison);
     } elseif ($menu instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(PerfilMenuPeer::MENU_ID, $menu->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByMenu() only accepts arguments of type Menu or PropelCollection');
     }
 }