本文整理汇总了PHP中b8\Store\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: startWorker
/**
* Start the worker.
*/
public function startWorker()
{
$this->pheanstalk->watch($this->queue);
$this->pheanstalk->ignore('default');
$buildStore = Factory::getStore('Build');
while ($this->run) {
// Get a job from the queue:
$job = $this->pheanstalk->reserve();
$this->checkJobLimit();
// Get the job data and run the job:
$jobData = json_decode($job->getData(), true);
if (!$this->verifyJob($job, $jobData)) {
continue;
}
$this->logger->addInfo('Received build #' . $jobData['build_id'] . ' from Beanstalkd');
// If the job comes with config data, reset our config and database connections
// and then make sure we kill the worker afterwards:
if (!empty($jobData['config'])) {
$this->logger->addDebug('Using job-specific config.');
$currentConfig = Config::getInstance()->getArray();
$config = new Config($jobData['config']);
Database::reset($config);
}
try {
$build = BuildFactory::getBuildById($jobData['build_id']);
} catch (\Exception $ex) {
$this->logger->addWarning('Build #' . $jobData['build_id'] . ' does not exist in the database.');
$this->pheanstalk->delete($job);
}
try {
// Logging relevant to this build should be stored
// against the build itself.
$buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
$this->logger->pushHandler($buildDbLog);
$builder = new Builder($build, $this->logger);
$builder->execute();
// After execution we no longer want to record the information
// back to this specific build so the handler should be removed.
$this->logger->popHandler($buildDbLog);
} catch (\PDOException $ex) {
// If we've caught a PDO Exception, it is probably not the fault of the build, but of a failed
// connection or similar. Release the job and kill the worker.
$this->run = false;
$this->pheanstalk->release($job);
} catch (\Exception $ex) {
$build->setStatus(Build::STATUS_FAILED);
$build->setFinished(new \DateTime());
$build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
$buildStore->save($build);
$build->sendStatusPostback();
}
// Reset the config back to how it was prior to running this job:
if (!empty($currentConfig)) {
$config = new Config($currentConfig);
Database::reset($config);
}
// Delete the job when we're done:
$this->pheanstalk->delete($job);
}
}
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:63,代码来源:BuildWorker.php
示例2: init
/**
* Initialise the controller, set up stores and services.
*/
public function init()
{
$this->buildStore = Store\Factory::getStore('Build');
$this->projectStore = Store\Factory::getStore('Project');
$this->projectService = new ProjectService($this->projectStore);
$this->buildService = new BuildService($this->buildStore);
}
开发者ID:nelsonyang0710,项目名称:PHPCI,代码行数:10,代码来源:ProjectController.php
示例3: execute
/**
* Creates an admin user in the existing PHPCI database
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
require PHPCI_DIR . 'bootstrap.php';
// Try to create a user account:
$adminEmail = $this->ask('Admin email address: ', true, FILTER_VALIDATE_EMAIL);
if (empty($adminEmail)) {
return;
}
$adminPass = $this->ask('Admin password: ');
$adminName = $this->ask('Admin name: ');
try {
$user = new \PHPCI\Model\User();
$user->setEmail($adminEmail);
$user->setName($adminName);
$user->setIsAdmin(1);
$user->setHash(password_hash($adminPass, PASSWORD_DEFAULT));
$store = \b8\Store\Factory::getStore('User');
$store->save($user);
print 'User account created!' . PHP_EOL;
} catch (\Exception $ex) {
print 'There was a problem creating your account. :(' . PHP_EOL;
print $ex->getMessage();
print PHP_EOL;
}
}
开发者ID:bztrn,项目名称:PHPCI,代码行数:28,代码来源:CreateAdminCommand.php
示例4: change
public function change()
{
$count = 100;
$this->metaStore = \b8\Store\Factory::getStore('BuildMeta');
$this->errorStore = \b8\Store\Factory::getStore('BuildError');
while ($count == 100) {
$data = $this->metaStore->getErrorsForUpgrade(100);
$count = count($data);
/** @var \PHPCI\Model\BuildMeta $meta */
foreach ($data as $meta) {
try {
switch ($meta->getMetaKey()) {
case 'phpmd-data':
$this->processPhpMdMeta($meta);
break;
case 'phpcs-data':
$this->processPhpCsMeta($meta);
break;
case 'phpdoccheck-data':
$this->processPhpDocCheckMeta($meta);
break;
case 'phpcpd-data':
$this->processPhpCpdMeta($meta);
break;
case 'technicaldebt-data':
$this->processTechnicalDebtMeta($meta);
break;
}
} catch (\Exception $ex) {
}
$this->metaStore->delete($meta);
}
}
}
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:34,代码来源:20151015124825_convert_errors.php
示例5: getBuildById
/**
* @param $buildId
* @return Build
* @throws \Exception
*/
public static function getBuildById($buildId)
{
$build = Factory::getStore('Build')->getById($buildId);
if (empty($build)) {
throw new \Exception('Build ID ' . $buildId . ' does not exist.');
}
return self::getBuild($build);
}
开发者ID:mrudtf,项目名称:PHPCI,代码行数:13,代码来源:BuildFactory.php
示例6: get
/**
* @param string $store Name of the store you want to load.
* @return \b8\Store
*/
public static function get($store)
{
$namespace = self::getModelNamespace($store);
if (!is_null($namespace)) {
return Factory::getStore($store, $namespace);
}
return null;
}
开发者ID:dw250100785,项目名称:Octo,代码行数:12,代码来源:Store.php
示例7: write
protected function write(array $record)
{
$message = (string) $record['message'];
$message = str_replace($this->build->currentBuildPath, '/', $message);
$this->logValue .= $message . PHP_EOL;
$this->build->setLog($this->logValue);
Factory::getStore('Build')->save($this->build);
}
开发者ID:kukupigs,项目名称:PHPCI,代码行数:8,代码来源:BuildDBLogHandler.php
示例8: execute
/**
* Loops through running.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$runner = new RunCommand($this->logger);
$runner->setMaxBuilds(1);
$runner->setDaemon(false);
/** @var \PHPCI\Store\BuildStore $store */
$store = Factory::getStore('Build');
$service = new BuildService($store);
$lastBuild = array_shift($store->getLatestBuilds(null, 1));
$service->createDuplicateBuild($lastBuild);
$runner->run(new ArgvInput(array()), $output);
}
开发者ID:stefanius,项目名称:phpci-box,代码行数:15,代码来源:RebuildCommand.php
示例9: getPreviousBuild
/**
* Return the previous build from a specific branch, for this project.
* @param string $branch
* @return mixed|null
*/
public function getPreviousBuild($branch = 'master')
{
$criteria = array('branch' => $branch, 'project_id' => $this->getId());
$order = array('id' => 'DESC');
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 1, array(), $order);
if (is_array($builds['items']) && count($builds['items'])) {
$previous = array_shift($builds['items']);
if (isset($previous) && $previous instanceof Build) {
return $previous;
}
}
return null;
}
开发者ID:bdanchilla,项目名称:PHPCI,代码行数:18,代码来源:Project.php
示例10: index
/**
* List project groups.
*/
public function index()
{
$this->requireAdmin();
$groups = array();
$groupList = $this->groupStore->getWhere(array(), 100, 0, array(), array('title' => 'ASC'));
foreach ($groupList['items'] as $group) {
$thisGroup = array('title' => $group->getTitle(), 'id' => $group->getId());
$projects = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId());
$thisGroup['projects'] = $projects['items'];
$groups[] = $thisGroup;
}
$this->view->groups = $groups;
}
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:16,代码来源:GroupController.php
示例11: change
public function change()
{
$table = $this->table('project_group');
$table->addColumn('title', 'string', array('limit' => 100, 'null' => false));
$table->save();
$group = new \PHPCI\Model\ProjectGroup();
$group->setTitle('Projects');
/** @var \PHPCI\Model\ProjectGroup $group */
$group = \b8\Store\Factory::getStore('ProjectGroup')->save($group);
$table = $this->table('project');
$table->addColumn('group_id', 'integer', array('signed' => true, 'null' => false, 'default' => $group->getId()));
$table->addForeignKey('group_id', 'project_group', 'id', array('delete' => 'RESTRICT', 'update' => 'CASCADE'));
$table->save();
}
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:14,代码来源:20151008140800_add_project_groups.php
示例12: getLatestBuild
public function getLatestBuild($branch = 'master', $status = null)
{
$criteria = array('branch' => $branch, 'project_id' => $this->getId());
if (isset($status)) {
$criteria['status'] = $status;
}
$order = array('id' => 'DESC');
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 0, array(), $order);
if (is_array($builds['items']) && count($builds['items'])) {
$latest = array_shift($builds['items']);
if (isset($latest) && $latest instanceof Build) {
return $latest;
}
}
return null;
}
开发者ID:bztrn,项目名称:PHPCI,代码行数:16,代码来源:Project.php
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
// For verbose mode we want to output all informational and above
// messages to the symphony output interface.
if ($input->hasOption('verbose') && $input->getOption('verbose')) {
$this->logger->pushHandler(new OutputLogHandler($this->output, Logger::INFO));
}
$store = Factory::getStore('Build');
$result = $store->getByStatus(0);
$this->logger->addInfo(Lang::get('found_n_builds', count($result['items'])));
$buildService = new BuildService($store);
while (count($result['items'])) {
$build = array_shift($result['items']);
$build = BuildFactory::getBuild($build);
$this->logger->addInfo('Added build #' . $build->getId() . ' to queue.');
$buildService->addBuildToQueue($build);
}
}
开发者ID:DavidGarciaCat,项目名称:PHPCI,代码行数:19,代码来源:RebuildQueueCommand.php
示例14: execute
/**
* Pulls all pending builds from the database and runs them.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$parser = new Parser();
$yaml = file_get_contents(APPLICATION_PATH . 'PHPCI/config.yml');
$this->settings = $parser->parse($yaml);
$token = $this->settings['phpci']['github']['token'];
if (!$token) {
$this->logger->error(Lang::get('no_token'));
return;
}
$buildStore = Factory::getStore('Build');
$this->logger->addInfo(Lang::get('finding_projects'));
$projectStore = Factory::getStore('Project');
$result = $projectStore->getWhere();
$this->logger->addInfo(Lang::get('found_n_projects', count($result['items'])));
foreach ($result['items'] as $project) {
$http = new HttpClient('https://api.github.com');
$commits = $http->get('/repos/' . $project->getReference() . '/commits', array('access_token' => $token));
$last_commit = $commits['body'][0]['sha'];
$last_committer = $commits['body'][0]['commit']['committer']['email'];
$message = $commits['body'][0]['commit']['message'];
$this->logger->info(Lang::get('last_commit_is', $project->getTitle(), $last_commit));
if ($project->getLastCommit() != $last_commit && $last_commit != "") {
$this->logger->info(Lang::get('adding_new_build'));
$build = new Build();
$build->setProjectId($project->getId());
$build->setCommitId($last_commit);
$build->setStatus(Build::STATUS_NEW);
$build->setBranch($project->getBranch());
$build->setCreated(new \DateTime());
$build->setCommitMessage($message);
if (!empty($last_committer)) {
$build->setCommitterEmail($last_committer);
}
$buildStore->save($build);
$project->setLastCommit($last_commit);
$projectStore->save($project);
}
}
$this->logger->addInfo(Lang::get('finished_processing_builds'));
}
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:44,代码来源:PollCommand.php
示例15: execute
/**
* Creates an admin user in the existing PHPCI database
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$userStore = Factory::getStore('User');
$userService = new UserService($userStore);
require PHPCI_DIR . 'bootstrap.php';
// Try to create a user account:
$adminEmail = $this->ask('Admin email address: ', true, FILTER_VALIDATE_EMAIL);
if (empty($adminEmail)) {
return;
}
$adminPass = $this->ask('Admin password: ');
$adminName = $this->ask('Admin name: ');
try {
$userService->createUser($adminName, $adminEmail, $adminPass, 1);
print 'User account created!' . PHP_EOL;
} catch (\Exception $ex) {
print 'There was a problem creating your account. :(' . PHP_EOL;
print $ex->getMessage();
print PHP_EOL;
}
}
开发者ID:kukupigs,项目名称:PHPCI,代码行数:24,代码来源:CreateAdminCommand.php
示例16: execute
/**
* Creates an admin user in the existing PHPCI database
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$userStore = Factory::getStore('User');
$userService = new UserService($userStore);
require PHPCI_DIR . 'bootstrap.php';
// Try to create a user account:
$adminEmail = $this->ask(Lang::get('enter_email'), true, FILTER_VALIDATE_EMAIL);
if (empty($adminEmail)) {
return;
}
$adminPass = $this->ask(Lang::get('enter_pass'));
$adminName = $this->ask(Lang::get('enter_name'));
try {
$userService->createUser($adminName, $adminEmail, $adminPass, 1);
print Lang::get('user_created') . PHP_EOL;
} catch (\Exception $ex) {
print Lang::get('failed_to_create') . PHP_EOL;
print $ex->getMessage();
print PHP_EOL;
}
}
开发者ID:mrudtf,项目名称:PHPCI,代码行数:24,代码来源:CreateAdminCommand.php
示例17: execute
/**
* Pulls all pending builds from the database and runs them.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$parser = new Parser();
$yaml = file_get_contents(APPLICATION_PATH . 'PHPCI/config.yml');
$this->settings = $parser->parse($yaml);
$token = $this->settings['phpci']['github']['token'];
if (!$token) {
$this->logger->error("No github token found");
exit;
}
$buildStore = Factory::getStore('Build');
$this->logger->addInfo("Finding projects to poll");
$projectStore = Factory::getStore('Project');
$result = $projectStore->getWhere();
$this->logger->addInfo(sprintf("Found %d projects", count($result['items'])));
foreach ($result['items'] as $project) {
$http = new HttpClient('https://api.github.com');
$commits = $http->get('/repos/' . $project->getReference() . '/commits', array('access_token' => $token));
$last_commit = $commits['body'][0]['sha'];
$last_committer = $commits['body'][0]['commit']['committer']['email'];
$this->logger->info("Last commit to github for " . $project->getTitle() . " is " . $last_commit);
if ($project->getLastCommit() != $last_commit && $last_commit != "") {
$this->logger->info("Last commit is different from database, adding new build for " . $project->getTitle());
$build = new Build();
$build->setProjectId($project->getId());
$build->setCommitId($last_commit);
$build->setStatus(Build::STATUS_NEW);
$build->setBranch($project->getBranch());
$build->setCreated(new \DateTime());
if (!empty($last_committer)) {
$build->setCommitterEmail($last_committer);
}
$buildStore->save($build);
$project->setLastCommit($last_commit);
$projectStore->save($project);
}
}
$this->logger->addInfo("Finished processing builds");
}
开发者ID:kukupigs,项目名称:PHPCI,代码行数:42,代码来源:PollCommand.php
示例18: execute
/**
* Pulls all pending builds from the database and runs them.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
// For verbose mode we want to output all informational and above
// messages to the symphony output interface.
if ($input->hasOption('verbose')) {
$this->logger->pushHandler(new OutputLogHandler($this->output, Logger::INFO));
}
$this->logger->pushProcessor(new LoggedBuildContextTidier());
$this->logger->addInfo("Finding builds to process");
$store = Factory::getStore('Build');
$result = $store->getByStatus(0, $this->maxBuilds);
$this->logger->addInfo(sprintf("Found %d builds", count($result['items'])));
$builds = 0;
foreach ($result['items'] as $build) {
$builds++;
$build = BuildFactory::getBuild($build);
try {
// Logging relevant to this build should be stored
// against the build itself.
$buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
$this->logger->pushHandler($buildDbLog);
$builder = new Builder($build, $this->logger);
$builder->execute();
// After execution we no longer want to record the information
// back to this specific build so the handler should be removed.
$this->logger->popHandler($buildDbLog);
} catch (\Exception $ex) {
$build->setStatus(Build::STATUS_FAILED);
$build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
$store->save($build);
}
}
$this->logger->addInfo("Finished processing builds");
return $builds;
}
开发者ID:kukupigs,项目名称:PHPCI,代码行数:39,代码来源:RunCommand.php
示例19: init
public function init()
{
$request =& $this->request;
$route = '/:controller/:action';
$opts = array('controller' => 'Home', 'action' => 'index');
// Inlined as a closure to fix "using $this when not in object context" on 5.3
$validateSession = function () {
if (!empty($_SESSION['user_id'])) {
$user = b8\Store\Factory::getStore('User')->getByPrimaryKey($_SESSION['user_id']);
if ($user) {
$_SESSION['user'] = $user;
return true;
}
unset($_SESSION['user_id']);
}
return false;
};
// Handler for the route we're about to register, checks for a valid session where necessary:
$routeHandler = function (&$route, Response &$response) use(&$request, $validateSession) {
$skipValidation = in_array($route['controller'], array('session', 'webhook', 'build-status'));
if (!$skipValidation && !$validateSession()) {
if ($request->isAjax()) {
$response->setResponseCode(401);
$response->setContent('');
} else {
$_SESSION['login_redirect'] = substr($request->getPath(), 1);
$response = new RedirectResponse($response);
$response->setHeader('Location', PHPCI_URL . 'session/login');
}
return false;
}
return true;
};
$this->router->clearRoutes();
$this->router->register($route, $opts, $routeHandler);
}
开发者ID:kukupigs,项目名称:PHPCI,代码行数:36,代码来源:Application.php
示例20: init
public function init()
{
$this->response->disableLayout();
$this->userStore = b8\Store\Factory::getStore('User');
}
开发者ID:kukupigs,项目名称:PHPCI,代码行数:5,代码来源:SessionController.php
注:本文中的b8\Store\Factory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论