Skip to content

Commit

Permalink
Merge 3f5bb4a into 8404c4c
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Dec 13, 2017
2 parents 8404c4c + 3f5bb4a commit a6dc733
Show file tree
Hide file tree
Showing 42 changed files with 381 additions and 388 deletions.
34 changes: 17 additions & 17 deletions docs/cookbook/recipe_custom_action.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ to implement a ``clone`` action.
return new RedirectResponse($this->admin->generateUrl('list'));
// if you have a filtered list and want to keep your filters after the redirect
// return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
// return new RedirectResponse($this->admin->generateUrl('list', ['filter' => $this->admin->getFilterParameters()]));
}
}
Expand All @@ -128,7 +128,7 @@ If you want to add the current filter parameters to the redirect url you can add

.. code-block:: php
return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
return new RedirectResponse($this->admin->generateUrl('list', ['filter' => $this->admin->getFilterParameters()]));
Using template in new controller
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -190,16 +190,16 @@ Next we have to add the action in ``configureListFields`` specifying the templat
// other fields...
->add('_action', null, array(
'actions' => array(
->add('_action', null, [
'actions' => [
// ...
'clone' => array(
'clone' => [
'template' => 'AppBundle:CRUD:list__action_clone.html.twig'
)
)
))
]
]
])
;
}
Expand Down Expand Up @@ -244,16 +244,16 @@ The full ``CarAdmin.php`` example looks like this:
->add('engine')
->add('rescueEngine')
->add('createdAt')
->add('_action', null, array(
'actions' => array(
'show' => array(),
'edit' => array(),
'delete' => array(),
'clone' => array(
->add('_action', null, [
'actions' => [
'show' => [],
'edit' => [],
'delete' => [],
'clone' => [
'template' => 'AppBundle:CRUD:list__action_clone.html.twig'
)
)
));
]
]
]);
}
protected function configureShowFields(ShowMapper $showMapper)
Expand Down
16 changes: 8 additions & 8 deletions docs/cookbook/recipe_file_uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ Both of these are straightforward when you know what to do:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('file', 'file', array(
->add('file', 'file', [
'required' => false
))
])
// ...
;
Expand Down Expand Up @@ -237,15 +237,15 @@ looks like this:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('linkedImage1', 'sonata_type_admin', array(
->add('linkedImage1', 'sonata_type_admin', [
'delete' => false
))
->add('linkedImage2', 'sonata_type_admin', array(
])
->add('linkedImage2', 'sonata_type_admin', [
'delete' => false
))
->add('linkedImage3', 'sonata_type_admin', array(
])
->add('linkedImage3', 'sonata_type_admin', [
'delete' => false
))
])
// ...
;
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook/recipe_image_previews.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ we are manipulating form fields we do this from within ``ImageAdmin::configureFo
$image = $this->getSubject();
// use $fileFieldOptions so we can add other options to the field
$fileFieldOptions = array('required' => false);
$fileFieldOptions = ['required' => false];
if ($image && ($webPath = $image->getWebPath())) {
// get the container so the full path to the image can be set
$container = $this->getConfigurationPool()->getContainer();
Expand Down Expand Up @@ -115,7 +115,7 @@ Admin class is embedded and use a different method:
}
// use $fileFieldOptions so we can add other options to the field
$fileFieldOptions = array('required' => false);
$fileFieldOptions = ['required' => false];
if ($image && ($webPath = $image->getWebPath())) {
// add a 'help' option containing the preview's img tag
$fileFieldOptions['help'] = '<img src="'.$webPath.'" class="admin-preview" />';
Expand Down
18 changes: 9 additions & 9 deletions docs/cookbook/recipe_select2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ To disable select2 on some ``select`` form element, set data attribute ``data-so
public function configureFormFields(FormMapper $formMapper)
{
$formMaper
->add('category', 'sonata_type_model', array(
'attr' => array(
->add('category', 'sonata_type_model', [
'attr' => [
'data-sonata-select2' => 'false'
)
))
]
])
;
}
Expand All @@ -60,14 +60,14 @@ to enable ``allowClear`` or ``data-sonata-select2-allow-clear = "false"`` to dis
public function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('category', 'sonata_type_model', array(
'attr' => array(
->add('category', 'sonata_type_model', [
'attr' => [
'data-sonata-select2-allow-clear' => 'false'
)
))
]
])
;
}
.. note::

