本文整理汇总了PHP中Silex\Application::match方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::match方法的具体用法?PHP Application::match怎么用?PHP Application::match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::match方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(BaseApplication $app)
{
// リポジトリ
$app['eccube.plugin.product_rank.repository.product_rank'] = $app->share(function () use($app) {
return new ProductRankRepository($app['orm.em'], $app['orm.em']->getClassMetadata('\\Eccube\\Entity\\ProductCategory'), $app);
});
$basePath = '/' . $app["config"]["admin_route"];
// 一覧
$app->match($basePath . '/product/product_rank/', '\\Plugin\\ProductRank\\Controller\\ProductRankController::index')->bind('admin_product_product_rank');
// 一覧:上
$app->put($basePath . '/product/product_rank/{category_id}/{product_id}/up', '\\Plugin\\ProductRank\\Controller\\ProductRankController::up')->assert('category_id', '\\d+')->assert('product_id', '\\d+')->bind('admin_product_product_rank_up');
// 一覧:下
$app->put($basePath . '/product/product_rank/{category_id}/{product_id}/down', '\\Plugin\\ProductRank\\Controller\\ProductRankController::down')->assert('category_id', '\\d+')->assert('product_id', '\\d+')->bind('admin_product_product_rank_down');
// 一覧:N番目へ移動
$app->post($basePath . '/product/product_rank/moveRank', '\\Plugin\\ProductRank\\Controller\\ProductRankController::moveRank')->assert('category_id', '\\d+')->assert('product_id', '\\d+')->assert('position', '\\d+')->bind('admin_product_product_rank_move_rank');
// カテゴリ選択
$app->match($basePath . '/product/product_rank/{category_id}', '\\Plugin\\ProductRank\\Controller\\ProductRankController::index')->assert('category_id', '\\d+')->bind('admin_product_product_rank_show');
// メッセージ登録
$app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
$file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
if (file_exists($file)) {
$translator->addResource('yaml', $file, $app['locale']);
}
return $translator;
}));
// メニュー登録
$app['config'] = $app->share($app->extend('config', function ($config) {
$addNavi['id'] = "product_rank";
$addNavi['name'] = "商品並び替え";
$addNavi['url'] = "admin_product_product_rank";
self::addNavi($config['nav'], $addNavi, array('product'));
return $config;
}));
}
示例2: setup
public function setup()
{
$this->app = new Application();
$this->app->match("/", function () {
return new Response();
});
}
示例3: register
public function register(BaseApplication $app)
{
// Routingを追加
$admin = $app['config']['admin_route'];
$app->match($admin . '/sales_report', '\\Plugin\\SalesReport\\Controller\\SalesReportController::index')->bind('admin_sales_report');
$app->match($admin . '/sales_report/term', '\\Plugin\\SalesReport\\Controller\\SalesReportController::term')->bind('admin_sales_report_term');
$app->match($admin . '/sales_report/member', '\\Plugin\\SalesReport\\Controller\\SalesReportController::member')->bind('admin_sales_report_member');
$app->match($admin . '/sales_report/age', '\\Plugin\\SalesReport\\Controller\\SalesReportController::age')->bind('admin_sales_report_age');
$app->match($admin . '/sales_report/product', '\\Plugin\\SalesReport\\Controller\\SalesReportController::product')->bind('admin_sales_report_product');
// Formの定義
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
$types[] = new \Plugin\SalesReport\Form\Type\SalesReportType();
return $types;
}));
// Serviceの定義
$app['eccube.plugin.service.sales_report'] = $app->share(function () use($app) {
return new \Plugin\SalesReport\Service\SalesReportService($app);
});
// サブナビの拡張
$app['config'] = $app->share($app->extend('config', function ($config) {
$nav = array('id' => 'admin_sales_report', 'name' => '売上集計', 'has_child' => 'true', 'icon' => 'cb-chart', 'child' => array(array('id' => 'admin_sales_report', 'url' => 'admin_sales_report', 'name' => '期間別集計'), array('id' => 'admin_sales_report_product', 'url' => 'admin_sales_report_product', 'name' => '商品別集計'), array('id' => 'admin_sales_report_age', 'url' => 'admin_sales_report_age', 'name' => '年代別集計')));
$config['nav'][] = $nav;
return $config;
}));
}
示例4: connect
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$app->match('/', 'Silex\\Controller\\StatsdController::indexAction')->bind('index');
$app->match('/sample', 'Silex\\Controller\\StatsdController::sampleAction')->bind('sample');
return $controllers;
}
示例5: register
public function register(BaseApplication $app)
{
$app->match('/' . $app['config']['admin_route'] . '/plugin/FreeeLight/config', 'Plugin\\FreeeLight\\Controller\\ConfigController::index')->bind('plugin_FreeeLight_config');
$app->match('/' . $app['config']['admin_route'] . '/plugin/FreeeLight/config2', 'Plugin\\FreeeLight\\Controller\\ConfigController::step2')->bind('plugin_FreeeLight_config_step2');
$app->match('/' . $app['config']['admin_route'] . '/plugin/FreeeLight/config3', 'Plugin\\FreeeLight\\Controller\\ConfigController::step3')->bind('plugin_FreeeLight_config_step3');
$app->match('/' . $app['config']['admin_route'] . '/plugin/FreeeLight/config_complete', 'Plugin\\FreeeLight\\Controller\\ConfigController::complete')->bind('plugin_FreeeLight_config_complete');
$app->match('/oauth2/receive_authcode', 'Plugin\\FreeeLight\\Controller\\OAuth2Controller::receive_authcode')->bind('plugin_FreeeLight_oauth2_receive_authcode');
// Form
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
$types[] = new \Plugin\FreeeLight\Form\Type\FreeeCompanyType($app);
$types[] = new \Plugin\FreeeLight\Form\Type\FreeeLightConfigType($app);
$types[] = new \Plugin\FreeeLight\Form\Type\FreeeLightConfig2Type($app);
return $types;
}));
// Repository
$app['eccube.plugin.repository.freeelight'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\FreeeLight\\Entity\\FreeeLight');
});
$app['eccube.plugin.repository.freee_oauth2'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\FreeeLight\\Entity\\FreeeOAuth2');
});
$app['eccube.plugin.repository.freee_tax'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\FreeeLight\\Entity\\FreeeTax');
});
$app['eccube.plugin.repository.freee_account_item'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\FreeeLight\\Entity\\FreeeAccountItem');
});
$app['eccube.plugin.repository.freee_wallet'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\FreeeLight\\Entity\\FreeeWallet');
});
$app['eccube.plugin.repository.freee_company'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\FreeeLight\\Entity\\FreeeCompany');
});
}
示例6: addRoute
/**
* {@inheritdoc}
*/
public function addRoute($routePath, $method, $controllerClassName, $actionMethodName, Response $response, \Closure $init)
{
$this->app->match($routePath, $controllerClassName . '::' . $actionMethodName)->method(strtoupper($method))->value('response', $response)->before(function (Request $request) use($init) {
$this->request = $request;
$init();
});
}
示例7: registerListener
protected function registerListener(Application $app)
{
$app['security.authentication_listener.factory.opauth'] = $app->protect(function ($name, $options) use($app) {
$options = array_replace_recursive(array('check_path' => '/login/opauth', 'opauth' => array('path' => '/login/')), $options);
if (!isset($app['security.authentication.success_handler.' . $name])) {
$app['security.authentication.success_handler.' . $name] = $app['security.authentication.success_handler._proto']($name, $options);
}
if (!isset($app['security.authentication.failure_handler.' . $name])) {
$app['security.authentication.failure_handler.' . $name] = $app['security.authentication.failure_handler._proto']($name, $options);
}
// define the authentication provider object
if (!isset($app['security.authentication_provider.' . $name . '.opauth'])) {
$app['security.authentication_provider.' . $name . '.opauth'] = $app->share(function () use($app, $name) {
return new OpauthProvider($app['security.user_provider.' . $name]);
});
}
// define the authentication listener object
if (!isset($app['security.authentication_listener.' . $name . '.opauth'])) {
$app['security.authentication_listener.' . $name . '.opauth'] = $app->share(function () use($app, $name, $options) {
return new OpauthListener($app['security'], $app['security.authentication_manager'], isset($app['security.session_strategy.' . $name]) ? $app['security.session_strategy.' . $name] : $app['security.session_strategy'], $app['security.http_utils'], $name, $app['security.authentication.success_handler.' . $name], $app['security.authentication.failure_handler.' . $name], $options, $app['logger'], $app['dispatcher']);
});
}
// routes
// $this->onBoot[] = function() use ($app, $options, $name) {
$bindName = "opauth_{$name}_";
$app->match($options['check_path'], function () {
})->bind($bindName . 'check');
$app->match($options['opauth']['path'] . '{strategy}/{return}', function () {
})->value('return', '')->bind($bindName . 'login');
// };
return array('security.authentication_provider.' . $name . '.opauth', 'security.authentication_listener.' . $name . '.opauth', null, 'pre_auth');
});
}
示例8: connect
public function connect(Application $app)
{
$controllers = $app["controllers_factory"];
$app->match('/login', [$this, 'loginAction'])->bind('login');
$app->get('/logout', [$this, 'logoutAction'])->bind('logout');
$app->match('/login_redirect', [$this, 'loginRedirectAction'])->bind('login-redirect');
return $controllers;
}
示例9: register
public function register(Application $app)
{
$app->match('/administration/{table}', function ($table) use($app) {
if (is_null($app['silexcms.security']->getUsername())) {
return $app->redirect($app['url_generator']->generate('administration_login'));
}
$repository = $app['silexcms.sets'][$table]->getRepository();
$schema = $repository->getSchema();
$rows = $repository->findAll(true);
foreach ($rows as $row) {
$data[] = array_map(function ($val) {
return is_string($val) && strlen($val) > 50 ? substr(strip_tags($val), 0, 47) . '...' : $val;
}, $row);
}
return new TransientResponse($app, $app['silexcms.template.loader']->load('administration/administration_table.html.twig'), array('table' => $table, 'fields' => $schema, 'rows' => $data));
})->bind('administration_table');
$app->match('/administration/{table}/{primaryKey}', function (Request $req, $table, $primaryKey) use($app) {
if (is_null($app['silexcms.security']->getUsername())) {
return $app->redirect($app['url_generator']->generate('administration_login'));
}
$set = $app['silexcms.sets'][$table];
$repository = $set->getRepository();
$formGenerator = new Form($set);
$form = $app['form.factory']->create(new TableType($app, $table), $formGenerator->getData('_new' === $primaryKey ? null : $primaryKey));
if ($req->getMethod() === 'POST') {
$form->bindRequest($req);
if ($form->isValid()) {
$data = $form->getData();
foreach ($data['row'] as $row) {
$where = array('`' . $repository->getPrimaryKey() . '`' => $row[$repository->getPrimaryKey()]);
// unset id primaryKey
if ('id' === $repository->getPrimaryKey()) {
unset($row[$repository->getPrimaryKey()]);
}
if ('_new' === $primaryKey) {
$repository->insert($row);
return $app->redirect($app['url_generator']->generate('administration_table', array('table' => $table)));
}
$repository->update($row, $where);
try {
// cache strategy if exist. Update cache version
$app['silexcms.cache.manager']->update();
} catch (\Exception $e) {
}
}
}
}
return new TransientResponse($app, $app['silexcms.template.loader']->load('administration/administration_edit.html.twig'), array('table' => $table, 'primaryKey' => $primaryKey, 'form' => $form->createView()));
})->bind('administration_edit');
$app->match('/administration', function () use($app) {
if (is_null($app['silexcms.security']->getUsername())) {
return $app->redirect($app['url_generator']->generate('administration_login'));
}
$tables = array_keys($app['silexcms.sets']);
return new TransientResponse($app, $app['silexcms.template.loader']->load('administration/administration_hub.html.twig'), array('tables' => $tables));
})->bind('administration_hub');
}
示例10: register
public function register(BaseApplication $app)
{
// 定休日テーブル用リポジトリ
$app['eccube.plugin.holiday.repository.holiday'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Holiday\\Entity\\Holiday');
});
$basePath = '/' . $app["config"]["admin_route"];
// 一覧
$app->match($basePath . '/system/shop/holiday/', '\\Plugin\\Holiday\\Controller\\HolidayController::index')->bind('admin_setting_shop_holiday');
// 新規作成
$app->match($basePath . '/system/shop/holiday/new', '\\Plugin\\Holiday\\Controller\\HolidayController::edit')->bind('admin_setting_shop_holiday_new');
// 編集
$app->match($basePath . '/system/shop/holiday/{id}/edit', '\\Plugin\\Holiday\\Controller\\HolidayController::edit')->assert('id', '\\d+')->bind('admin_setting_shop_holiday_edit');
// 一覧:削除
$app->delete($basePath . '/system/shop/holiday/{id}/delete', '\\Plugin\\Holiday\\Controller\\HolidayController::delete')->assert('id', '\\d+')->bind('admin_setting_shop_holiday_delete');
// 一覧:上
$app->put($basePath . '/system/shop/holiday/{id}/up', '\\Plugin\\Holiday\\Controller\\HolidayController::up')->assert('id', '\\d+')->bind('admin_setting_shop_holiday_up');
// 一覧:下
$app->put($basePath . '/system/shop/holiday/{id}/down', '\\Plugin\\Holiday\\Controller\\HolidayController::down')->assert('id', '\\d+')->bind('admin_setting_shop_holiday_down');
$app->match('/block/holiday_calendar_block', '\\Plugin\\Holiday\\Controller\\Block\\HolidayController::index')->bind('block_holiday_calendar_block');
// 型登録
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
$types[] = new \Plugin\Holiday\Form\Type\HolidayType($app);
return $types;
}));
// メッセージ登録
$app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
$file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
if (file_exists($file)) {
$translator->addResource('yaml', $file, $app['locale']);
}
return $translator;
}));
// load config
$conf = $app['config'];
$app['config'] = $app->share(function () use($conf) {
$confarray = array();
$path_file = __DIR__ . '/../Resource/config/path.yml';
if (file_exists($path_file)) {
$config_yml = Yaml::parse(file_get_contents($path_file));
if (isset($config_yml)) {
$confarray = array_replace_recursive($confarray, $config_yml);
}
}
return array_replace_recursive($conf, $confarray);
});
// メニュー登録
$app['config'] = $app->share($app->extend('config', function ($config) {
$addNavi['id'] = "holiday";
$addNavi['name'] = "定休日管理";
$addNavi['url'] = "admin_setting_shop_holiday";
self::addNavi($config['nav'], $addNavi, array('setting', 'shop'));
return $config;
}));
}
示例11: boot
public function boot(Application $app)
{
$app['users.repository'];
$app->match('/login', $app['actions.dispatch']($app['users.login_action']))->bind('login');
$app->match('/logout')->bind('logout');
$app['cms.navigation_list'] = $app->share($app->extend('cms.navigation_list', function (ListNodeInterface $cmsNav) use($app) {
$cmsNav->getChild('users')->addChild('logout', 'Logout', $app['url_generator']->generate('logout'));
return $cmsNav;
}));
}
示例12: connect
/**
* {@inheritdoc}
*/
public function connect(Application $app)
{
/** @var $ctr ControllerCollection */
$ctr = $app['controllers_factory'];
// Sitewide feed
$this->app->match('/amp/feed.{extension}', [$this, 'feed'])->assert('extension', '(xml|rss)');
// ContentType specific feed(s)
$this->app->match('/{contenttypeslug}/amp/feed.{extension}', [$this, 'feed'])->assert('extension', '(xml|rss)')->assert('contenttypeslug', $this->getContentTypeAssert());
return $ctr;
}
示例13: register
public function register(BaseApplication $app)
{
// 不要?
$app['eccube.plugin.maker.repository.maker_plugin'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Maker\\Entity\\MakerPlugin');
});
// メーカーテーブル用リポジトリ
$app['eccube.plugin.maker.repository.maker'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Maker\\Entity\\Maker');
});
$app['eccube.plugin.maker.repository.product_maker'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Maker\\Entity\\ProductMaker');
});
// 一覧・登録・修正
$app->match('/' . $app["config"]["admin_route"] . '/product/maker/{id}', '\\Plugin\\Maker\\Controller\\MakerController::index')->value('id', null)->assert('id', '\\d+|')->bind('admin_maker');
// 削除
$app->match('/' . $app["config"]["admin_route"] . '/product/maker/{id}/delete', '\\Plugin\\Maker\\Controller\\MakerController::delete')->value('id', null)->assert('id', '\\d+|')->bind('admin_maker_delete');
// 上
$app->match('/' . $app["config"]["admin_route"] . '/product/maker/{id}/up', '\\Plugin\\Maker\\Controller\\MakerController::up')->value('id', null)->assert('id', '\\d+|')->bind('admin_maker_up');
// 下
$app->match('/' . $app["config"]["admin_route"] . '/product/maker/{id}/down', '\\Plugin\\Maker\\Controller\\MakerController::down')->value('id', null)->assert('id', '\\d+|')->bind('admin_maker_down');
// 型登録
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
$types[] = new \Plugin\Maker\Form\Type\MakerType($app);
return $types;
}));
// Form Extension
$app['form.type.extensions'] = $app->share($app->extend('form.type.extensions', function ($extensions) use($app) {
$extensions[] = new \Plugin\Maker\Form\Extension\Admin\ProductMakerTypeExtension($app);
return $extensions;
}));
// メッセージ登録
$app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
$file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
if (file_exists($file)) {
$translator->addResource('yaml', $file, $app['locale']);
}
return $translator;
}));
// メニュー登録
$app['config'] = $app->share($app->extend('config', function ($config) {
$addNavi['id'] = "maker";
$addNavi['name'] = "メーカー管理";
$addNavi['url'] = "admin_maker";
$nav = $config['nav'];
foreach ($nav as $key => $val) {
if ("product" == $val["id"]) {
$nav[$key]['child'][] = $addNavi;
}
}
$config['nav'] = $nav;
return $config;
}));
}
示例14: register
public function register(BaseApplication $app)
{
// 定休日管理テーブル用リポジトリ
$app['eccube.plugin.holiday.repository.holiday'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Holiday\\Entity\\Holiday');
});
// 定休曜日管理テーブル用レポジトリ
$app['eccube.plugin.holiday.repository.holidayweek'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Holiday\\Entity\\HolidayWeek');
});
// 定休日基本設定テーブル用レポジトリ
$app['eccube.plugin.holiday.repository.holidayconfig'] = $app->share(function () use($app) {
return $app['orm.em']->getRepository('Plugin\\Holiday\\Entity\\HolidayConfig');
});
// Setting
$app->match('/' . $app["config"]["admin_route"] . '/plugin/holiday/config/', '\\Plugin\\Holiday\\Controller\\ConfigController::edit')->value('id', 1)->assert('id', '\\d+|')->bind('plugin_holiday_config');
// 一覧・登録・修正
$app->match('/' . $app["config"]["admin_route"] . '/setting/holiday/{id}', '\\Plugin\\Holiday\\Controller\\HolidayController::index')->value('id', null)->assert('id', '\\d+|')->bind('admin_holiday');
// 定休日 曜日
$app->match('/' . $app["config"]["admin_route"] . '/setting/holidayweek/{id}', '\\Plugin\\Holiday\\Controller\\HolidayWeekController::index')->value('id', 1)->assert('id', '\\d+|')->bind('admin_holiday_week');
// 削除
$app->match('/' . $app["config"]["admin_route"] . '/setting/holiday/{id}/delete', '\\Plugin\\Holiday\\Controller\\HolidayController::delete')->value('id', null)->assert('id', '\\d+|')->bind('admin_holiday_delete');
// 型登録
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
$types[] = new \Plugin\Holiday\Form\Type\HolidayConfigType($app);
$types[] = new \Plugin\Holiday\Form\Type\HolidayType($app);
$types[] = new \Plugin\Holiday\Form\Type\HolidayWeekType($app);
return $types;
}));
// メッセージ登録
$app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
$file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
if (file_exists($file)) {
$translator->addResource('yaml', $file, $app['locale']);
}
return $translator;
}));
// 定休日管理
$app['config'] = $app->share($app->extend('config', function ($config) {
$addNavi['id'] = "holiday";
$addNavi['name'] = "定休日管理";
$addNavi['has_child'] = true;
$addNavi['child'] = array(array('id' => 'holiday_config', 'name' => '基本設定', 'url' => 'plugin_holiday_config'), array('id' => 'holiday_week', 'name' => '定休日管理', 'url' => 'admin_holiday_week'), array('id' => 'holiday', 'name' => '休日管理', 'url' => 'admin_holiday'));
$nav = $config['nav'];
foreach ($nav as $key => $val) {
if ("setting" == $val["id"]) {
$nav[$key]['child'][] = $addNavi;
}
}
$config['nav'] = $nav;
return $config;
}));
}
示例15: createApplication
public function createApplication()
{
$app = new Application();
$app->match('/hello', function () {
return 'world';
});
$app->match('/html', function () {
return '<h1>title</h1>';
});
return $app;
}