返信遅くなり申し訳ありません。
ServiceProviderは、下記の通りになってます。
namespace Plugin\B2BShop;
use Monolog\Logger;
use Monolog\Handler\FingersCrossedHandler;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Plugin\B2BShop\Form\Type\B2BShopConfigType;
use Silex\Application as BaseApplication;
use Silex\ServiceProviderInterface;
class B2BShopServiceProvider implements ServiceProviderInterface
{
public function register(BaseApplication $app)
{
// プラグイン用設定画面
$app->match('/'.$app['config']['admin_route'].'/plugin/B2BShop/config', 'Plugin\B2BShop\Controller\ConfigController::index')->bind('plugin_B2BShop_config');
// 独自コントローラ
$app->match('/plugin/b2bshop/hello', 'Plugin\B2BShop\Controller\B2BShopController::index')->bind('plugin_B2BShop_hello');
// Form
$app['form.types'] = $app->share($app->extend('form.types', function ($types) use ($app) {
$types[] = new B2BShopConfigType();
return $types;
}));
// Repository
// Service
// メッセージ登録
// $file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
// $app['translator']->addResource('yaml', $file, $app['locale']);
// load config
// プラグイン独自の定数はconfig.ymlの「const」パラメータに対して定義し、$app['b2bshopconfig']['定数名']で利用可能
// if (isset($app['config']['B2BShop']['const'])) {
// $config = $app['config'];
// $app['b2bshopconfig'] = $app->share(function () use ($config) {
// return $config['B2BShop']['const'];
// });
// }
// ログファイル設定
$app['monolog.logger.b2bshop'] = $app->share(function ($app) {
$logger = new $app['monolog.logger.class']('b2bshop');
$filename = $app['config']['root_dir'].'/app/log/b2bshop.log';
$RotateHandler = new RotatingFileHandler($filename, $app['config']['log']['max_files'], Logger::INFO);
$RotateHandler->setFilenameFormat(
'b2bshop_{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)
{
}
}
Formの追加は、プラグイン解説の方法を取っています(Extensionではないと思われます)。
Form/Type内にある定義ファイル(B2BShopConfigType.php)は以下の通りです。
namespace Plugin\B2BShop\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class B2BShopConfigType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('public', CheckboxType::class, array(
'label' => 'B2B顧客',
'required' => false,
));
}
public function getName()
{
return 'b2bshop_config';
}
}
twingについては、よく分かっておりません。
大変申し訳ないのですが、ご教授いただけないでしょうか?