/** * Filter the query by a related \Thelia\Model\Api object * * @param \Thelia\Model\Api|ObjectCollection $api 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 filterByApi($api, $comparison = null) { if ($api instanceof \Thelia\Model\Api) { return $this->addUsingAlias(ProfileTableMap::ID, $api->getProfileId(), $comparison); } elseif ($api instanceof ObjectCollection) { return $this->useApiQuery()->filterByPrimaryKeys($api->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByApi() only accepts arguments of type \\Thelia\\Model\\Api or Collection'); } }
private function doUpdate(Api $api) { $error_msg = null; $form = $this->createForm(AdminForm::API_UPDATE); try { $updateForm = $this->validateForm($form); $event = new ApiUpdateEvent($api, $updateForm->get('profile')->getData() ?: null); $this->dispatch(TheliaEvents::API_UPDATE, $event); $response = RedirectResponse::create(URL::getInstance()->absoluteUrl($this->getRoute('admin.configuration.api'))); } catch (FormValidationException $e) { $error_msg = $this->createStandardFormValidationErrorMessage($e); } catch (\Exception $e) { $error_msg = $e->getMessage(); } if (null !== $error_msg) { $this->setupFormErrorContext("foo", $error_msg, $form, $e); $response = $this->renderList($api->getId()); } return $response; }
public function createApi(ApiCreateEvent $event) { $api = new ApiModel(); $api->setLabel($event->getLabel())->setProfileId($event->getProfile())->save(); }
/** * Exclude object from result * * @param ChildApi $api Object to remove from the list of results * * @return ChildApiQuery The current query, for fluid interface */ public function prune($api = null) { if ($api) { $this->addUsingAlias(ApiTableMap::ID, $api->getId(), Criteria::NOT_EQUAL); } return $this; }