You have to use false as string! ``"false"``!
You have to use false as string! ``"false"``!
31 changes: 15 additions & 16 deletions docs/cookbook/recipe_sortable_listing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ and use the default twig template provided in the ``pixSortableBehaviorBundle``
.. code-block:: php
$listMapper
->add('_action', null, array(
'actions' => array(
'move' => array(
'template' => 'PixSortableBehaviorBundle:Default:_sort.html.twig'
),
)
)
);
->add('_action', null, [
'actions' => [
'move' => [
'template' => 'PixSortableBehaviorBundle:Default:_sort.html.twig'
],
]
]);
In order to add new routes for these actions we are also adding the following method
Expand Down Expand Up @@ -133,11 +132,11 @@ Now we need to define the sort by field to be ``$position``:
class ClientAdmin extends AbstractAdmin
{
protected $datagridValues = array(
protected $datagridValues = [
'_page' => 1,
'_sort_order' => 'ASC',
'_sort_by' => 'position',
);
];
protected function configureRoutes(RouteCollection $collection)
{
Expand All @@ -152,13 +151,13 @@ Now we need to define the sort by field to be ``$position``:
$listMapper
->addIdentifier('name')
->add('enabled')
->add('_action', null, array(
'actions' => array(
'move' => array(
->add('_action', null, [
'actions' => [
'move' => [
'template' => 'AppBundle:Admin:_sort.html.twig'
),
),
))
],
],
])
;
}
}
Expand Down
8 changes: 4 additions & 4 deletions docs/cookbook/recipe_sortable_sonata_type_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ So we start by updating ``UserBundle/Resources/config/doctrine/User.orm.xml`` an

.. code-block:: xml
<one-to-many field="userHasExpectations" target-entity="UserBundle\Entity\UserHasExpectations" mapped-by="user" orphan-removal="true">
<one-to-many field="userHasExpectations" target-entity="UserBundle\Entity\UserHasExpectations" mapped-by="user" orphan-removal="true">
<cascade>
<cascade-persist />
</cascade>
Expand Down Expand Up @@ -322,7 +322,7 @@ So we are going to start by creating this ``UserBundle\Admin\UserHasExpectations
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('expectation', 'sonata_type_model', array('required' => false))
->add('expectation', 'sonata_type_model', ['required' => false])
->add('position', 'hidden')
;
}
Expand Down Expand Up @@ -363,14 +363,14 @@ Now update the ``UserBundle\Admin\UserAdmin.php`` by adding the ``sonata_type_mo
// ...
$formMapper
->add('userHasExpectations', 'sonata_type_model', array(
->add('userHasExpectations', 'sonata_type_model', [
'label' => 'User\'s expectations',
'query' => $this->modelManager->createQuery('UserBundle\Entity\Expectation'),
'required' => false,
'multiple' => true,
'by_reference' => false,
'sortable' => true,
))
])
;
$formMapper->get('userHasExpectations')->addModelTransformer(new ExpectationDataTransformer($this->getSubject(), $this->modelManager));
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ line in the `app/AppKernel.php` file of your project:
{
public function registerBundles()
{
$bundles = array(
$bundles = [
// ...
// The admin requires some twig functions defined in the security
Expand All @@ -72,7 +72,7 @@ line in the `app/AppKernel.php` file of your project:
// And finally, the storage and SonataAdminBundle
new Sonata\AdminBundle\SonataAdminBundle(),
);
];
// ...
}
Expand Down
16 changes: 8 additions & 8 deletions docs/getting_started/the_form_view.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ as choice.
{
$formMapper
// ...
->add('category', 'entity', array(
->add('category', 'entity', [
'class' => 'AppBundle\Entity\Category',
'property' => 'name',
))
])
;
}
.. note::
Expand Down Expand Up @@ -135,10 +135,10 @@ dialog with the admin of the referenced model in it:
{
$formMapper
// ...
->add('category', 'sonata_type_model', array(
->add('category', 'sonata_type_model', [
'class' => 'AppBundle\Entity\Category',
'property' => 'name',
))
])
;
}
Expand Down Expand Up @@ -168,10 +168,10 @@ category field to a Meta data group. To do this, use the ``with()`` method:
->end()
->with('Meta data')
->add('category', 'sonata_type_model', array(
->add('category', 'sonata_type_model', [
'class' => 'AppBundle\Entity\Category',
'property' => 'name',
))
])
->end()
;
}
Expand All @@ -188,10 +188,10 @@ order to tweak the styling:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('Content', array('class' => 'col-md-9'))
->with('Content', ['class' => 'col-md-9'])
// ...
->end()
->with('Meta data', array('class' => 'col-md-3')
->with('Meta data', ['class' => 'col-md-3'])
// ...
->end()
;
Expand Down
6 changes: 3 additions & 3 deletions docs/getting_started/the_list_view.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ field has 5 arguments:
// filter
$type = null,
array $filterOptions = array(),
array $filterOptions = [],
// field
$fieldType = null,
Expand All @@ -185,10 +185,10 @@ the search field to use the ``name`` property of the Category:
{
$datagridMapper
->add('title')
->add('category', null, array(), 'entity', array(
->add('category', null, [], 'entity', [
'class' => 'AppBundle\Entity\Category',
'choice_label' => 'name', // In Symfony2: 'property' => 'name'
))
])
;
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/action_export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ behavior for a specific admin, you can override the ``getExportFields()`` method
public function getExportFields()
{
return array('givenName', 'familyName', 'contact.phone');
return ['givenName', 'familyName', 'contact.phone'];
}
.. note::
Expand Down Expand Up @@ -68,7 +68,7 @@ method in your admin class.
public function getExportFormats()
{
return array('pdf', 'html');
return ['pdf', 'html'];
}
Customizing the query used to fetch the results
Expand Down

0 comments on commit a6dc733

Please sign in to comment.