Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
【EC-CUBE3】会員情報の項目を追加する方法
<?php
/*
* This file is part of the Profile
*
* Copyright (C) 2016 会員プロフィール
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Profile\ServiceProvider;
use Eccube\Application;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\FingersCrossedHandler;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Plugin\Profile\Form\Type\ProfileConfigType;
use Silex\Application as BaseApplication;
use Silex\ServiceProviderInterface;
use Symfony\Component\Yaml\Yaml;
class ProfileServiceProvider implements ServiceProviderInterface
{
public function register(BaseApplication $app)
{
// プラグイン用設定画面
$app->match('/'.$app['config']['admin_route'].'/plugin/Profile/config', 'Plugin\Profile\Controller\ConfigController::index')->bind('plugin_Profile_config');
// 独自コントローラ
$app->match('/plugin/[lower_code]/hello', 'Plugin\Profile\Controller\ProfileController::index')->bind('plugin_Profile_hello');
// Form
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use ($app) {
$types[] = new ProfileConfigType();
return $types;
}));
// Repositoryを追加
$app['eccube.plugin.profile.repository.profile'] = $app->share(
function () use ($app) {
return $app['orm.em']->getRepository('Plugin\Profile\Entity\Profile');
}
);
// Service
// メッセージ登録
// $file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
// $app['translator']->addResource('yaml', $file, $app['locale']);
// load config
// プラグイン独自の定数はconfig.ymlの「const」パラメータに対して定義し、$app['[lower_code]config']['定数名']で利用可能
// if (isset($app['config']['Profile']['const'])) {
// $config = $app['config'];
// $app['[lower_code]config'] = $app->share(function () use ($config) {
// return $config['Profile']['const'];
// });
// }
// ログファイル設定
$app['monolog.logger.[lower_code]'] = $app->share(function ($app) {
$logger = new $app['monolog.logger.class']('[lower_code]');
$filename = $app['config']['root_dir'].'/app/log/[lower_code].log';
$RotateHandler = new RotatingFileHandler($filename, $app['config']['log']['max_files'], Logger::INFO);
$RotateHandler->setFilenameFormat(
'[lower_code]_{date}',
'Y-m-d'
);
$logger->pushHandler(
new FingersCrossedHandler(
$RotateHandler,
new ErrorLevelActivationStrategy(Logger::ERROR),
0,
true,
true,
Logger::INFO
)
);
return $logger;
});
}
public function boot(BaseApplication $app)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment