PHP code example of tavy315 / sylius-labels-plugin

1. Go to this page and download the library: Download tavy315/sylius-labels-plugin 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/ */

    

tavy315 / sylius-labels-plugin example snippets



$bundles = [
    Tavy315\SyliusLabelsPlugin\Tavy315SyliusLabelsPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
];

     
    // src/Entity/Product.php
    
    namespace App\Entity;

    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\Product as BaseProduct;
    use Tavy315\SyliusLabelsPlugin\Model\LabelsAwareTrait;
    use Tavy315\SyliusLabelsPlugin\Model\ProductInterface;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_product")
     */
    class Product extends BaseProduct implements ProductInterface
    {
        use LabelsAwareTrait {
            LabelsAwareTrait::__construct as private __labelsTraitConstruct;
        }
      
        public function __construct()
        {
            $this->__labelsTraitConstruct();
            parent::__construct();
        }
    }
    

    
    // src/Model/Product.php
    
    namespace App\Model;
    
    use Sylius\Component\Core\Model\Product as BaseProduct;
    use Tavy315\SyliusLabelsPlugin\Model\LabelsAwareTrait;
    use Tavy315\SyliusLabelsPlugin\Model\ProductInterface;
    
    class Product extends BaseProduct implements ProductInterface
    {
        use LabelsAwareTrait {
            LabelsAwareTrait::__construct as private __labelsTraitConstruct;
        }
      
        public function __construct()
        {
            $this->__labelsTraitConstruct();
            parent::__construct();
        }
    }