Skip to content

Instantly share code, notes, and snippets.

@diegograssato
Created March 11, 2014 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegograssato/9478512 to your computer and use it in GitHub Desktop.
Save diegograssato/9478512 to your computer and use it in GitHub Desktop.
Module.php
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace DTUXFixture;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface,
Zend\ModuleManager\Feature\ConfigProviderInterface,
Zend\ModuleManager\Feature\ConsoleUsageProviderInterface,
Zend\Console\Adapter\AdapterInterface as Console,
Zend\ModuleManager\Feature\ConsoleBannerProviderInterface;
use Symfony\Component\Yaml\Parser as YamlParser,
Zend\Config\Factory as ConfigFactory;
class Module implements
AutoloaderProviderInterface,
ConfigProviderInterface,
ConsoleUsageProviderInterface,
ConsoleBannerProviderInterface
{
public function init()
{
// This first line is just for the shorter yml suffix
ConfigFactory::registerReader( 'yml', 'yaml' );
// Adding the parser to the reader
$decoder = new YamlParser();
$reader = ConfigFactory::getReaderPluginManager()->get( 'yaml' );
$reader->setYamlDecoder( [ $decoder, 'parse' ] );
}
public function onBootstrap(MvcEvent $e)
{
//$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function getsConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getConfig()
{
$decoder = new YamlParser();
$reader = ConfigFactory::getReaderPluginManager()->get( 'yaml' );
$data = $reader->fromFile(__DIR__ . '/config/module.config.yml');
$config = new \Zend\Config\Config(array('__DIR__' => __DIR__.'/config'), true);
$processor = new \Zend\Config\Processor\Constant();
$processor->process($config);
$data['view_manager']['template_path_stack']['SampleModule'] = $config->__DIR__.'/../view';
return $data;
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
/**
* Necessario para configurar opções para o console
* @param Console $console
* @return array|null|string
*/
public function getConsoleUsage(Console $console)
{
return array(
// Describe available commands
'fixture' => 'Load Fixture',
// Describe expected parameters
array( 'fixName', 'Fixture name(optional)' )
);
}
/**
* This method is defined in ConsoleBannerProviderInterface
*/
public function getConsoleBanner(Console $console){
return
"==------------------------------------------------------==\n" .
" DataFixture - Load fixtures the entitys \n" .
"==------------------------------------------------------==\n" .
"Mongo ODM version ".\Doctrine\ODM\MongoDB\Version::VERSION
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment