owncourses /
courses-server
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Admin; |
||
| 6 | |||
| 7 | use Doctrine\ORM\QueryBuilder; |
||
| 8 | use Sonata\AdminBundle\Admin\AbstractAdmin; |
||
| 9 | use Sonata\AdminBundle\Datagrid\DatagridMapper; |
||
| 10 | use Sonata\AdminBundle\Datagrid\ListMapper; |
||
| 11 | use Sonata\AdminBundle\Form\FormMapper; |
||
| 12 | use Sonata\AdminBundle\Show\ShowMapper; |
||
| 13 | |||
| 14 | final class BookmarkAdmin extends AbstractAdmin |
||
| 15 | { |
||
| 16 | protected $datagridValues = [ |
||
| 17 | '_page' => 1, |
||
| 18 | '_sort_order' => 'DESC', |
||
| 19 | '_sort_by' => 'created', |
||
| 20 | ]; |
||
| 21 | |||
| 22 | protected function configureDatagridFilters(DatagridMapper $datagridMapper): void |
||
| 23 | { |
||
| 24 | $datagridMapper |
||
| 25 | ->add('id') |
||
| 26 | ->add('title') |
||
| 27 | ->add('timeInSeconds') |
||
| 28 | ->add('lesson') |
||
| 29 | ->add('created') |
||
| 30 | ->add('updated') |
||
| 31 | ; |
||
| 32 | } |
||
| 33 | |||
| 34 | protected function configureListFields(ListMapper $listMapper): void |
||
| 35 | { |
||
| 36 | $listMapper |
||
| 37 | ->add('id') |
||
| 38 | ->add('title') |
||
| 39 | ->add('timeInSeconds') |
||
| 40 | ->add('lesson') |
||
| 41 | ->add('created') |
||
| 42 | ->add('updated') |
||
| 43 | ->add('_action', null, [ |
||
| 44 | 'actions' => [ |
||
| 45 | 'show' => [], |
||
| 46 | 'edit' => [], |
||
| 47 | 'delete' => [], |
||
| 48 | ], |
||
| 49 | ]); |
||
| 50 | } |
||
| 51 | |||
| 52 | protected function configureFormFields(FormMapper $formMapper): void |
||
| 53 | { |
||
| 54 | $formMapper |
||
| 55 | ->add('title') |
||
| 56 | ->add('timeInSeconds') |
||
| 57 | ->add('lesson') |
||
| 58 | ; |
||
| 59 | } |
||
| 60 | |||
| 61 | protected function configureShowFields(ShowMapper $showMapper): void |
||
| 62 | { |
||
| 63 | $showMapper |
||
| 64 | ->add('id') |
||
| 65 | ->add('title') |
||
| 66 | ->add('timeInSeconds') |
||
| 67 | ->add('created') |
||
| 68 | ->add('updated') |
||
| 69 | ; |
||
| 70 | } |
||
| 71 | |||
| 72 | public function createQuery($context = 'list') |
||
| 73 | { |
||
| 74 | /** @var QueryBuilder $query */ |
||
| 75 | $query = parent::createQuery($context); |
||
| 76 | $query->andWhere( |
||
| 77 | $query->expr()->isnull($query->getRootAliases()[0].'.user') |
||
| 78 | ); |
||
| 79 | |||
| 80 | return new $query(); |
||
|
1 ignored issue
–
show
|
|||
| 81 | } |
||
| 82 | } |
||
| 83 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.