/** * @{inheritdoc} */ public function get($id = null) { if (null !== $id) { return $this->repository->find($id); } return $this->repository->findAll(); }
/** * {@inheritdoc} */ public function loadChoiceList($value = null) { if ($this->choiceList) { return $this->choiceList; } return $this->choiceList = $this->factory->createListFromChoices($this->repository->findAll(), $value); }
/** * {@inheritDoc} */ public function getRoles() { $result = $this->objectRepository->findAll(); $roles = array(); // Pass One: Build each object foreach ($result as $role) { if (!$role instanceof RoleInterface) { continue; } $roleId = $role->getRoleId(); $parent = null; if ($role instanceof HierarchicalRoleInterface && ($parent = $role->getParent())) { $parent = $parent->getRoleId(); } $roles[$roleId] = new Role($roleId, $parent); } // Pass Two: Re-inject parent objects to preserve hierarchy /* @var $roleObj \BjyAuthorize\Acl\Role */ foreach ($roles as $roleObj) { $parentRoleObj = $roleObj->getParent(); if ($parentRoleObj && $parentRoleObj->getRoleId()) { $roleObj->setParent($roles[$parentRoleObj->getRoleId()]); } } return array_values($roles); }
/** * Here we read rules from DB and put them into a form that BjyAuthorize's Controller.php understands */ public function getRules() { $rules = array(); // initialize the rules array // // get the doctrine shemaManager $schemaManager = $this->objectManager->getConnection()->getSchemaManager(); // check if the roles table exists, if it does not, do not bother querying if ($schemaManager->tablesExist(array('roles')) === true) { //read from object store a set of (role, controller, action) $result = $this->objectRepository->findAll(); // if a result set exists if (count($result)) { //transform to object BjyAuthorize will understand foreach ($result as $key => $role) { $roleId = $role->getRoleId(); // check if any resource access has been defined before // if it has, continue with normal operations // else, allow access to this first user if (!$role->getResources()) { continue; } foreach ($role->getResources() as $rle) { $this->defaultRules['allow'][] = [[$roleId], $rle->getControllerId(), []]; } } } } return $this->defaultRules; }
/** * @param Rfc $rfc * @param array $voteDiff */ public function notify(Rfc $rfc, array $voteDiff) { foreach ($this->emailSubscriberRepository->findAll() as $subscriber) { $email = $this->twig->render('rfc.twig', ['rfcName' => $rfc->getName(), 'details' => $voteDiff['details'], 'changeLog' => $voteDiff['changeLog'], 'voteDiffs' => $voteDiff['votes'], 'rfcVotes' => $rfc->getVotes(), 'unsubscribeUrl' => sprintf('%s/unsubscribe/%s', $this->config->get('app.url'), $subscriber->getUnsubscribeToken())]); $message = $this->mailer->createMessage()->setSubject(sprintf('%s updated!', $rfc->getName()))->setFrom('*****@*****.**')->setTo($subscriber->getEmail())->setBody($email, 'text/html'); $this->mailer->send($message); } }
/** * Gets all zones * * @param string|null $scope * * @return array $zones */ protected function getZones($scope = null) { if (null === $scope) { return $this->repository->findAll(); } return $this->repository->findBy(array('scope' => $scope)); }
private function initRoutes() { $redirects = $this->redirectRepository->findAll(); foreach ($redirects as $redirect) { /** @var Redirect $redirect */ $this->routeCollection->add('_redirect_route_' . $redirect->getId(), new Route($redirect->getOrigin(), array('_controller' => 'FrameworkBundle:Redirect:urlRedirect', 'path' => $redirect->getTarget(), 'permanent' => $redirect->isPermanent()))); } }
/** * @param ObjectRepository $repository The entity repository * @param string $type Type is used to display errors if needed */ protected function validateObjects(ObjectRepository $repository, $type) { $validator = $this->getService('validator'); $entities = $repository->findAll(); foreach ($entities as $entity) { $violations = $validator->validate($entity); if (0 !== $violations->count()) { $this->addErrors($violations, $entity, $type); } } }
/** * Here we read rules from DB and put them into an a form that BjyAuthorize's Controller.php understands */ public function getRules() { //read from object store a set of (role, controller, action) $result = $this->objectRepository->findAll(); //transform to object BjyAuthorize will understand $rules = array(); foreach ($result as $key => $rule) { $role = $rule->getRole()->getRoleId(); $controller = $rule->getController(); $action = $rule->getAction(); if ($action === 'all') { $rules[$controller]['roles'][] = $role; $rules[$controller]['controller'] = array($controller); } else { $rules[$controller . ':' . $action]['roles'][] = $role; $rules[$controller . ':' . $action]['controller'] = array($controller); $rules[$controller . ':' . $action]['action'] = array($action); } } return array_values($rules); }
private function initRoutes() { $redirects = $this->redirectRepository->findAll(); $domain = $this->domainConfiguration->getHost(); /** @var Redirect $redirect */ foreach ($redirects as $redirect) { // Only add the route when the domain matches or the domain is empty if ($redirect->getDomain() == $domain || !$redirect->getDomain()) { $this->routeCollection->add('_redirect_route_' . $redirect->getId(), new Route($redirect->getOrigin(), array('_controller' => 'FrameworkBundle:Redirect:urlRedirect', 'path' => $redirect->getTarget(), 'permanent' => $redirect->isPermanent()))); } } }
/** * @param Rfc $rfc * @param array $voteDiff */ public function notify(Rfc $rfc, array $voteDiff) { $attachments = []; foreach ($voteDiff['votes'] as $title => $voteDiffs) { $attachment = ['text' => $title, 'color' => 'good', 'fields' => []]; if (!empty($voteDiffs['new'])) { $newVotes = array_map(function ($voter, $vote) { return sprintf('%s: %s', $voter, $vote); }, array_keys($voteDiffs['new']), $voteDiffs['new']); $attachment['fields'][] = ['title' => 'New Votes', 'value' => implode(", ", $newVotes)]; } if (!empty($voteDiffs['updated'])) { $updatedVotes = array_map(function ($voter, $vote) { return sprintf('%s: %s', $voter, $vote); }, array_keys($voteDiffs['updated']), $voteDiffs['updated']); $attachment['fields'][] = ['title' => 'Updated Votes', 'value' => implode(", ", $updatedVotes)]; } $counts = []; foreach ($rfc->getVotes()[$title]['counts'] as $header => $standing) { if ($header === 'Real name') { continue; } $counts[$header] = $standing; } $counts = array_map(function ($vote, $count) { return sprintf('%s: %s', $vote, $count); }, array_keys($counts), $counts); $attachment['fields'][] = ['title' => 'Current Standings', 'value' => implode(", ", $counts)]; $attachments[] = $attachment; } $message = ['text' => sprintf("*PHP RFC Updates for %s*", $rfc->getName()), 'username' => 'PHP RFC Digestor', 'icon_url' => 'http://php.net/images/logos/php.ico', 'attachments' => json_encode($attachments)]; foreach ($this->slackSubscriberRepository->findAll() as $slackSubscriber) { $this->commander->setToken($slackSubscriber->getToken()); $message['channel'] = '#' . $slackSubscriber->getChannel(); $this->commander->execute('chat.postMessage', $message); } }
/** * @return array */ public function getStates() { return $this->usStatesRepository->findAll(); }
/** * @return \ArrayIterator */ protected function getResults() { return new \ArrayIterator($this->repository->findAll()); }
/** * {@inheritdoc} */ public function findPackages() { return $this->repository->findAll(); }
/** * @return mixed */ public function getCategories() { return $this->repository->findAll(); }
/** * Return all the clients * @return array */ public function findAll() { return $this->clientRepository->findAll(); }
/** * @return ShipmentCollectionPoint[] */ public function getCollectionPoints() { return $this->collectionPointRepository->findAll(); }
/** * @return array */ public function findAll() { return $this->exRateRepository->findAll(); }
/** * {@inheritdoc} */ public function findSubscriptions() { return $this->repository->findAll(); }
/** * @inheritdoc */ function getAll() { $x = $this->cardRepository->findAll(); return $this->cardRepository->findAll(); }
/** * @return array */ public function findAll() { return $this->appSettingRepository->findAll(); }
/** * (non-PHPDoc) * @see Rhapsody\SocialBundle\Doctrine\CategoryManagerInterface::findAll() */ public function findAll($map = false) { $results = $this->repository->findAll(); return !$map ? array_values($results) : $results; }
/** * @return Categories|Category[] */ public function getAll() { return new Categories($this->repository->findAll()); }
/** * @param array $expectedData * @return Scenario */ public function then(array $expectedData) { $this->testCase->assertEquals($expectedData, $this->repository->findAll()); return $this; }
/** * Finds all objects in the repository. * * @return mixed The objects. */ public function findAll() { return $this->objectRepository->findAll(); }
/** * Get a random item from a repo * * @param Faker\Generator $faker * @param ObjectRepository $repo * @param array &$items * * @return mixed */ protected function getRandomItem(Faker\Generator $faker, ObjectRepository $repo, array &$items = null) { if (null === $items) { $items = []; $loadedItems = $repo->findAll(); foreach ($loadedItems as $item) { $items[$item->getCode()] = $item; } } return $faker->randomElement($items); }
/** * @return mixed */ public function getAll() { $result = $this->repository->findAll(); return $result; }