/**
  * 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 you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by find*()
  * and findPk*() calls.
  *
  * @param \Menu\Model\MenuVersion $obj A \Menu\Model\MenuVersion object.
  * @param string $key             (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if (null === $key) {
             $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #2
0
 /**
  * Sets the properties of the current object to the value they had at a specific version
  *
  * @param ChildMenuVersion $version The version object to use
  * @param ConnectionInterface   $con the connection to use
  * @param array                 $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
  *
  * @return ChildMenu The current object (for fluent API support)
  */
 public function populateFromVersion($version, $con = null, &$loadedObjects = array())
 {
     $loadedObjects['ChildMenu'][$version->getId()][$version->getVersion()] = $this;
     $this->setId($version->getId());
     $this->setVisible($version->getVisible());
     $this->setPosition($version->getPosition());
     $this->setCreatedAt($version->getCreatedAt());
     $this->setUpdatedAt($version->getUpdatedAt());
     $this->setVersion($version->getVersion());
     $this->setVersionCreatedAt($version->getVersionCreatedAt());
     $this->setVersionCreatedBy($version->getVersionCreatedBy());
     if ($fkValues = $version->getMenuItemIds()) {
         $this->clearMenuItems();
         $fkVersions = $version->getMenuItemVersions();
         $query = ChildMenuItemVersionQuery::create();
         foreach ($fkValues as $key => $value) {
             $c1 = $query->getNewCriterion(MenuItemVersionTableMap::ID, $value);
             $c2 = $query->getNewCriterion(MenuItemVersionTableMap::VERSION, $fkVersions[$key]);
             $c1->addAnd($c2);
             $query->addOr($c1);
         }
         foreach ($query->find($con) as $relatedVersion) {
             if (isset($loadedObjects['ChildMenuItem']) && isset($loadedObjects['ChildMenuItem'][$relatedVersion->getId()]) && isset($loadedObjects['ChildMenuItem'][$relatedVersion->getId()][$relatedVersion->getVersion()])) {
                 $related = $loadedObjects['ChildMenuItem'][$relatedVersion->getId()][$relatedVersion->getVersion()];
             } else {
                 $related = new ChildMenuItem();
                 $related->populateFromVersion($relatedVersion, $con, $loadedObjects);
                 $related->setNew(false);
             }
             $this->addMenuItem($related);
             $this->collMenuItemsPartial = false;
         }
     }
     return $this;
 }
 /**
  * Exclude object from result
  *
  * @param   ChildMenuVersion $menuVersion Object to remove from the list of results
  *
  * @return ChildMenuVersionQuery The current query, for fluid interface
  */
 public function prune($menuVersion = null)
 {
     if ($menuVersion) {
         $this->addCond('pruneCond0', $this->getAliasedColName(MenuVersionTableMap::ID), $menuVersion->getId(), Criteria::NOT_EQUAL);
         $this->addCond('pruneCond1', $this->getAliasedColName(MenuVersionTableMap::VERSION), $menuVersion->getVersion(), Criteria::NOT_EQUAL);
         $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
     }
     return $this;
 }
 /**
  * Filter the query by a related \Menu\Model\MenuVersion object
  *
  * @param \Menu\Model\MenuVersion|ObjectCollection $menuVersion  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildMenuQuery The current query, for fluid interface
  */
 public function filterByMenuVersion($menuVersion, $comparison = null)
 {
     if ($menuVersion instanceof \Menu\Model\MenuVersion) {
         return $this->addUsingAlias(MenuTableMap::ID, $menuVersion->getId(), $comparison);
     } elseif ($menuVersion instanceof ObjectCollection) {
         return $this->useMenuVersionQuery()->filterByPrimaryKeys($menuVersion->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByMenuVersion() only accepts arguments of type \\Menu\\Model\\MenuVersion or Collection');
     }
 }