/** * This method will filter our query results to a particular billing client ID. * * @param int $clientId * @return QuestionQuery */ public function filterByClientId($clientId) { $userIds = []; $users = Factory::createNewQueryObject(UserQuery::class)->findByBillingClientId($clientId); foreach ($users as $user) { $userIds[] = $user->getUserId(); } return $this->filterByAuthUserId($userIds); }
/** * This action will find a signup record based on the associated token. * * @Route("/signup/findByToken/{token}") * @Method({"GET"}) * * @param Request $request */ public function findByTokenAction($token, Request $request) { $bypassToken = Factory::createNewQueryObject(BypassTokenQuery::class)->findOneByToken($token); if ($bypassToken == null) { $errorResponse = new PropelSOAErrorResponse('That token could not be found. Please try the signup again.', 404); return $errorResponse; } $signup = Factory::createNewQueryObject(SignupQuery::class)->findOneByAuthBypassTokenId($bypassToken->getBypassTokenId()); if ($signup == null) { $errorResponse = new PropelSOAErrorResponse('We could not find a record of your signup. Please try the signup again.', 404); return $errorResponse; } $signupData = ['SignupId' => $signup->getSignupId(), 'Name' => $signup->getName(), 'Email' => $signup->getEmail()]; return new PropelSOASuccessResponse($signupData); }
/** * This method will determine if the current client or user has access to view our materials. * * @return int */ public function isAuthorized() { $clientPeer = Factory::createNewObject(ClientPeer::class); $clientId = $clientPeer->getWorkingClientId(); if ($clientId === null) { return true; } $client = Factory::createNewQueryObject(ClientQuery::class)->findOneByClientId($clientId); foreach ($client->getClientProducts() as $clientProduct) { if ($clientProduct->getProductId() == $this->getBillingProductId()) { // Our related product is in the list of products the client has access to, so they should be able to view this. return 1; } if ($clientProduct->getProduct()->getCode() == 'NEVER_STOP_LEARNING') { // This client is on the all-access plan, and should always have access return 1; } } return 0; }
public function testInjectQueryObjectCausesMockToReturnFromCreateNewQueryObject() { $queryMock = $this->getMock(stdClass::class, []); Factory::injectQueryObject(stdClass::class, $queryMock); $this->assertEquals($queryMock, Factory::createNewQueryObject(stdClass::class)); }