PHP code example of flame / modules

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

    

flame / modules example snippets


class AppExtension extends CompilerExtension implements Flame\Modules\Providers\IRouterProvider
{

	/**
	 * Returns array of ServiceDefinition,
	 * that will be appended to setup of router service
	 * 
 	 * @example https://github.com/nette/sandbox/blob/master/app/router/RouterFactory.php - createRouter()
	 * @return \Nette\Application\IRouter
	 */
	public function getRoutesDefinition()
	{
		return new Nette\Application\Routers\Route('<module>/<presenter>/<action>[/<id>]', array(
			'module' => 'App',
			'Presenter' => 'Homepage',
			'action' => 'default',
			'id' => null
		);
	}
}

class AppExtension extends CompilerExtension
{
	public function loadConfiguration()
    	{
    		$builder = $this->getContainerBuilder();
    		$builder->addDefinition('service.routerFactory')
    			->setClass('Modules\RouterFactory') // YOUR ROUTER FACTORY CLASS
    			->addTag(Flame\Modules\ModulesExtension::TAG_ROUTER); // DONT FORGET TO ADD THE TAG!
    	}
}

class AppExtension extends CompilerExtension implements Flame\Modules\Providers\IPresenterMappingProvider
{

	/**
    	 * Returns array of ClassNameMask => PresenterNameMask
    	 *
    	 * @example return array('*' => 'Booking\*Module\Presenters\*Presenter');
    	 * @return array
    	 */
    	public function getPresenterMapping()
    	{
    		return array(
    			'*' => 'App\*Module\Presenters\*Presenter'
    		);
    	}
}

class AppExtension extends CompilerExtension implements Flame\Modules\Providers\IParametersProvider
{

	/**
	 * Return array of parameters,
	 * which you want to add into DIC
	 *
	 * @example return array('images' => 'path/to/folder/with/images');
	 * @return array
	 */
	public function getParameters()
	{
		return array(
			'images' => '%wwwDir%/path/to/folder/with/images',
			'consoleMode' => true,
			'appDir' => 'aa'
		);
	}

}

class HelperExtension extends CompilerExtension implements Flame\Modules\Providers\ITemplateHelpersProvider
{

	/**
	 * Return list of helpers definitions or providers
	 *
	 * @return array
	 */
	public function getHelpersConfiguration()
	{
		return array(
			'App\HelperModule\Template\HelperProvider'
		);
	}
}


class MacroExtension extends CompilerExtension implements Flame\Modules\Providers\ILatteMacrosProvider
{

	/**
	 * Get array of latte macros classes
	 *
	 * @return array
	 */
	public function getLatteMacros()
	{
		return array(
			'App\MacroModule\Template\MacroInstaller'
		);
	}
}

class ErrorExtension extends CompilerExtension implements Flame\Modules\Providers\IErrorPresenterProvider
{

	/**
	 * Return name of error presenter
	 *
	 * @return string
	 */
	public function getErrorPresenterName()
	{
		return 'Error:CustomError';
	}
}