PHP code example of ip / sorter-bundle

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

    

ip / sorter-bundle example snippets



// AppBundle/Entity/Test.php

// ...

use Doctrine\ORM\Mapping as ORM;
use Ip\SorterBundle\Model\BaseSort;

/**
 * @ORM\Entity
 * @ORM\Table(name="test")
 * @ORM\EntityListeners({"Ip\SorterBundle\EventListener\SortListener"})
 */
class Test extends BaseSort
{
    // ...
}


// AppBundle/Controller/testController.php

// ...

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

// ...

class testController extends Controller
{
    
    // ...
    
    public function moveUpAction($id)
    {
        // ...
        
        $testEntity->moveUp($this);

        // ...
    }
    
    public function moveDownAction($id)
    {
        // ...
        
        $testEntity->moveDown($this);

        // ...
    }

    // ...
}


// AppBundle/Entity/ProductSubCategory.php

// ...

use Doctrine\ORM\Mapping as ORM;
use Ip\SorterBundle\Model\BaseSort;

/**
 * @ORM\Entity
 * @ORM\Table(name="product_sub_category")
 * @ORM\EntityListeners({"Ip\SorterBundle\EventListener\SortListener"})
 */
class ProductSubCategory extends BaseSort
{
    // ...
    
    /**
     * @ORM\ManyToOne(targetEntity="ProductCategory", inversedBy="productSubCategories")
     * @ORM\JoinColumn(name="product_category_id", referencedColumnName="id")
     */
    protected $productCategory;
    
    // ...
    
    /**
     * @return array
     */
    public function hasSuperCategory()
    {
        return array('productCategory' => $this->getProductCategory());
    }
}

return array(
    'productCategory' => $this->getProductCategory(),
    'anotherSuperCategory' => $this->getAnotherSuperCategory()
);