当前位置: 首页>>代码示例>>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;未经允许,请勿转载。