PHP code example of ns / admin-bundle

1. Go to this page and download the library: Download ns/admin-bundle 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/ */

    

ns / admin-bundle example snippets


class FooBar extends NS\AdminBundle\Entity\AdminSoftDeletableEntity
{
    public function __toString()
    {
        return 'somestring';
    }
}

class FooBarRepository extends NS\AdminBundle\Repository\AbstractAdminManagedRepository
{
    public function __construct(Doctrine\Persistence\ManagerRegistry $registry)
    {
        parent::__construct($registry, FooBar::class);
    }
}

class FooBarService extends NS\AdminBundle\Service\AdminService
{
    public function getClass(): string
    {
        return FooBar::class;
    }
}

class FooBarEditType extends Symfony\Component\Form\AbstractType
{
    public function buildForm()
    {
        //...
    }
}

class FoobarAdminController extends NS\AdminBundle\Controller\AbstractAdminController
{
    public function __construct(FooBarService $admin_service)
    {
        parent::__construct($admin_service);
    }
    
    protected function getEditFormClass(): string
    {
        return FooBarEditType::class;
    }
    
    protected function getListTemplate(): string
    {
        return 'path/to/list.html.twig';
    }

    //Only needed if using a view template:
    protected function getViewTemplate(): string
    {
        return 'path/to/view.html.twig';
    }

}