public function __construct() { // autoloader require_once sfConfig::get('app_ddgithub_path') . 'lib/vendor/github-api/AutoLoader.php'; Github_Autoloader::register(); $this->_git = new Github_Client(); }
protected function getUserRepositoryTags() { Loader::library("3rdparty/github3/Github/Autoloader", FRONTEND_DEVELOPER_PACKAGE_HANDLE); Github_Autoloader::register(); $tags = array(); $username = $this->getUserName(); if (!empty($username)) { $github = new Github_Client(); $api = $github->getRepoApi(); $tags = $api->getRepoTags($username, $this->repos); } return $tags; }
protected function getUserRepositories() { Loader::library("3rdparty/github3/Github/Autoloader", FRONTEND_DEVELOPER_PACKAGE_HANDLE); Github_Autoloader::register(); $username = $this->getUserName(); if (empty($username)) { return null; } $github = new Github_Client(); $api = $github->getRepoApi(); $repositories = $api->getUserRepos($username); $rows = array(); foreach ($repositories as $repos) { $key = $repos["name"]; $rows[$key] = $repos; } return $rows; }
<?php // 使用https://github.com/ornicar/php-github-api 作为Github客户端库 require_once dirname(__FILE__) . "/Github/Autoloader.php"; Github_Autoloader::register(); /** * 使用Github作为版本历史的后端 */ class GithubVersionManager { protected $user = NULL; protected $repos = NULL; protected $branch = NULL; protected $github = NULL; public function __construct($user, $repos, $branch) { $this->user = $user; $this->repos = $repos; $this->branch = $branch; $this->github = new Github_Client(); } public function getLastCommit($file) { $commits = $this->getRevisionHistories($file); return array_shift($commits); } public function getRevisionHistories($file) { return $this->github->getCommitApi()->getFileCommits($this->user, $this->repos, $this->branch, $file); } public function getRawDataByFile($file, $revision = 'HEAD')
public function init() { require_once DIR_BASE . 'lib/Github/Autoloader.php'; Github_Autoloader::register(); }
public function testAutoload() { $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Github'); $autoloader = new Github_Autoloader(); $this->assertNull($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class'); }
/** * Run the boot process, boot up our app. Call the relevant classes such as: * config, registry, session, dispatch, router. * * @return $this Fluent interface */ function boot() { error_reporting($this->_errorLevel); ini_set('display_errors', $this->_showErrors); // Fire up the default config handler if ($this->_config === null) { $this->_config = new PPI_Config('general.ini', array('block' => $this->_siteMode)); } $this->_config = $this->_config->getConfig(); $registry = PPI_Registry::getInstance(); // Set the config into the registry for quick read/write $registry->set('PPI_Config', $this->_config); // ------------- Initialise the session ----------------- if (!headers_sent()) { // Fire up the default session handler if ($this->_session === null) { $this->_session = new PPI_Session(); } $registry->set('PPI_Session', $this->_session); } // -------------- Library Autoloading Process -------------- if (!empty($this->_config->system->autoloadLibs)) { foreach (explode(',', $this->_config->system->autoloadLibs) as $sLib) { switch (strtolower(trim($sLib))) { case 'zf': PPI_Autoload::add('Zend', array('path' => SYSTEMPATH . 'Vendor/', 'prefix' => 'Zend_')); break; case 'github': $githubAutoloader = SYSTEMPATH . 'Vendor/Github/Autoloader.php'; if (!file_exists($githubAutoloader)) { throw new PPI_Exception('Unable to autoload github, the github autoloader was no found.'); } include_once SYSTEMPATH . 'Vendor/Github/Autoloader.php'; Github_Autoloader::register(); break; // @todo - test this. // @todo - test this. case 'swift': include_once SYSTEMPATH . 'Vendor/Swift/swift_required_pear.php'; break; /* case 'solar': PPI_Autoload::add('Solar', array( 'path' => SYSTEMPATH . 'Vendor/', 'prefix' => 'Solar_' )); Solar::start(); break; */ } } } $registry->set('PPI_App', $this); return $this; // Fluent Interface }