本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectRepository::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectRepository::findAll方法的具体用法?PHP ObjectRepository::findAll怎么用?PHP ObjectRepository::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectRepository
的用法示例。
在下文中一共展示了ObjectRepository::findAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @{inheritdoc}
*/
public function get($id = null)
{
if (null !== $id) {
return $this->repository->find($id);
}
return $this->repository->findAll();
}
示例2: loadChoiceList
/**
* {@inheritdoc}
*/
public function loadChoiceList($value = null)
{
if ($this->choiceList) {
return $this->choiceList;
}
return $this->choiceList = $this->factory->createListFromChoices($this->repository->findAll(), $value);
}
示例3: getRoles
/**
* {@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);
}
示例4: getRules
/**
* 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;
}
示例5: notify
/**
* @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('notifier@php-rfc-digestor.com')->setTo($subscriber->getEmail())->setBody($email, 'text/html');
$this->mailer->send($message);
}
}
示例6: getZones
/**
* 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));
}
示例7: initRoutes
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())));
}
}
示例8: validateObjects
/**
* @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);
}
}
}
示例9: getRules
/**
* 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);
}
示例10: initRoutes
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())));
}
}
}
示例11: notify
/**
* @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);
}
}
示例12: getStates
/**
* @return array
*/
public function getStates()
{
return $this->usStatesRepository->findAll();
}
示例13: getResults
/**
* @return \ArrayIterator
*/
protected function getResults()
{
return new \ArrayIterator($this->repository->findAll());
}
示例14: findPackages
/**
* {@inheritdoc}
*/
public function findPackages()
{
return $this->repository->findAll();
}
示例15: getCategories
/**
* @return mixed
*/
public function getCategories()
{
return $this->repository->findAll();
}