PHP code example of akeneo / measure-bundle

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

    

akeneo / measure-bundle example snippets


$converter = $this->container->get('akeneo_measure.measure_converter');
$converter->setFamily(LengthFamilyInterface::FAMILY);
$result = $converter->convert(LengthFamilyInterface::KILOMETER, LengthFamilyInterface::MILE, 1);

$this->container->getParameter('akeneo_measure.measures_config');

use Akeneo\Bundle\MeasureBundle\Family\LengthFamilyInterface;

/**
 * Override LengthFamily interface to add Dong measure constant
 */
class MyLengthFamilyInterface extends LengthFamilyInterface
{

    /**
     * @staticvar string
     */
    const DONG = 'DONG';

}

$converter = $this->container->get('akeneo_measure.measure_converter');
$converter->setFamily(LengthFamilyInterface::FAMILY);
$result = $converter->convert(LengthFamilyInterface::KILOMETER, MyLengthFamilyInterface::DONG, 1);

/**
 * Capacitance measures constants
 */
class CapacitanceFamilyInterface
{

    /**
     * Family measure name
     * @staticvar string
     */
    const FAMILY = 'Capacitance';

    /**
     * @staticvar string
     */
    const FARAD     = 'FARAD';

    /**
     * @staticvar string
     */
    const KILOFARAD = 'KILOFARAD';

    /**
     * @staticvar string
     */
    const MEGAFARAD = 'MEGAFARAD';

}