Example #1
0
 /**
  * @param ProfileEvent $event
  */
 public function updateResourceAccess(ProfileEvent $event)
 {
     if (null !== ($profile = ProfileQuery::create()->findPk($event->getId()))) {
         ProfileResourceQuery::create()->filterByProfileId($event->getId())->delete();
         foreach ($event->getResourceAccess() as $resourceCode => $accesses) {
             $manager = new AccessManager(0);
             $manager->build($accesses);
             $profileResource = new ProfileResource();
             $profileResource->setProfileId($event->getId())->setResource(ResourceQuery::create()->findOneByCode($resourceCode))->setAccess($manager->getAccessValue());
             $profileResource->save();
         }
         $event->setProfile($profile);
     }
 }
Example #2
0
 /**
  * @param    Profile $profile The profile object to add.
  */
 protected function doAddProfile($profile)
 {
     $profileResource = new ChildProfileResource();
     $profileResource->setProfile($profile);
     $this->addProfileResource($profileResource);
     // set the back reference to this object directly as using provided method either results
     // in endless loop or in multiple relations
     if (!$profile->getResources()->contains($this)) {
         $foreignCollection = $profile->getResources();
         $foreignCollection[] = $this;
     }
 }
Example #3
0
 /**
  * Filter the query by a related \Thelia\Model\ProfileResource object
  *
  * @param \Thelia\Model\ProfileResource|ObjectCollection $profileResource  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 filterByProfileResource($profileResource, $comparison = null)
 {
     if ($profileResource instanceof \Thelia\Model\ProfileResource) {
         return $this->addUsingAlias(ProfileTableMap::ID, $profileResource->getProfileId(), $comparison);
     } elseif ($profileResource instanceof ObjectCollection) {
         return $this->useProfileResourceQuery()->filterByPrimaryKeys($profileResource->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByProfileResource() only accepts arguments of type \\Thelia\\Model\\ProfileResource or Collection');
     }
 }
Example #4
0
 /**
  * Exclude object from result
  *
  * @param   ChildProfileResource $profileResource Object to remove from the list of results
  *
  * @return ChildProfileResourceQuery The current query, for fluid interface
  */
 public function prune($profileResource = null)
 {
     if ($profileResource) {
         $this->addCond('pruneCond0', $this->getAliasedColName(ProfileResourceTableMap::PROFILE_ID), $profileResource->getProfileId(), Criteria::NOT_EQUAL);
         $this->addCond('pruneCond1', $this->getAliasedColName(ProfileResourceTableMap::RESOURCE_ID), $profileResource->getResourceId(), Criteria::NOT_EQUAL);
         $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
     }
     return $this;
 }
 /**
  * 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\ProfileResource $obj A \Thelia\Model\ProfileResource 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->getResourceId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }