/** * @param ProfileEvent $event */ public function create(ProfileEvent $event) { $profile = new ProfileModel(); $profile->setDispatcher($event->getDispatcher())->setCode($event->getCode())->setLocale($event->getLocale())->setTitle($event->getTitle())->setChapo($event->getChapo())->setDescription($event->getDescription())->setPostscriptum($event->getPostscriptum()); $profile->save(); $event->setProfile($profile); }
/** * @param ProfileModel $profile * @depends testUpdate */ public function testUpdateResourceAccess(ProfileModel $profile) { $event = new ProfileEvent(); $event->setId($profile->getId())->setResourceAccess(array('admin.address' => array(AccessManager::CREATE))); $action = new Profile($this->getMockEventDispatcher()); $action->updateResourceAccess($event); $updatedProfile = $event->getProfile(); $this->assertInstanceOf('Thelia\\Model\\Profile', $updatedProfile); $resources = $updatedProfile->getResources(); $this->assertEquals(1, count($resources)); $resource = $resources->getFirst(); $this->assertEquals('admin.address', $resource->getCode()); $profileResource = $updatedProfile->getProfileResources()->getFirst(); $accessManager = new AccessManager($profileResource->getAccess()); $this->assertTrue($accessManager->can(AccessManager::CREATE)); }
/** * Exclude object from result * * @param ChildProfile $profile Object to remove from the list of results * * @return ChildProfileQuery The current query, for fluid interface */ public function prune($profile = null) { if ($profile) { $this->addUsingAlias(ProfileTableMap::ID, $profile->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Declares an association between this object and a ChildProfile object. * * @param ChildProfile $v * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) * @throws PropelException */ public function setProfile(ChildProfile $v = null) { if ($v === null) { $this->setId(NULL); } else { $this->setId($v->getId()); } $this->aProfile = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildProfile object, it will not be re-added. if ($v !== null) { $v->addProfileI18n($this); } return $this; }
/** * @param Profile $object * @return int */ protected function getObjectId($object) { return $object->getId(); }
/** * Filter the query by a related \Thelia\Model\Profile object * * @param \Thelia\Model\Profile|ObjectCollection $profile The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProfileModuleQuery The current query, for fluid interface */ public function filterByProfile($profile, $comparison = null) { if ($profile instanceof \Thelia\Model\Profile) { return $this->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profile->getId(), $comparison); } elseif ($profile instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profile->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByProfile() only accepts arguments of type \\Thelia\\Model\\Profile or Collection'); } }