Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:26:54+00:00 2026-06-07T16:26:54+00:00

Using this code in PropertyAdmin extends Admin : public function createQuery($context = ‘list’) {

  • 0
  1. Using this code in PropertyAdmin extends Admin :

    public function createQuery($context = 'list')
    {   
    $user = $this->getConfigurationPool()->getContainer()->get('security.context')->getToken()->getUser();
    $query = $this->getModelManager()->createQuery($this->getClass(), 'o');
    $query->where('o.Creator=:creator')->setParameter("creator", $user);
    return $query;
    }
    

I was able to limit “list” results to those who “belong” to logged admin ie. only Properties (that is an entity) created by logged admin.

The problem:
By manually changing the URL (id value like 1, 2…), I can edit Property that belongs to other user. For edit action, above query is not called at all. How to change that behavior?

2.Instead of putting query in controllers, can I fetch it from PropertyRepository class? That would keep logic in models for which I could write unit tests.

3.I am trying:
ProductAdmin extends AdminHelper {….}
AdminHelper extends Admin { …. }

But it fails saying “Cannot import resource “D:_development\rent2\app/config.” from “D:_development\rent2\app/config\routing.yml”.

AdminHelper is abstract class but Sonata still reads it. Any solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:26:55+00:00Added an answer on June 7, 2026 at 4:26 pm

    1.a) Use ACL for your objects, CRUD controller has permission checking.

    1.b) Redefine edit action, make sure that user tries to edit property that belongs to him, something similar to Page Admin Controller, there create action is redefined

    2) In controller $this->getConfigurationPool()->getContainer()->get(‘doctrine’)->getRepository($this->getClass()); gives you access to repository registered for this model. Probably there are few other ways to get service container and entity manager from it.

    3) To create your admin class you should extend Sonata Admin: docs for this, this problem does not seems to be related to sonata as for me. Can you please provide content for D:_development\rent2\app/config\routing.yml ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using this code to restrict the user to not enter special characters $(input).keyup(function(){
When using this code: <script> $(document).ready(function () { $.getJSON(http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?, function(data) { if(data[0].text.length > 107)
While using this code to serialize an object: public object Clone() { var serializer
Using this code it should return a list of the assets. But it crashes,
Using this code with simplehtmldom script ( http://simplehtmldom.sourceforge.net/manual.htm ): function file_get_html() { $dom =
Using this code, user won't enter numeric value. In Google Chrome, input box is
Using this code for authentification: HttpContext.Current.User=new GenericPrincipal (new GenericIdentity(user.UserName), roles); FormsAuthentication.SetAuthCookie(user.UserName,false); Problem is -
using this code: public class DvdRomUtility { [DllImport(winmm.dll, EntryPoint = mciSendStringA, CharSet = CharSet.Ansi)]
Using this code $.getJSON(http://mydomain.com/getcustomers?callback=?,function(data) { .... }).error(function(err){ .... }) I'm getting jQuery16103492487950357067_1336742910384 was not
using this code: <h2 id=status> 0, 0 </h2> <script type=text/javascript> $('html').mousemove(function(e){ $('#status').html(e.pageX +', '+

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.