Example #1
0
 /**
  * @param ProfileEvent $event
  */
 public function updateModuleAccess(ProfileEvent $event)
 {
     if (null !== ($profile = ProfileQuery::create()->findPk($event->getId()))) {
         ProfileModuleQuery::create()->filterByProfileId($event->getId())->delete();
         foreach ($event->getModuleAccess() as $moduleCode => $accesses) {
             $manager = new AccessManager(0);
             $manager->build($accesses);
             $profileModule = new ProfileModule();
             $profileModule->setProfileId($event->getId())->setModule(ModuleQuery::create()->findOneByCode($moduleCode))->setAccess($manager->getAccessValue());
             $profileModule->save();
         }
         $event->setProfile($profile);
     }
 }
Example #2
0
 /**
  * Filter the query by a related \Thelia\Model\ProfileModule object
  *
  * @param \Thelia\Model\ProfileModule|ObjectCollection $profileModule  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildProfileQuery The current query, for fluid interface
  */
 public function filterByProfileModule($profileModule, $comparison = null)
 {
     if ($profileModule instanceof \Thelia\Model\ProfileModule) {
         return $this->addUsingAlias(ProfileTableMap::ID, $profileModule->getProfileId(), $comparison);
     } elseif ($profileModule instanceof ObjectCollection) {
         return $this->useProfileModuleQuery()->filterByPrimaryKeys($profileModule->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByProfileModule() only accepts arguments of type \\Thelia\\Model\\ProfileModule or Collection');
     }
 }
Example #3
0
 /**
  * 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 \Thelia\Model\ProfileModule $obj A \Thelia\Model\ProfileModule 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->getProfileId(), (string) $obj->getModuleId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #4
0
 /**
  * Exclude object from result
  *
  * @param   ChildProfileModule $profileModule Object to remove from the list of results
  *
  * @return ChildProfileModuleQuery The current query, for fluid interface
  */
 public function prune($profileModule = null)
 {
     if ($profileModule) {
         $this->addCond('pruneCond0', $this->getAliasedColName(ProfileModuleTableMap::PROFILE_ID), $profileModule->getProfileId(), Criteria::NOT_EQUAL);
         $this->addCond('pruneCond1', $this->getAliasedColName(ProfileModuleTableMap::MODULE_ID), $profileModule->getModuleId(), Criteria::NOT_EQUAL);
         $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
     }
     return $this;
 }