當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Restaurant::suitableRestaurants方法代碼示例

本文整理匯總了PHP中Restaurant::suitableRestaurants方法的典型用法代碼示例。如果您正苦於以下問題:PHP Restaurant::suitableRestaurants方法的具體用法?PHP Restaurant::suitableRestaurants怎麽用?PHP Restaurant::suitableRestaurants使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Restaurant的用法示例。


在下文中一共展示了Restaurant::suitableRestaurants方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

// Register the monolog logging service
$app->register(new Silex\Provider\MonologServiceProvider(), array('monolog.logfile' => 'php://stderr'));
// Register view rendering
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// Register patch and delete http methods
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
$app->get('/', function () use($app) {
    return $app['twig']->render('index.html.twig');
    #, array('options' => Option::getAll()));
});
$app->post('/options', function () use($app) {
    $suitable_option_names = $_POST["option_names"];
    $suitable_option_ids = Option::getIdsFromNames($suitable_option_names);
    $options = Option::getObjects($suitable_option_ids);
    $suitable_restaurants = Restaurant::suitableRestaurants($suitable_option_ids);
    return $app['twig']->render('results.html.twig', array('suitable_restaurants' => $suitable_restaurants, 'options' => $options));
});
$app->get('/admin', function () use($app) {
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_restaurants', function () use($app) {
    $restaurant_name = new Restaurant($_POST['restaurant_name']);
    $restaurant_name->save();
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_options', function () use($app) {
    $option_name = new Option($_POST['option_name']);
    $option_name->save();
    return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
開發者ID:ben-pritchard,項目名稱:allergen_avoider,代碼行數:31,代碼來源:app.php

示例2: test_suitableRestaurants

 function test_suitableRestaurants()
 {
     // arrange
     $restaurant_name = "Taco Hell";
     $test_restaurant = new Restaurant($restaurant_name);
     $test_restaurant->save();
     $restaurant_name2 = "Burger Queen";
     $test_restaurant2 = new Restaurant($restaurant_name2);
     $test_restaurant2->save();
     $option_name = "Shellfish-free";
     $test_option = new Option($option_name);
     $test_option->save();
     $option_name2 = "Gasoline-free";
     $test_option2 = new Option($option_name2);
     $test_option2->save();
     $option_name3 = "Soy-free";
     $test_option3 = new Option($option_name3);
     $test_option3->save();
     // act
     $test_restaurant->addOption($test_option2);
     $test_restaurant->addOption($test_option3);
     $test_restaurant2->addOption($test_option);
     $test_restaurant2->addOption($test_option2);
     $test_restaurant2->addOption($test_option3);
     $option_ids = array();
     array_push($option_ids, $test_option->getId());
     array_push($option_ids, $test_option3->getId());
     $result = Restaurant::suitableRestaurants($option_ids);
     // assert
     $this->assertEquals([$test_restaurant2], $result);
 }
開發者ID:ben-pritchard,項目名稱:allergen_avoider,代碼行數:31,代碼來源:RestaurantTest.php


注:本文中的Restaurant::suitableRestaurants方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。