PHP code example of tangoman / repository-helper

1. Go to this page and download the library: Download tangoman/repository-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tangoman / repository-helper example snippets




namespace FoobarBundle\Repository;

use Doctrine\ORM\EntityRepository;
use TangoMan\RepositoryHelper\RepositoryHelper;

/**
 * Class FoobarRepository
 */
class FoobarRepository extends EntityRepository
{
    use RepositoryHelper;
}

use Symfony\Component\HttpFoundation\Request;

class FoobarController extends Controller
{
    /**
     * @Route("/")
     */
    public function indexAction(Request $request)
    {
        // Show searchable, sortable, paginated user list
        $em = $this->get('doctrine')->getManager();
        $foobars = $em->getRepository('AppBundle:Foobar')->findByQuery($request);

        return $this->render(
            'admin/foobar/index.html.twig',
            [
                'foobars' => $foobars,
            ]
        );
    }
twig
<th class="{{ app.request.query.get('order') == 'user-username' ? app.request.query.get('way', 'ASC') }}">
    <a href="{{ path('app_admin_post_index', app.request.query.all|merge({
        'page'  : 1,
        'order' : 'user-username',
        'way'   : app.request.query.get('order') == 'user-username'
        and app.request.query.get('way', 'ASC') == 'ASC' ? 'DESC' : 'ASC'})) }}">
        User
    </a>
</th>