コード例 #1
0
 /**
  * this method returns a Propel ModelCriteria
  *
  * @return \Propel\Runtime\ActiveQuery\ModelCriteria
  */
 public function buildModelCriteria()
 {
     $search = MenuItemQuery::create();
     //		$this->configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'));
     $id = $this->getId();
     if ($id) {
         $search->filterById($id, Criteria::IN);
     }
     $menuid = $this->getMenuId();
     if ($menuid) {
         $search->filterByMenuId($menuid, Criteria::IN);
     }
     //	$critere->joinMenu('menu_i18n', Criteria::INNER_JOIN)->where('`menu_i18n' . $idcat . '`.category_id IN ('.$liste.')');
     return $search;
 }
コード例 #2
0
 public function itemMenu(MenuEvent $event)
 {
     $liste_item = json_decode($event->getListeItem());
     $compteur = 0;
     $item = MenuItemQuery::create()->filterByMenuId($event->getId())->find();
     $item->delete();
     foreach ($liste_item[0] as $idobj) {
         $info = explode('_', $idobj);
         $compteur++;
         $menuItem = new MenuItem();
         $menuItem->setMenuId($event->getId());
         $menuItem->setVisible(1);
         $menuItem->setTypobj($info[0]);
         $menuItem->setObjet($info[1]);
         $menuItem->setPosition($compteur);
         $menuItem->save();
         /*
         $menuItem_i18n = new MenuItemI18n();
         $menuItem_i18n->setId($menuItem->getId());
         $menuItem_i18n->setLocale('fr_FR');
         $menuItem_i18n->save();
         */
     }
 }
コード例 #3
0
 /**
  * Get the associated ChildMenuItem object
  *
  * @param      ConnectionInterface $con Optional Connection object.
  * @return                 ChildMenuItem The associated ChildMenuItem object.
  * @throws PropelException
  */
 public function getMenuItem(ConnectionInterface $con = null)
 {
     if ($this->aMenuItem === null && ($this->id !== null && $this->menu_id !== null)) {
         $this->aMenuItem = ChildMenuItemQuery::create()->findPk(array($this->id, $this->menu_id), $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aMenuItem->addMenuItemVersions($this);
            */
     }
     return $this->aMenuItem;
 }
コード例 #4
0
 /**
  * Performs an INSERT on the database, given a MenuItem or Criteria object.
  *
  * @param mixed               $criteria Criteria or MenuItem object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(MenuItemTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from MenuItem object
     }
     if ($criteria->containsKey(MenuItemTableMap::ID) && $criteria->keyContainsValue(MenuItemTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . MenuItemTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = MenuItemQuery::create()->mergeWith($criteria);
     try {
         // use transaction because $criteria could contain info
         // for more than one table (I guess, conceivably)
         $con->beginTransaction();
         $pk = $query->doInsert($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     return $pk;
 }
コード例 #5
0
 /**
  * Returns the number of related MenuItem objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      ConnectionInterface $con
  * @return int             Count of related MenuItem objects.
  * @throws PropelException
  */
 public function countMenuItems(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collMenuItemsPartial && !$this->isNew();
     if (null === $this->collMenuItems || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collMenuItems) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getMenuItems());
         }
         $query = ChildMenuItemQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByMenu($this)->count($con);
     }
     return count($this->collMenuItems);
 }
コード例 #6
0
 /**
  * Checks whether the current state must be recorded as a version
  *
  * @return  boolean
  */
 public function isVersioningNecessary($con = null)
 {
     if ($this->alreadyInSave) {
         return false;
     }
     if ($this->enforceVersion) {
         return true;
     }
     if (ChildMenuItemQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
         return true;
     }
     if (null !== ($object = $this->getMenu($con)) && $object->isVersioningNecessary($con)) {
         return true;
     }
     return false;
 }