Permalink
Browse files

Initial commit

- Basic project structure
  • Loading branch information...
0 parents commit 9ceccb77c32b4199091697bdfaac742a1dfaa251 @weierophinney weierophinney committed Oct 10, 2012
@@ -0,0 +1,7 @@
+.buildpath
+.project
+.settings/
+.DS_Store
+.*.sw*
+.*.un~
+.vimproject
@@ -0,0 +1,25 @@
+<?php
+
+namespace PhlyPaste;
+
+class Module
+{
+ public function getAutoloaderConfig()
+ {
+ return array(
+ 'Zend\Loader\ClassMapAutoloader' => array(
+ __DIR__ . '/autoload_classmap.php',
+ ),
+ 'Zend\Loader\StandardAutoloader' => array(
+ 'namespaces' => array(
+ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
+ ),
+ ),
+ );
+ }
+
+ public function getConfig()
+ {
+ return include __DIR__ . '/config/module.config.php';
+ }
+}
@@ -0,0 +1,4 @@
+PhlyPaste - ZF2 Pastebin Module
+===============================
+
+This is a module implementing a ZF2 pastebin.
@@ -0,0 +1,7 @@
+<?php
+// Generated by ZF2's ./bin/classmap_generator.php
+return array(
+ 'PhlyPaste\Module' => __DIR__ . '/Module.php',
+ 'PhlyPaste\Controller\PasteController' => __DIR__ . '/src/PhlyPaste/Controller/PasteController.php',
+ 'PhlyPasteTest\Bootstrap' => __DIR__ . '/test/Bootstrap.php',
+);
@@ -0,0 +1,12 @@
+<?php
+return function ($class) {
+ static $map;
+ if (!$map) {
+ $map = include __DIR__ . '/autoload_classmap.php';
+ }
+
+ if (!isset($map[$class])) {
+ return false;
+ }
+ return include $map[$class];
+};
@@ -0,0 +1,2 @@
+<?php
+spl_autoload_register(include __DIR__ . '/autoload_function.php');
@@ -0,0 +1,52 @@
+<?php
+return array(
+ 'controllers' => array(
+ 'invokables' => array(
+ 'PhlyPaste\Controller\Paste' => 'PhlyPaste\Controller\PasteController',
+ ),
+ ),
+ 'router' => array(
+ 'routes' => array(
+ 'phly-paste' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => '/pastes[/]',
+ 'defaults' => array(
+ '__NAMESPACE__' => 'PhlyPaste\Controller',
+ 'controller' => 'Paste',
+ 'action' => 'index',
+ ),
+ ),
+ 'may_terminate' => true,
+ 'child_routes' => array(
+ 'process' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => 'process',
+ 'defaults' => array(
+ 'action' => 'process',
+ ),
+ ),
+ ),
+ 'show' => array(
+ 'type' => 'Segment',
+ 'options' => array(
+ 'route' => ':paste',
+ 'constraints' => array(
+ 'paste' => '[a-f0-9]{8}',
+ ),
+ 'defaults' => array(
+ 'action' => 'show',
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ 'view_manager' => array(
+ 'template_path_stack' => array(
+ 'PhlyPaste' => __DIR__ . '/../view',
+ ),
+ ),
+);
@@ -0,0 +1,12 @@
+<?php
+
+namespace PhlyPaste\Controller;
+
+use Zend\Mvc\Controller\AbstractActionController;
+
+class PasteController extends AbstractActionController
+{
+ public function indexAction()
+ {
+ }
+}
@@ -0,0 +1,101 @@
+<?php
+namespace PhlyPasteTest;
+
+use Zend\Loader\AutoloaderFactory;
+use Zend\Mvc\Service\ServiceManagerConfig;
+use Zend\ServiceManager\ServiceManager;
+use Zend\Stdlib\ArrayUtils;
+use RuntimeException;
+
+error_reporting(E_ALL | E_STRICT);
+chdir(__DIR__);
+
+class Bootstrap
+{
+ protected static $serviceManager;
+
+ public static function init()
+ {
+ // Load the user-defined test configuration file, if it exists; otherwise, load
+ if (is_readable(__DIR__ . '/TestConfig.php')) {
+ $testConfig = include __DIR__ . '/TestConfig.php';
+ } else {
+ $testConfig = include __DIR__ . '/TestConfig.php.dist';
+ }
+
+ $zf2ModulePaths = array(dirname(dirname(__DIR__)));
+ if (($path = static::findParentPath('vendor'))) {
+ $zf2ModulePaths[] = $path;
+ }
+ if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) {
+ $zf2ModulePaths[] = $path;
+ }
+
+ $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
+ $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
+
+ static::initAutoloader();
+
+ // use ModuleManager to load this module and it's dependencies
+ $baseConfig = array(
+ 'module_listener_options' => array(
+ 'module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths),
+ ),
+ );
+
+ $config = ArrayUtils::merge($baseConfig, $testConfig);
+
+ $serviceManager = new ServiceManager(new ServiceManagerConfig());
+ $serviceManager->setService('ApplicationConfig', $config);
+ $serviceManager->get('ModuleManager')->loadModules();
+ static::$serviceManager = $serviceManager;
+ }
+
+ public static function getServiceManager()
+ {
+ return static::$serviceManager;
+ }
+
+ protected static function initAutoloader()
+ {
+ $vendorPath = static::findParentPath('vendor');
+
+ if (is_readable($vendorPath . '/autoload.php')) {
+ $loader = include $vendorPath . '/autoload.php';
+ }
+
+ $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false));
+
+ if (!$zf2Path) {
+ throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
+ }
+
+ if (isset($loader)) {
+ $loader->add('Zend', $zf2Path . '/Zend');
+ } else {
+ include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
+ AutoloaderFactory::factory(array(
+ 'Zend\Loader\StandardAutoloader' => array(
+ 'autoregister_zf' => true,
+ 'namespaces' => array(
+ __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__,
+ ),
+ ),
+ ));
+ }
+ }
+
+ protected static function findParentPath($path)
+ {
+ $dir = __DIR__;
+ $previousDir = '.';
+ while (!is_dir($dir . '/' . $path)) {
+ $dir = dirname($dir);
+ if ($previousDir === $dir) return false;
+ $previousDir = $dir;
+ }
+ return $dir . '/' . $path;
+ }
+}
+
+Bootstrap::init();
No changes.
@@ -0,0 +1,8 @@
+<?php
+define('ZF2_PATH', getenv('HOME') . '/workspace/zf2/library');
+
+return array(
+ 'modules' => array(
+ 'PhlyPaste',
+ ),
+);
@@ -0,0 +1,7 @@
+<phpunit bootstrap="./Bootstrap.php" colors="true">
+ <testsuites>
+ <testsuite name="PhlyPaste Module Tests">
+ <directory>./PhlyPasteTest</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>
@@ -0,0 +1,3 @@
+<strong>Module:</strong> PhlyPaste &raquo;
+<strong>Controller:</strong> Skeleton &raquo;
+<strong>Action:</strong> index

0 comments on commit 9ceccb7

Please sign in to comment.