本文整理汇总了PHP中Step::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Step::find方法的具体用法?PHP Step::find怎么用?PHP Step::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Step
的用法示例。
在下文中一共展示了Step::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sizeof
$incomplete_steps_count = sizeof($project->getIncompleteSteps());
$complete_steps_count = $all_steps_count - $incomplete_steps_count;
$progress_percent = (int) ($complete_steps_count / $all_steps_count * 100);
} else {
// If there are no steps, then progress percent is definitely 0.
$progress_percent = 0;
}
// get next step should work here
return $app['twig']->render('coach/active_project/5complete.html.twig', array('project' => $project, 'step' => $project->getNextStep(), 'progress_percent' => $progress_percent));
});
// Duplicate for post, sent here if user checks that they have finished step
// on get page
$coach_active_project->post('/{id}/complete', function ($id) use($app) {
$project = Project::find($id);
// Pass step id to here through hidden form input
$step = Step::find($_POST['step_id']);
if (!empty($_POST['complete']) && $_POST['complete'] == 'true') {
$step->updateComplete(1);
} else {
$step->updateComplete(0);
}
// get percent complete on this project
$all_steps_count = sizeof($project->getSteps());
$incomplete_steps_count = sizeof($project->getIncompleteSteps());
$complete_steps_count = $all_steps_count - $incomplete_steps_count;
$progress_percent = (int) ($complete_steps_count / $all_steps_count * 100);
// If finishing this step completes the project, then update complete in project
// and re-direct on twig page to project complete page.
//if length of project get incomplete steps = 0 then update complete true
if ($incomplete_steps_count == 0) {
$project->updateComplete(1);
示例2: test_find
function test_find()
{
//Arrange
$description = "Buy book on learning French";
$project_id = 1;
$position = 1;
$test_step = new Step($description, $project_id, $position);
$test_step->save();
$description2 = "Buy French bread";
$project_id2 = 1;
$position2 = 2;
$test_step2 = new Step($description2, $project_id2, $position2);
$test_step2->save();
//Act
$result = Step::find($test_step2->getId());
//Assert
$this->assertEquals($test_step2, $result);
}
示例3: function
/* 6. Add due date from previous page.
** Give user option to edit the project as they have entered it. */
$coach_new_project->post('/{id}/update', function ($id) use($app) {
$project = Project::find($id);
$project->updateDueDate($_POST['due_date']);
return $app['twig']->render('coach/new_project/6update.html.twig', array('project' => $project, 'steps' => $project->getSteps()));
});
// Get route to update step positions from JS values
// Disable for now b/c update button goes to finished
// $coach_new_project->get('/{id}/update', function($id) use ($app) {
// $project = Project::find($id);
//
// return $app['twig']->render('coach/new_project/6update.html.twig', array(
// 'project' => $project,
// 'steps' => $project->getSteps()
// ));
// });
/* 7. If anything was edited, update it here.
** Display congratulations, redirect to dashboard. */
$coach_new_project->get('/{id}/finished', function ($id) use($app) {
$project = Project::find($id);
// logic to do updating here
// Get updated step position values from JS
foreach ($_GET as $step_id => $new_position) {
$step = Step::find($step_id);
$step->updatePosition($new_position);
}
return $app['twig']->render('coach/new_project/7finished.html.twig', array('project' => $project, 'steps' => $project->getSteps()));
});
// Place all urls in this file at /coach/new_project/*
$app->mount('/coach/new_project', $coach_new_project);