/** * Validates the object and all objects related to this table. * * @see getValidationFailures() * @param ValidatorInterface|null $validator A Validator class instance * @return boolean Whether all objects pass validation. */ public function validate(ValidatorInterface $validator = null) { if (null === $validator) { $validator = new RecursiveValidator(new ExecutionContextFactory(new IdentityTranslator()), new LazyLoadingMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory()); } $failureMap = new ConstraintViolationList(); if (!$this->alreadyInValidation) { $this->alreadyInValidation = true; $retval = null; // We call the validate method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. // If validate() method exists, the validate-behavior is configured for related object if (method_exists($this->aUser, 'validate')) { if (!$this->aUser->validate($validator)) { $failureMap->addAll($this->aUser->getValidationFailures()); } } // If validate() method exists, the validate-behavior is configured for related object if (method_exists($this->aPack, 'validate')) { if (!$this->aPack->validate($validator)) { $failureMap->addAll($this->aPack->getValidationFailures()); } } $retval = $validator->validate($this); if (count($retval) > 0) { $failureMap->addAll($retval); } $this->alreadyInValidation = false; } $this->validationFailures = $failureMap; return (bool) (!(count($this->validationFailures) > 0)); }
/** * Filter the query by a related \Models\Pack object * * @param \Models\Pack|ObjectCollection $pack The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildFileQuery The current query, for fluid interface */ public function filterByPack($pack, $comparison = null) { if ($pack instanceof \Models\Pack) { return $this->addUsingAlias(FileTableMap::COL_PACK_ID, $pack->getId(), $comparison); } elseif ($pack instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(FileTableMap::COL_PACK_ID, $pack->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByPack() only accepts arguments of type \\Models\\Pack or Collection'); } }
/** * Filter the query by a related \Models\Pack object * * @param \Models\Pack|ObjectCollection $pack the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildUserQuery The current query, for fluid interface */ public function filterByPack($pack, $comparison = null) { if ($pack instanceof \Models\Pack) { return $this->addUsingAlias(UserTableMap::COL_ID, $pack->getOwnerId(), $comparison); } elseif ($pack instanceof ObjectCollection) { return $this->usePackQuery()->filterByPrimaryKeys($pack->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByPack() only accepts arguments of type \\Models\\Pack or Collection'); } }
protected function validateOne() { setContentType("json"); $pack = new Pack(); $given = array_keys($_POST); $response["error"] = null; if (count($given) == 1) { if ($given[0] == "name") { $p = PackQuery::create()->filterByOwner($this->data["loggedUser"])->filterByName($_POST["name"])->findOne(); if ($p) { $response["error"] = array("name" => "name", "message" => "You can not have two packs with the same name."); $this->viewString(json_encode($response)); return; } $pack->setName($_POST["name"]); } else { if ($given[0] == "description") { $pack->setDescription($_POST["description"]); } else { setHTTPStatusCode("400"); return; } } if (!$pack->validate()) { foreach ($pack->getValidationFailures() as $failure) { if ($given[0] == $failure->getPropertyPath()) { $response["error"] = array("name" => $failure->getPropertyPath(), "message" => $failure->getMessage()); } } } $this->viewString(json_encode($response)); } else { setHTTPStatusCode("400"); } }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aUser) { $this->aUser->removePackPermission($this); } if (null !== $this->aGroup) { $this->aGroup->removePackPermission($this); } if (null !== $this->aPack) { $this->aPack->removePackPermission($this); } $this->id = null; $this->value = null; $this->user_id = null; $this->group_id = null; $this->pack_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * @param ChildPack $pack The ChildPack object to add. */ protected function doAddPack(ChildPack $pack) { $this->collPacks[] = $pack; $pack->setOwner($this); }
/** * Exclude object from result * * @param ChildPack $pack Object to remove from the list of results * * @return $this|ChildPackQuery The current query, for fluid interface */ public function prune($pack = null) { if ($pack) { $this->addUsingAlias(PackTableMap::COL_ID, $pack->getId(), Criteria::NOT_EQUAL); } return $this; }