PHP code example of yottacms / yotta-unit-bundle

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

    

yottacms / yotta-unit-bundle example snippets

    
// UnitExample.php
use Symfony\Component\DependencyInjection\ContainerInterface;
use YottaCms\Bundle\YottaUnitBundle\UnitManager\UnitInterface;

class UnitExample implements UnitInterface
{
    const PARAMETER_KEY = 'unit_example';
    
    protected $configUnit;
    
    public function __construct(ContainerInterface $container)
    {
        if (!isset($container->getParameter('yotta_unit.items')[self::PARAMETER_KEY])) {
            throw new \Exception('Parameters "' . self::PARAMETER_KEY . '" not found in yotta_unit.items');
        }
        
        $this->configUnit = $container->getParameter('yotta_unit.items')[self::PARAMETER_KEY];
    }
    
    /**
     * @inheritdoc
     */
    public function getName(): string 
    {
        return $this->configUnit['name'];
    }
    
    /**
     * @inheritdoc
     */
    public function getDescription(): ?string 
    {
        return $this->configUnit['description'];
    }
    
    /**
     * @inheritdoc
     */
    public function getEntryPoint(): ?string
    {
        return $this->configUnit['entry_point'];
    }
    
    /**
     * @inheritdoc
     */
    public function getConfig(): array
    {
        return $this->configUnit;
    }
    
    /**
     * @inheritdoc
     */
    public function getType(): string
    {
        return $this->configUnit['type'];
    }
}