Example #1
0
 /**
  * @param string $fileName
  * @param null $path
  * @return array
  */
 protected function getConfig($fileName, $path = null)
 {
     $extension = explode('.', $fileName);
     switch (end($extension)) {
         case 'yml':
             $reader = new \Zend\Config\Reader\Yaml(array('Spyc', 'YAMLLoadString'));
             return $reader->fromFile($this->getConfigPath($path) . $fileName);
         case 'ini':
             break;
         case 'xml':
             break;
         default:
             break;
     }
 }
Example #2
0
<?php

namespace Whathood;

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
return array('router' => array('routes' => array('home' => array('type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array('route' => '/', 'constraints' => array('regionName' => 'Philadelphia'), 'defaults' => array('controller' => 'Whathood\\Controller\\Region', 'action' => 'show')), 'may_terminate' => true, 'child_routes' => array('about' => array('type' => 'literal', 'options' => array('route' => 'about', 'defaults' => array('controller' => 'Whathood\\Controller\\Index', 'action' => 'about'))))), 'region' => array('type' => 'Segment', 'options' => array('route' => '/:region[/]', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Region', 'action' => 'show'))), 'neighborhood' => array('type' => 'Segment', 'options' => array('route' => '/:region/:neighborhood[/]', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Neighborhood', 'action' => 'show'))), 'whathood_default' => array('type' => 'Literal', 'options' => array('route' => '/whathood', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Index', 'action' => 'index')), 'may_terminate' => true, 'child_routes' => array('default' => array('type' => 'Segment', 'options' => array('route' => '/[:controller[/:action]]', 'constraints' => array('controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'), 'defaults' => array())))), 'user_polygon_id' => array('type' => 'Segment', 'options' => array('route' => '/whathood/user-polygon/by-id/:user_polygon_id[/format/:format]', 'constraints' => array('region_name' => '[a-zA-Z][a-zA-Z0-9_-]+', 'user_polygon_id' => '[0-9]+'), 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'UserPolygon', 'action' => 'by-id'))), 'whathood_search' => array('type' => 'Segment', 'options' => array('route' => '/whathood-search', 'constraints' => array('region' => '[a-zA-Z][a-zA-Z0-9_-]+'), 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Whathood', 'action' => 'by-position'))), 'search' => array('type' => 'Segment', 'options' => array('route' => '/search', 'constraints' => array('region' => '[a-zA-Z][a-zA-Z0-9_-]+'), 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Search', 'action' => 'index'))), 'user_polygon_page_list' => array('type' => 'Segment', 'options' => array('route' => '/whathood/user-polygon/page-list/page/:page', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Whathood\\Controller\\UserPolygon', 'action' => 'page-list'))), 'user_polygon_page_neighborhood' => array('type' => 'Segment', 'options' => array('route' => '/whathood/user-polygon/page/region/:region/neighborhood/:neighborhood/:page[/]', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Whathood\\Controller\\UserPolygon', 'action' => 'page-neighborhood'))), 'user_polygon_page_center' => array('type' => 'Segment', 'options' => array('route' => '/whathood/user-polygon/page-center/page/:page/x/:x/y/:y', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Whathood\\Controller\\UserPolygon', 'action' => 'page-center'))), 'admin' => array('type' => 'Segment', 'options' => array('route' => '/admin', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Admin', 'action' => 'index'))), 'sitemap' => array('type' => 'Segment', 'options' => array('route' => '/sitemap', 'defaults' => array('__NAMESPACE__' => 'Whathood\\Controller', 'controller' => 'Index', 'action' => 'navigation'))), 'rest-test-point' => array('type' => 'Segment', 'options' => array('route' => '/api/v1/test-point[/:id]', 'defaults' => array('controller' => 'Whathood\\Controller\\TestPointRestful'))), 'rest-neighborhood-polygon' => array('type' => 'Segment', 'options' => array('route' => '/api/v1/neighborhood-polygon[/:id]', 'defaults' => array('controller' => 'Whathood\\Controller\\NeighborhoodPolygonRestful'))), 'rest-user-polygon' => array('type' => 'Segment', 'options' => array('route' => '/api/v1/user-polygon[/:id]', 'defaults' => array('controller' => 'Whathood\\Controller\\UserPolygonRestful'))), 'rest-whathood' => array('type' => 'Segment', 'options' => array('route' => '/api/v1/whathood[/x/:x][/y/:y]', 'defaults' => array('controller' => 'Whathood\\Controller\\ElectionPointRestful'))))), 'console' => array('router' => array('routes' => array('np' => array('options' => array('route' => 'np', 'defaults' => array('controller' => 'Whathood\\Controller\\NeighborhoodPolygonConsole', 'action' => 'consoledefault'))), 'up' => array('options' => array('route' => 'up', 'defaults' => array('controller' => 'Whathood\\Controller\\UserPolygonConsole', 'action' => 'consoledefault'))), 'neighborhood' => array('options' => array('route' => 'neighborhood', 'defaults' => array('controller' => 'Whathood\\Controller\\NeighborhoodConsole', 'action' => 'consoledefault'))), 'watcher-route' => array('options' => array('route' => 'watcher [--forever] [--force] [--neighborhood=] [--region=] [--grid-res=] [--target-precision=]', 'defaults' => array('controller' => 'Whathood\\Controller\\WatcherConsole', 'action' => 'watch'))), 'test-point-route' => array('options' => array('route' => 'test-point show [--neighborhood=] [--region=] [--grid-res=]', 'defaults' => array('controller' => 'Whathood\\Controller\\TestPointConsole', 'action' => 'show'))), 'neighborhood-delete' => array('options' => array('route' => 'neighborhood delete [--id=] [--neighborhood=] [--region=]', 'defaults' => array('controller' => 'Whathood\\Controller\\Neighborhood', 'action' => 'delete'))), 'db-size-route' => array('options' => array('route' => 'postgres size', 'defaults' => array('controller' => 'Whathood\\Controller\\PostgresConsole', 'action' => 'show-database-size')))))), 'service_manager' => array('factories' => array('Whathood\\YamlConfig' => function ($sm) {
    require_once 'vendor/mustangostang/spyc/Spyc.php';
    $reader = new \Zend\Config\Reader\Yaml(array('Spyc', 'YAMLLoadString'));
    return $reader->fromFile('../whathood.yaml');
}, 'Whathood\\Logger' => function ($sm) {
    $config = $sm->get('Config');
    $file = $config['whathood']['log']['logfile'];
    $file_writer = new \Zend\Log\Writer\Stream($file);
    $logger = new \Whathood\Logger();
    $logger->addWriter($file_writer);
    return $logger;
}, 'Whathood\\ConsoleLogger' => function ($sm) {
    $logger = $sm->get('Whathood\\Logger');
    $console_writer = new \Zend\Log\Writer\Stream('php://output');
    $logger->addWriter($console_writer);
    return $logger;
}, 'Whathood\\Emailer' => function ($sm) {
    $config = $sm->get('Config');
    $emailer = new \Whathood\Model\Email($config['whathood']['log']['email']);
    return $emailer;
<?php

// module/Album/config/module.config.php:
//require_once ('vendor/spyc/spyc.php');
$reader = new Zend\Config\Reader\Yaml(array('Spyc', 'YAMLLoadString'));
$routesConfig = $reader->fromFile(__DIR__ . '/module.routes.yml');
return array('controllers' => array('invokables' => array('Documentation\\Controller\\Page' => 'Documentation\\Controller\\PageController')), 'router' => array('routes' => (array) $routesConfig), 'view_manager' => array('template_map' => array('layout/layout' => 'module/Application/view/layout/layout.phtml', 'application/index/index' => 'module/Application/view/application/index/index.phtml', 'error/404' => 'module/Application/view/error/404.phtml', 'error/index' => 'module/Application/view/error/index.phtml'), 'template_path_stack' => array('documentation' => __DIR__ . '/../../view')));
 public function loadConfig($path)
 {
     $this->getLogger()->info('Applying config from ' . $path);
     $configReader = new \Zend\Config\Reader\Yaml(['Symfony\\Component\\Yaml\\Yaml', 'parse']);
     $config = $configReader->fromFile($path);
     $this->config = $config;
     if (isset($config['deployment']) && isset($config['deployment']['hooks'])) {
         foreach ($config['deployment']['hooks'] as $eventname => $tasks) {
             foreach ($tasks as $task) {
                 if (!isset($task['task-runner'])) {
                     $runner = $this->getTaskRunnerManager()->get('command');
                 } else {
                     $runner = $this->getTaskRunnerManager()->get($task['task-runner']);
                 }
                 $hydrator = new ClassMethods();
                 $hydrator->hydrate($task, $runner);
                 $this->listeners[] = $this->getEventManager()->attach($eventname, [$runner, 'run']);
             }
         }
     }
 }