예제 #1
0
 public function verifyProfileId($value, ExecutionContextInterface $context)
 {
     $profile = ProfileQuery::create()->findPk($value);
     if (null === $profile) {
         $context->addViolation(Translator::getInstance()->trans("Profile ID not found"));
     }
 }
예제 #2
0
 public static function getProfileList()
 {
     $profileList = array(0 => AdminResources::SUPERADMINISTRATOR);
     foreach (ProfileQuery::create()->find() as $profile) {
         $profileList[$profile->getId()] = $profile->getCode();
     }
     return $profileList;
 }
예제 #3
0
 public function verifyCode($value, ExecutionContextInterface $context)
 {
     /* check unicity */
     $profile = ProfileQuery::create()->findOneByCode($value);
     if (null !== $profile) {
         $context->addViolation(Translator::getInstance()->trans("Profile `code` already exists"));
     }
 }
예제 #4
0
 public function buildModelCriteria()
 {
     $search = ProfileQuery::create();
     /* manage translations */
     $this->configureI18nProcessing($search);
     $id = $this->getId();
     if (null !== $id) {
         $search->filterById($id, Criteria::IN);
     }
     $search->orderById(Criteria::ASC);
     return $search;
 }
예제 #5
0
파일: Resource.php 프로젝트: margery/thelia
 /**
  * Gets the number of ChildProfile objects related by a many-to-many relationship
  * to the current object by way of the profile_resource cross-reference table.
  *
  * @param      Criteria $criteria Optional query object to filter the query
  * @param      boolean $distinct Set to true to force count distinct
  * @param      ConnectionInterface $con Optional connection object
  *
  * @return int the number of related ChildProfile objects
  */
 public function countProfiles($criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     if (null === $this->collProfiles || null !== $criteria) {
         if ($this->isNew() && null === $this->collProfiles) {
             return 0;
         } else {
             $query = ChildProfileQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByResource($this)->count($con);
         }
     } else {
         return count($this->collProfiles);
     }
 }
예제 #6
0
 public static function setUpBeforeClass()
 {
     ProfileQuery::create()->filterByCode('Test')->delete();
 }
예제 #7
0
 /**
  * Returns a new ChildProfileQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildProfileQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof \Thelia\Model\ProfileQuery) {
         return $criteria;
     }
     $query = new \Thelia\Model\ProfileQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
예제 #8
0
 /**
  * Performs an INSERT on the database, given a Profile or Criteria object.
  *
  * @param mixed               $criteria Criteria or Profile 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(ProfileTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Profile object
     }
     if ($criteria->containsKey(ProfileTableMap::ID) && $criteria->keyContainsValue(ProfileTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProfileTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = ProfileQuery::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;
 }
예제 #9
0
 /**
  * Get the associated ChildProfile object
  *
  * @param      ConnectionInterface $con Optional Connection object.
  * @return                 ChildProfile The associated ChildProfile object.
  * @throws PropelException
  */
 public function getProfile(ConnectionInterface $con = null)
 {
     if ($this->aProfile === null && $this->id !== null) {
         $this->aProfile = ChildProfileQuery::create()->findPk($this->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->aProfile->addProfileI18ns($this);
            */
     }
     return $this->aProfile;
 }
예제 #10
0
 /**
  *
  * in this function you add all the fields you need for your Form.
  * Form this you have to call add method on $this->formBuilder attribute :
  *
  * $this->formBuilder->add("name", "text")
  *   ->add("email", "email", array(
  *           "attr" => array(
  *               "class" => "field"
  *           ),
  *           "label" => "email",
  *           "constraints" => array(
  *               new \Symfony\Component\Validator\Constraints\NotBlank()
  *           )
  *       )
  *   )
  *   ->add('age', 'integer');
  *
  * @return null
  */
 protected function buildForm()
 {
     $this->formBuilder->add('label', 'text', ['constraints' => [new NotBlank()], 'label' => Translator::getInstance()->trans('label'), 'label_attr' => ['for' => 'api_label']])->add('profile', "choice", array("choices" => ProfileQuery::getProfileList(), "constraints" => array(new NotBlank()), "label" => Translator::getInstance()->trans('Profile'), "label_attr" => array("for" => "profile")));
 }
예제 #11
0
 protected function getExistingObject()
 {
     $profile = ProfileQuery::create()->findOneById($this->getRequest()->get('profile_id', 0));
     if (null !== $profile) {
         $profile->setLocale($this->getCurrentEditionLocale());
     }
     return $profile;
 }
예제 #12
0
 protected function buildForm()
 {
     $this->formBuilder->add("login", "text", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array(array($this, "verifyExistingLogin"))))), "label" => Translator::getInstance()->trans("Login"), "label_attr" => array("for" => "login")))->add("firstname", "text", array("constraints" => array(new Constraints\NotBlank()), "label" => Translator::getInstance()->trans("First Name"), "label_attr" => array("for" => "firstname")))->add("lastname", "text", array("constraints" => array(new Constraints\NotBlank()), "label" => Translator::getInstance()->trans("Last Name"), "label_attr" => array("for" => "lastname")))->add("password", "password", array("constraints" => array(), "label" => Translator::getInstance()->trans("Password"), "label_attr" => array("for" => "password")))->add("password_confirm", "password", array("constraints" => array(new Constraints\Callback(array("methods" => array(array($this, "verifyPasswordField"))))), "label" => Translator::getInstance()->trans('Password confirmation'), "label_attr" => array("for" => "password_confirmation")))->add('profile', "choice", array("choices" => ProfileQuery::getProfileList(), "constraints" => array(new Constraints\NotBlank()), "label" => Translator::getInstance()->trans('Profile'), "label_attr" => array("for" => "profile")))->add('locale', "choice", array("choices" => $this->getLocaleList(), "constraints" => array(new Constraints\NotBlank()), "label" => Translator::getInstance()->trans('Preferred locale'), "label_attr" => array("for" => "locale")));
 }
 protected function buildForm()
 {
     $this->formBuilder->add("login", "text", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array(array($this, "verifyExistingLogin"))))), "label" => $this->translator->trans("Login name"), "label_attr" => array("for" => "login", 'help' => $this->translator->trans("This is the name used on the login screen"))))->add("email", "email", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Email(), new Constraints\Callback(array("methods" => array(array($this, "verifyExistingEmail"))))), "label" => $this->translator->trans("Email address"), "label_attr" => array("for" => "email", 'help' => $this->translator->trans("Please enter a valid email address")), 'attr' => ['placeholder' => $this->translator->trans('Administrator email address')]))->add("firstname", "text", array("constraints" => array(new Constraints\NotBlank()), "label" => $this->translator->trans("First Name"), "label_attr" => array("for" => "firstname")))->add("lastname", "text", array("constraints" => array(new Constraints\NotBlank()), "label" => $this->translator->trans("Last Name"), "label_attr" => array("for" => "lastname")))->add("password", "password", array("constraints" => array(), "label" => $this->translator->trans("Password"), "label_attr" => array("for" => "password")))->add("password_confirm", "password", array("constraints" => array(new Constraints\Callback(array("methods" => array(array($this, "verifyPasswordField"))))), "label" => $this->translator->trans('Password confirmation'), "label_attr" => array("for" => "password_confirmation")))->add('profile', "choice", array("choices" => ProfileQuery::getProfileList(), "constraints" => array(new Constraints\NotBlank()), "label" => $this->translator->trans('Profile'), "label_attr" => array("for" => "profile")))->add('locale', "choice", array("choices" => $this->getLocaleList(), "constraints" => array(new Constraints\NotBlank()), "label" => $this->translator->trans('Preferred locale'), "label_attr" => array("for" => "locale")));
 }
예제 #14
0
파일: Profile.php 프로젝트: margery/thelia
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see Profile::setDeleted()
  * @see Profile::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildProfileQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
예제 #15
0
파일: Profile.php 프로젝트: margery/thelia
 /**
  * @param ProfileEvent $event
  */
 public function delete(ProfileEvent $event)
 {
     if (null !== ($profile = ProfileQuery::create()->findPk($event->getId()))) {
         $profile->delete();
         $event->setProfile($profile);
     }
 }