はっきり言ったら、このようにサービスプロバイダーで入れています。
<?php
namespace Plugin\TestPlugin\ServiceProvider;
use Eccube\Application;
use Silex\Application as BaseApplication;
use Silex\ServiceProviderInterface;
class TestPluginServiceProvider implements ServiceProviderInterface
{
public function register(BaseApplication $app)
{
$app->match('/admin/test1', 'Object::method')->bind('test_url_1');
$app->match('/admin/test2/{id}', 'Object::method')->bind('test_url_2');
$app['config'] = $app->share(
$app->extend(
'config',
function ($config) {
// 親アイテム
$menuItem['id'] = "parent_item";
$menuItem['name'] = "Parent Item";
$menuItem['has_child'] = "true";
$menuItem['icon'] = "cb-plus-square";
// 子供アイテム
$children = array(
array(
"id" => "child_item_1",
"name" => "Child Item 1",
"url" => "test_url_1" // 成功
),
array(
"id" => "child_item_2",
"name" => "Child Item 2",
"url" => "test_url_2" // 失敗、idが無い
)
);
$menuItem['child'] = $children;
$nav = $config['nav'];
// 設定アイテムの位置を習得
$insertAtIndex = 0;
foreach ($nav as $key => $val) {
if ($val['id'] == "setting") {
$insertAtIndex = $key;
}
}
// 習得したところの前に入れる
array_splice($nav, $insertAtIndex, 0, array($menuItem));
// 保存
$config['nav'] = $nav;
return $config;
}
)
);
}
}