public function index02Action() { echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>"; $autoLoader = new \Zend\Loader\StandardAutoloader(array("autoregister_zf" => true, "namespaces" => array("Database" => LIB_PATH . "/Database", "Art" => LIB_PATH . "/Art"), "prefixes" => array("Mail" => LIB_PATH . "/Mail"))); $autoLoader->register(); $student = new \Database\Student(); $teacher = new \Database\Teacher(); $people = new \Database\basetada\People(); $sontung_m = new \Art\Singer(); $sender = new \Mail_Sender(); $google_sender = new \Mail_google_sender(); return false; }
public function __construct($options = array()) { // require autoloader $loader = new \Zend\Loader\StandardAutoloader(); $loader->register(); // this might look goofy, but this is setting up the // registry for dependency injection into the client $registry = new \Zend\Tool\Framework\Registry\FrameworkRegistry(); $registry->setClient($this); // NOTE: at this moment, $this->_registry should contain the registry object if ($options) { $this->setOptions($options); } }
public function indexAction() { /*$autloader = new \Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));*/ $autloader = new \Zend\Loader\StandardAutoloader(array('autoregister_zf' => true, 'namespaces' => array('Database' => LIBRARY_PATH . '/../../../Database'), 'prefixes' => array('Mail' => LIBRARY_PATH . '/../../../Mail'))); // $autloader->registerNamespace('Database', LIBRARY_PATH.'/../../../Database'); // $autloader->registerPrefix('Mail', LIBRARY_PATH.'/../../../Mail'); $autloader->register(); $student = new \Database\Student(); $teacher = new \Database\Teacher(); $worker = new \Database\Oracle\Worker(); $sender = new \Mail_Sender(); /** zf 1.x*/ $a_mail = new \Mail_Abc_A(); return false; }
public function checkEntities($force = false) { if (!is_dir($this->entityFolder . 'Entity') || $force) { $this->prepareFolder($force); $this->configure(); // custom datatypes (not mapped for reverse engineering) $this->em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string'); $this->em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); $driver = new RestDriver($this->em->getConnection()->getSchemaManager()); $driver->setNamespace($this->namespace); $driver->setBiDirecionalEntities(true); $this->em->getConfiguration()->setMetadataDriverImpl($driver); $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory($this->em); $cmf->setEntityManager($this->em); $metadata = $cmf->getAllMetadata(); $this->EntityGenerator($metadata); } $autoLoader = new \Zend\Loader\StandardAutoloader(array('namespaces' => array('Entity' => $this->entityFolder . DIRECTORY_SEPARATOR . $this->namespace), 'fallback_autoloader' => true)); $autoLoader->register(); }
/** * Constructor * * Initialize application. Potentially initializes include_paths, PHP * settings, and bootstrap class. * * @param string $environment * @param string|array|\Zend\Config\Config $options String path to configuration file, or array/\Zend\Config\Config of configuration options * @throws \Zend\Application\Exception When invalid options are provided * @return void */ public function __construct($environment, $options = null) { $this->_environment = (string) $environment; /** * @todo Make this configurable? */ require_once __DIR__ . '/../Loader/StandardAutoloader.php'; $autoloader = new \Zend\Loader\StandardAutoloader(); $autoloader->register(); $this->setAutoloader($autoloader); if (null !== $options) { if (is_string($options)) { $options = $this->_loadConfig($options); } elseif ($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException('Invalid options provided; must be location of config file, a config object, or an array'); } $this->setOptions($options); } }
if (false === (include $sStandardAutoloaderPath)) { throw new \RuntimeException('An error occurred while including file "' . $sStandardAutoloaderPath . '"'); } } else { if (!is_readable($sStandardAutoloaderPath = 'Zend/Loader/StandardAutoloader.php')) { throw new \InvalidArgumentException('StandardAutoloader file "' . $sStandardAutoloaderPath . '" is unreadable'); } if (false === (include $sStandardAutoloaderPath)) { throw new \RuntimeException('An error occurred while including file "' . $sStandardAutoloaderPath . '"'); } } if (!class_exists('Zend\\Loader\\StandardAutoloader')) { throw new \InvalidArgumentException('"' . $sStandardAutoloaderPath . '" does not provide "Zend\\Loader\\StandardAutoloader" class'); } //Setup autoloading $oAutoLoader = new \Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $oAutoLoader->register(); $oConsole = \Zend\Console\Console::getInstance(); } catch (\Exception $oException) { echo 'An error occured' . PHP_EOL; if ($bVerbose) { echo $oException . PHP_EOL; } exit(2); } try { $oGetopt = new \Zend\Console\Getopt(array('help|h' => 'Get usage message', 'module|m-s' => 'Module path to deploy; if none provided, assumes current directory', 'dir|d-s' => 'Directory path where to deploy the module (ex: apache/www/my-module), the directory could be created if needed', 'modules|a-s' => '(optionnal) Additionnal module namespaces (comma separated) to be used in the application', 'zapp|z-s' => '(optionnal) ZendSkeletonApplication file path, allows locale or remote directory, allows archive (Phar, Rar, Zip) depending on PHP installed libraries', 'composer|c-s' => '(optionnal) Composer.phar file path, allows locale or remote directory', 'overwrite|w' => 'Whether or not to overwrite existing deployed ZendSkeletonApplication', 'verbose|v' => 'Whether or not to display execution trace')); $oGetopt->parse(); $bVerbose = !!$oGetopt->getOption('verbose'); } catch (\Zend\Console\Exception\RuntimeException $oException) { $oConsole->writeLine($oException->getUsageMessage());
class educacion { /** * @return Universidad[] arrayOfLetters */ public function universidad() { $arreglo[] = array("cod_institucion" => '000001', "siglas" => 'UCV', "cod_carrera" => '006'); $arreglo[] = array("cod_institucion" => '000002', "siglas" => 'UCV', "cod_carrera" => '007'); $arreglo[] = array("cod_institucion" => '000003', "siglas" => 'UNEFA', "cod_carrera" => '008'); return $arreglo; } } /* load framework ZF2 */ set_include_path('/srv/www/io/ZendFramework-2.3.2/library'); require_once 'Zend/Loader/StandardAutoloader.php'; $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $loader->registerPrefix('Zend', '/srv/www/io/ZendFramework-2.3.2/library'); $loader->register(); /* class autodiscover and Zend\Soap\Server */ if (isset($_GET['wsdl'])) { $strategy = new Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex(); $server = new Zend\Soap\AutoDiscover($strategy); $server->setServiceName('WebServiceEducacion'); } else { $server = new Zend\Soap\Server(); } $uri = 'http://webservice.io/HelloWorld/server.php'; $server->setClass('educacion'); $server->setUri($uri); $server->handle();
<?php require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; $loader = new Zend\Loader\StandardAutoloader(); // Register the "Nel" namespace: $loader->registerNamespace('Nel', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'Nel'); // Register with spl_autoload: $loader->register();
<?php require_once __DIR__ . '/vendor/autoload.php'; $loader = new \Zend\Loader\StandardAutoloader(); $loader->registerNamespace('App', __DIR__ . '/App'); $loader->register();
protected function _init($env) { $profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION); $appConfigFileResource = $profile->search('applicationConfigFile'); if ($appConfigFileResource == false) { throw new \Zend\Tool\Project\Exception('A project with an application config file is required to use this provider.'); } $appConfigFilePath = $appConfigFileResource->getPath(); $this->_config = new \Zend\Config\Ini($appConfigFilePath, $env); require_once 'Zend/Loader/StandardAutoloader.php'; $autoloader = new \Zend\Loader\StandardAutoloader(); $autoloader->registerNamespace('Akrabat', realpath(__DIR__ . '/../')); $autoloader->register(); }
<?php ini_set('display_error', 1); date_default_timezone_set('Asia/Shanghai'); define('APPLICATION_PATH', dirname(__FILE__)); chdir(APPLICATION_PATH); define('CONFIG_PATH', APPLICATION_PATH . '/config/'); // Decline static file requests back to the PHP built-in webserver if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { return false; } // Composer autoloading $zf2Path = "/Users/liujin834/work/library/zf2-git/library"; $westdcCorePath = "/Users/liujin834/work/westdc/westdc-core/Westdc"; include $zf2Path . '/Zend/Loader/StandardAutoloader.php'; // Register Auto Loader $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true, 'namespaces' => array('Westdc' => $westdcCorePath), 'fallback_autoloader' => true)); // Register with spl_autoload: $loader->register();
/** * _runTool() - This is where the magic happens, dispatch Zend_Tool * * @return void */ protected function _runTool() { $configOptions = array(); if (isset($this->_configFile) && $this->_configFile) { $configOptions['configOptions']['configFilepath'] = $this->_configFile; } if (isset($this->_storageDirectory) && $this->_storageDirectory) { $configOptions['storageOptions']['directory'] = $this->_storageDirectory; } // ensure that zf.php loads the Zend_Tool_Project features $configOptions['classesToLoad'] = 'Zend\\Tool\\Project\\Provider\\Manifest'; $autoloader = new Zend\Loader\StandardAutoloader(); $autoloader->setFallbackAutoloader(true); $autoloader->register(); $console = new Zend\Tool\Framework\Client\Console\Console($configOptions); $console->dispatch(); return null; }
<?php require_once 'library/Zend/Loader/StandardAutoloader.php'; $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $loader->registerNamespace('SON', 'library/SON'); $loader->register(); $components = array('SON'); foreach ($components as $component) { $diCompiler = new Zend\Di\Definition\CompilerDefinition(); $diCompiler->addDirectory('library/' . $component); $diCompiler->compile(); file_put_contents('data/di/' . $component . '-definition.php', '<?php return ' . var_export($diCompiler->toArrayDefinition()->toArray(), true) . ';'); }
<?php namespace CB; use CB\DataModel as DM; $cron_id = 'check_core_email'; $execution_timeout = 60; //default is 60 seconds require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php'; $coreName = Config::get('core_name'); require_once 'Zend/Loader/StandardAutoloader.php'; require_once 'mail_functions.php'; /** DURING INSTANTIATION **/ $loader = new \Zend\Loader\StandardAutoloader(array('Zend' => ZEND_PATH . 'Zend')); /** AFTER INSTANTIATION **/ $loader = new \Zend\Loader\StandardAutoloader(); // the path can be absolute or relative below: $loader->registerNamespace('Zend', ZEND_PATH . 'Zend'); /** TO START AUTOLOADING */ $loader->register(); $mail_requirements = "\nMail requirements are:\n 1. Subject of email should contain target folder in the following format: <Message title> (/target/folder)\n 2. target folder should exist in the database.\n 3. Your email address should be specified in your casebox user profile.\n\n If at least one condition is not satisfied then the email would not be processed and is deleted automatically.\n"; // skip core if no email is set in config if (!defined('config\\mail_user')) { exit; } echo " (" . config\mail_user . ") ..."; $cd = prepareCron($cron_id, $execution_timeout); if (!$cd['success']) { echo "\nFailed to prepare cron\n"; exit; //skip this core if cron preparation fails
* - Configures Zend autoloading * - Load the configuration settings from config.ini.php * - Configures the Logger * - Configures the DB adapter * - Configures the Zend dependency injector */ /***************************************** * CONFIGURE AUTOLOADING *****************************************/ $sImporterPath = dirname(__FILE__); chdir($sImporterPath); $sScriptPath = substr($sImporterPath, 0, strrpos($sImporterPath, DIRECTORY_SEPARATOR)); $sIncludePath = $sImporterPath . PATH_SEPARATOR . $sScriptPath . PATH_SEPARATOR; set_include_path(get_include_path() . PATH_SEPARATOR . $sIncludePath); require 'Zend/Loader/StandardAutoloader.php'; $autoloader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $sImporterClassNameSpacePath = $sImporterPath . DIRECTORY_SEPARATOR . 'Classes'; $sInstallerNameSpacePath = $sScriptPath . DIRECTORY_SEPARATOR . 'installer' . DIRECTORY_SEPARATOR . 'Reports' . DIRECTORY_SEPARATOR; $autoloader->registerNamespace('Classes', $sImporterClassNameSpacePath, $sInstallerNameSpacePath); $autoloader->register(); /***************************************** * LOAD CONFIGURATION *****************************************/ $oConfig = new Zend\Config\Reader\Ini(); $oConfig->setNestSeparator(' : '); $aConfig = $oConfig->fromFile('config.ini.php'); // First attempt to load relevant section based on host name if (isset($_SERVER['HTTP_HOST'])) { $sServerHost = $_SERVER['HTTP_HOST']; foreach ($aConfig as $sSection => $aConfigSection) { if (isset($aConfigSection['common']) and isset($aConfigSection['common']['host'])) {
<?php // Set used namespaces use Zend\Locale\Locale; use Zend\Registry; use Zend\Service\LiveDocx\Helper; // Turn up error reporting error_reporting(E_ALL | E_STRICT); // Set up autoloader $base = dirname(dirname(dirname(dirname(__DIR__)))); require_once "{$base}/library/Zend/Loader/StandardAutoloader.php"; $loader = new \Zend\Loader\StandardAutoloader(); $loader->registerNamespace('Zend', "{$base}/library/Zend"); $loader->register(); // Include utility class require_once "{$base}/demos/Zend/Service/LiveDocx/library/Zend/Service/LiveDocx/Helper.php"; // Set default locale Locale::setDefault(Helper::LOCALE); $locale = new Locale(Locale::ZFDEFAULT); Registry::set('Zend_Locale', $locale); // Ensure LiveDocx credentials are available if (false === Helper::credentialsAvailable()) { Helper::printLine(Helper::credentialsHowTo()); exit; } unset($base);
<?php // autoloading from composer require_once dirname(__FILE__) . '/vendor/autoload.php'; $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $loader->registerNamespace('StefanTeitge\\Merville', 'src'); $loader->register(); use StefanTeitge\Merville\Merville; /* Daux.io ================== Description ----------- This is a tool for auto-generating documentation based on markdown files located in the /docs folder of the project. To see all of the available options and to read more about how to use the generator, visit: http://daux.io Author ------ Justin Walsh (Todaymade): justin@todaymade.com, @justin_walsh Garrett Moon (Todaymade): garrett@todaymade.com, @garrett_moon Stefan Teitge : stefan.teitge@gmail.com, @stefanteitge Feedback & Suggestions ---- To give us feedback or to suggest an idea, please create an request on the the GitHub issue tracker: https://github.com/stefanteitge/merville/issues Bugs ---- To file bug reports please create an issue using the github issue tracker: https://github.com/stefanteitge/merville/issues
<pre> <?php use Br\Gov\Filter\Acentuacao; define('DS', DIRECTORY_SEPARATOR); define('PS', PATH_SEPARATOR); set_include_path(get_include_path() . PS . '/home/brainfork/zend-framework/zf2/library'); require_once 'Zend' . DS . 'Loader' . DS . 'StandardAutoloader.php'; $autoloader = new Zend\Loader\StandardAutoloader(); $autoloader->register(); $autoloader->registerNamespace('Br', __DIR__ . DS . '../library' . DS . 'Br'); $a = new Acentuacao(); $f = $a->filter('Cinqüênta pássaros se vão e caçoam da àguia. Pão-de-ló e café!'); Zend\Debug::dump($f);
<?php set_include_path(get_include_path() . ':/Shared/ZF2rc03/library'); date_default_timezone_set('America/Los_Angeles'); require_once 'Zend/Loader/StandardAutoloader.php'; $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); $loader->registerNamespace('NedVisol', __DIR__ . '/../vendor/NedVisol/library/NedVisol'); $loader->registerNamespace('NedVisol\\Orm\\Definition', __DIR__ . '/../vendor/NedVisol/generated/NedVisol/Orm/Definition'); // Register with spl_autoload: $loader->register(); define('HBASE_THRIFT_HOST', 'hbase-thrift'); define('HBASE_THRIFT_PORT', '9090');
<?php use Zend\EventManager\EventManager; define('ZF2_PATH', getenv('ZF2_PATH') ? getenv('ZF2_PATH') : realpath(__DIR__ . '/library/Zend')); require_once ZF2_PATH . '/Loader/StandardAutoloader.php'; $autoLoader = new Zend\Loader\StandardAutoloader(); // register our StandardAutoloader with the SPL autoloader $autoLoader->register(); // register the Zend namespace $autoLoader->registerNamespace('Zend', ZF2_PATH); class ValidatePost { public function validate($event) { $data = $event->getParams(); if (!isset($data['title']) or !isset($data['slug'])) { throw new \InvalidArgumentException('Need a title and a slug!'); } return $data; } } class SlugifyPost { public function slugify($event) { $data = $event->getParams(); $event->setParam('slug', strtolower(str_replace(' ', '-', $data['title']))); return $data; } } class Post
<?php require_once __DIR__ . '/../../vendor/zendframework/zend-loader/Zend/Loader/StandardAutoloader.php'; $loader = new Zend\Loader\StandardAutoloader(); $loader->registerNamespace('Respect', __DIR__ . '/../../vendor/respect/validation/library/Respect'); $loader->registerNamespace('Symfony\\Component\\Validator', __DIR__ . '/../../vendor/symfony/validator/Symfony/Component/Validator'); $loader->registerNamespace('Symfony\\Component\\PropertyAccess', __DIR__ . '/../../vendor/symfony/property-access/Symfony/Component/PropertyAccess'); $loader->registerNamespace('Symfony\\Component\\Translation', __DIR__ . '/../../vendor/symfony/translation/Symfony/Component/Translation'); $loader->registerNamespace('HybridLogic', __DIR__ . '/../../vendor/hybridlogic/validation/src/HybridLogic'); $loader->registerNamespace('Fuel', __DIR__ . '/../../vendor/fuelphp/validation/src/Fuel'); $loader->registerNamespace('Zend\\Validator', __DIR__ . '/../../vendor/zendframework/zend-validator/Zend/Validator'); $loader->registerNamespace('Zend\\Stdlib', __DIR__ . '/../../vendor/zendframework/zend-stdlib/Zend/Stdlib'); $loader->registerNamespace('Kpacha\\ComponentBenchmark', __DIR__ . '/../../src/Kpacha/ComponentBenchmark'); $loader->registerNamespace('Kpacha\\BenchmarkTool', __DIR__ . '/../../vendor/kpacha/php-benchmark-tool/src/Kpacha/BenchmarkTool'); $loader->registerNamespace('Symfony\\Component\\Finder', __DIR__ . '/../../vendor/symfony/finder/Symfony/Component/Finder'); $loader->register(); include __DIR__ . '/common.php';
<?php /* set this path to the location of Zend/Loader/StandardAutoloader.php, * the client library can be used with any other php5.3 namespace style autoloaders (for example symfony2 & doctrine2) */ define('ZEND_AUTOLOADER_PATH', '/_path_/_to_/_zend_/_framework_/Zend/Loader/StandardAutoloader.php'); define('CONFIG_FILE', 'config.ini'); use Kaltura\Client\Configuration as KalturaConfiguration; use Kaltura\Client\Client as KalturaClient; use Kaltura\Client\Enum\SessionType as KalturaSessionType; use Kaltura\Client\ApiException; use Kaltura\Client\ClientException; // load zend framework 2 require_once ZEND_AUTOLOADER_PATH; $loader = new \Zend\Loader\StandardAutoloader(); // register Kaltura namespace $loader->registerNamespace('Kaltura', dirname(__FILE__) . '/../library/Kaltura'); $loader->registerNamespace('Test', dirname(__FILE__) . '/Test'); $loader->register(); $testerConfig = parse_ini_file(dirname(__FILE__) . '/' . CONFIG_FILE); if ($testerConfig['partnerId'] == 123) { die('Please edit the configuration file (config.ini)'); } // init kaltura configuration $config = new KalturaConfiguration($testerConfig['partnerId']); $config->setServiceUrl($testerConfig['serviceUrl']); $config->setCurlTimeout(30); $config->setLogger(new \Test\SampleLoggerImplementation()); // init kaltura client $client = new KalturaClient($config); // generate session
* published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * SOGoAccountsManager is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with SOGoAccountsManager. If not, see <http://www.gnu.org/licenses/>. */ set_include_path(ini_get('include_path') . PATH_SEPARATOR . dirname(dirname(__FILE__)) . '/library' . PATH_SEPARATOR . dirname(dirname(__FILE__)) . '/application'); require 'Slim/Slim.php'; \Slim\Slim::registerAutoloader(); require 'Zend/Loader/StandardAutoloader.php'; $zendAutoloader = new \Zend\Loader\StandardAutoloader(); $zendAutoloader->setFallbackAutoloader(true); $zendAutoloader->register(); $app = new \Slim\Slim(); $app->config(include 'config.php'); $app->add(new \Slim\Middleware\ContentTypes()); $app->add(new \SOGoAccountsManager\Middleware\SOGoSession()); $app->add(new \SOGoAccountsManager\Middleware\SOGoConfiguration()); $app->add(new \SOGoAccountsManager\Middleware\JsonExceptions()); $app->get('/checkAuth', function () use($app) { $className = '\\SOGoAccountsManager\\Authentication'; $auth = new $className($app); $auth->check(); }); // Accounts routes $app->get('/accounts', function () use($app) {
public static function get_instance() { if (self::$instance == null) { // Инициализируем автолоадер. Он ищет сначала в каталоге приложения, если класса нет и есть такой же с префиксом k_ в ядре, содает класс обертку с запрашиваемым именем и наследует ее от найденного в ядре класса spl_autoload_register(function ($class) { $is_zend = substr($class, 0, 5) == 'Zend\\'; if ($is_zend) { if (application::$zend_icluded) { return; } include_once PATH_ROOT . '/' . DIR_LIBRARY . '/lib/Zend/Loader/StandardAutoloader.php'; $loader = new Zend\Loader\StandardAutoloader(); $loader->registerNamespace('Zend', PATH_ROOT . '/' . DIR_LIBRARY . '/lib/Zend'); $loader->register(); if ($class !== 'Zend\\Loader\\StandardAutoloader') { $loader->autoload($class); } } else { $is_kernel = substr($class, 0, 2) == 'k_'; $fn = str_replace('_', '/', $is_kernel ? preg_replace('/^k\\_/', '', $class) : $class) . '.php'; if (!$is_kernel && file_exists(PATH_ROOT . '/' . DIR_APPLICATION . '/' . $fn)) { require_once PATH_ROOT . '/' . DIR_APPLICATION . '/' . $fn; } else { if (!$is_kernel && defined('DIR_ZLIBRARY') && file_exists(PATH_ROOT . '/' . DIR_ZLIBRARY . '/' . $fn)) { require_once PATH_ROOT . '/' . DIR_ZLIBRARY . '/' . $fn; } else { if (file_exists(PATH_ROOT . '/' . DIR_LIBRARY . '/' . $fn)) { require_once PATH_ROOT . '/' . DIR_LIBRARY . '/' . $fn; if (!$is_kernel && class_exists('k_' . $class)) { eval('class ' . $class . ' extends k_' . $class . ' {};'); } } else { if (class_exists('common') && method_exists('common', 'autoload')) { common::autoload($class); } } } } } }); // Экземпляр приложения создается не из текущего класса, а из класса, который находится в папке приложения application::$instance = new application(); } return application::$instance; }
/** * bootstrap modules */ protected function initModules() { // app $app = $this->app; // di container $container = $app->getContainer(); // navigation $navigation = array(); // view paths $viewModules = array(); // loader $loader = new \Zend\Loader\StandardAutoloader(); // for each module foreach ($this->modules as $module) { require_once $this->modulePath . '/' . $module . "/Module.php"; $m = "\\{$module}\\Module"; $m = new $m(); // autoloader if (method_exists($m, 'getAutoloaderConfig')) { $cfg = $m->getAutoloaderConfig(); // register module namespace foreach ($cfg as $key => $value) { $loader->registerNamespace($key, $value); } // register namespaces $loader->register(); } // routes if (method_exists($m, 'getRouterConfig')) { $cfg = $m->getRouterConfig(); // load routes foreach ($cfg as $value) { foreach (glob($value . "/*.php") as $filename) { require_once $filename; } } } // views if (method_exists($m, 'getViewConfig')) { $cfg = $m->getViewConfig(); // get view paths foreach ($cfg as $key => $value) { // get module view path // store path in app to register it with template engine $viewModules[$key] = $value; } } // navigation if (method_exists($m, 'getNavigationConfig')) { // get navigation config $cfg = $m->getNavigationConfig(); // merge navigation recursiv $navigation = array_merge_recursive($navigation, $cfg); } // middleware if (method_exists($m, 'getMiddlewareConfig')) { $cfg = $m->getMiddlewareConfig(); // load routes foreach ($cfg as $value) { foreach (glob($value . "/*.php") as $filename) { require_once $filename; } } } } // save view modules $container->viewModules = $viewModules; // save navigation $container->navigation = $navigation; }