{"id":202072,"date":"2013-11-13T22:20:03","date_gmt":"2013-11-13T18:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=202072"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=202072","title":{"rendered":"<span class=\"post_title\">KnpMenuBundle + Sonata. \u0414\u0435\u043b\u0430\u0435\u043c \u043c\u0435\u043d\u044e \u0438\u0437 \u0431\u0430\u0437\u044b<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435. \u042f \u043b\u044e\u0431\u043b\u044e Symfony. \u041e\u043d\u0430 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438 \u044f \u0435\u0435 \u043e\u0431\u043e\u0436\u0430\u044e. \u0415\u0449\u0435 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f SonataAdminBundle. \u0414\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u043c \u0438\u0437 \u0432\u0430\u0441 \u0442\u043e\u0436\u0435. \u0418\u0442\u0430\u043a, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u0430 \u043f\u0440\u0438 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 KNPMenuBundle + SonataAdminBundle. \u041f\u043e \u0441\u0443\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u043d\u0430 github\u2019e \u0441\u0430\u043c\u043e\u0433\u043e \u0431\u0430\u043d\u0434\u043b\u0430, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e \u0431\u044b \u043c\u0435\u043d\u044e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438? \u0417\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438\u0441\u044c? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0443 \u0438\u0437\u0432\u0438\u043d\u0438\u0442\u044c \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e \u043d\u0438\u0436\u0435, \u043d\u043e \u0432\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0435 \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e \u0438\u0445 \u0432\u0430\u0441 \u0432\u0438\u0434\u0435\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0441\u0441\u044b\u043b\u043a\u043e\u0439. \u041c\u043e\u0436\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439. \u0418\u0442\u0430\u043a \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 Sonata \u0438 \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0430\u043d\u0434\u043b\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u044e. <\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0438 \u043f\u0438\u0448\u0435\u043c:<br \/>  <b>#php app\/console generate:bundle<\/b><\/p>\n<p>  \u0418\u043c\u044f \u0434\u043b\u044f \u0431\u0430\u043d\u0434\u043b\u0430 \u0432\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0430\u043c\u0438, \u044f \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043b \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e MenuBundle.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c 2 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0431\u0430\u043d\u0434\u043b\u043e\u043c \u043f\u0430\u043f\u043a\u0438 Entity \u2014 \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0435\u0435. \u0418\u0442\u0430\u043a, \u0444\u0430\u0439\u043b \u043d\u043e\u043c\u0435\u0440 \u0440\u0430\u0437 \u2014 Menu.php. \u0424\u0430\u0439\u043b \u043d\u043e\u043c\u0435\u0440 \u0434\u0432\u0430 \u2014 MenuType.php. \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u0432\u0442\u043e\u0440\u043e\u0439 \u0444\u0430\u0439\u043b, \u044f \u043f\u043e\u044f\u0441\u043d\u044e \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  \u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0440\u0430\u0437:<\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Entity;  use Doctrine\\ORM\\Mapping as ORM; \/**  * @ORM\\Entity  * @ORM\\Table(name=&quot;menu&quot;)  * @ORM\\Entity(repositoryClass=&quot;MyFolder\\MenuBundle\\Entity\\MenuRepository&quot;)  *\/ class Menu{     \/**      * @ORM\\Id      * @ORM\\Column(type=&quot;integer&quot;)      * @ORM\\GeneratedValue(strategy=&quot;AUTO&quot;)      *\/     protected $id;      \/**      * @ORM\\Column(type=&quot;string&quot;, length=100)      *\/     protected $title;      \/**      * @ORM\\Column(type=&quot;string&quot;, length=100)      *\/     protected $route;      \/**      * @ORM\\Column(type=&quot;string&quot;, nullable=true)      *\/     protected $alias;      \/**      * @ORM\\Column(type=&quot;boolean&quot;)      *\/     protected $static;      \/**      * @ORM\\ManyToOne(targetEntity=&quot;Cafe\\MenuBundle\\Entity\\MenuType&quot;, inversedBy=&quot;menuTypeId&quot;)      * @ORM\\JoinColumn(name=&quot;menuTypeId&quot;, referencedColumnName=&quot;id&quot;)      *\/     protected $menuTypeId;  } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0444\u0430\u0439\u043b \u043f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0434\u0432\u0430:  <\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Entity;  use Doctrine\\ORM\\Mapping as ORM; \/**  * @ORM\\Entity  * @ORM\\Table(name=&quot;menu_type&quot;)  * @ORM\\Entity(repositoryClass=&quot;MyFolder\\MenuBundle\\Entity\\MenuTypeRepository&quot;)  *\/ class MenuType {      \/**      * @ORM\\Id      * @ORM\\Column(type=&quot;integer&quot;)      * @ORM\\GeneratedValue(strategy=&quot;AUTO&quot;)      *\/     protected $id;      \/**      * @ORM\\Column(type=&quot;string&quot;, length=100)      *\/     protected $title;      \/**      * @ORM\\OneToMany(targetEntity=&quot;Menu&quot;, mappedBy=&quot;menuTypeId&quot;)      *\/     private $typeId; } <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b 2 \u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b \u0434\u043b\u044f \u043d\u0438\u0445?!<br \/>  <b># php app\/console doctrine:generate:entities MyFolder\/MenuBundle\/Entity\/Menu<\/b><br \/>  \u0438<br \/>  <b># php app\/console doctrine:generate:entities MyFolder\/MenuBundle\/Entity\/MenuType<\/b><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0434\u0430\u0447\u043d\u043e \u0432\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u0441\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0438 \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0430\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0411\u0414. <br \/>  <b># php app\/console doctrine:schema:update &#8212;force<\/b><\/p>\n<p>  \u0418\u0442\u0430\u043a \u0443 \u043d\u0430\u0441 2 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0432\u044f\u0437\u044c\u044e ManyToOne. \u0422\u043e \u0435\u0441\u0442\u044c, \u043f\u043e \u0441\u0443\u0442\u0438, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0420\u0410\u0417 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0432\u044f\u0437\u0435\u0439 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0414\u0412\u0410. <\/p>\n<p>  \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435. \u0414\u0430\u0432\u0430\u0439 \u0442\u0435 \u043f\u0440\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0441\u0432\u044f\u0437\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445, \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442.<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0420\u0410\u0417.  <\/p>\n<pre><code class=\"php\">\/**   * @ORM\\ManyToOne(targetEntity=&quot;MyFolder\\MenuBundle\\Entity\\MenuType&quot;, inversedBy=&quot;menuTypeId&quot;)   * @ORM\\JoinColumn(name=&quot;menuTypeId&quot;, referencedColumnName=&quot;id&quot;)   *\/ protected $menuTypeId; <\/code><\/pre>\n<p>  \u0413\u043e\u0432\u043e\u0440\u044f\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 MyFolder\\MenuBundle\\Entity\\Menu \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 MyFolder\\MenuBundle\\Entity\\MenuType \u043e \u0447\u0435\u043c \u043d\u0430\u043c \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0414\u0412\u0410  <\/p>\n<pre><code class=\"php\">\/**    * @ORM\\OneToMany(targetEntity=&quot;Menu&quot;, mappedBy=&quot;menuTypeId&quot;)    *\/ private $typeId; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 Symfony.<\/p>\n<p>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043a\u043e\u0434\u0443. \u0418\u0442\u0430\u043a, \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438, \u0411\u0414 \u0441\u043e\u0437\u0434\u0430\u043b\u0438. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0430\u0434\u043c\u0438\u043d \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043d\u0430\u0448\u0430 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u044c, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u0412 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0431\u0430\u043d\u0434\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 Admin \u0430 \u0432 \u043d\u0435\u0439 2 \u0444\u0430\u0439\u043b\u0430. \u0424\u0430\u0439\u043b \u0440\u0430\u0437 \u2014 MenuAdmin, \u0444\u0430\u0439\u043b \u0434\u0432\u0430 \u2014 MenuTypeAdmin. \u041a\u043e\u0434 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0420\u0410\u0417:  <\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Admin;  use Sonata\\AdminBundle\\Admin\\Admin; use Sonata\\AdminBundle\\Datagrid\\ListMapper; use Sonata\\AdminBundle\\Datagrid\\DatagridMapper; use Sonata\\AdminBundle\\Form\\FormMapper; use Sonata\\AdminBundle\\Show\\ShowMapper;  class MenuAdmin extends Admin{     protected function configureFormFields(FormMapper $formMapper)     {         $formMapper             -&gt;add('title', null, array())             -&gt;add('route', null, array())             -&gt;add('alias', null, array())             -&gt;add('static', null, array('required' =&gt; false))             -&gt;add('menuTypeId', 'sonata_type_model', array(                     'class'=&gt;'MenuBundle:MenuType',                     'property'=&gt;'title',                     'required' =&gt; false                 )             )         ;     }      protected function configureDatagridFilters(DatagridMapper $datagridMapper)     {         $datagridMapper             -&gt;add('title', null, array())             -&gt;add('id', null, array())             -&gt;add('route', null, array())         ;     }      public function configureShowField(ShowMapper $showMapper){         $showMapper             -&gt;add('title', null, array())             -&gt;add('id', null, array())             -&gt;add('route', null, array())         ;     }      protected function configureListFields(ListMapper $listMapper)     {         $listMapper             -&gt;addIdentifier('title', null, array())             -&gt;add('route', null, array())             -&gt;add('id', null, array())             -&gt;add('menuTypeId', 'entity', array(                     'class'=&gt;'MenuBundle:MenuType',                     'property'=&gt;'title'                 )             )         ;     } } <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0438\u0437\u0432\u0438\u043d\u044f\u044e\u0441\u044c, \u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0442\u0430 \u0438\u043b\u0438 \u0438\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443, \u0438\u0431\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0421\u043e\u043d\u0430\u0442\u0435. \u041c\u043e\u0436\u0435\u0442 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0438\u0448\u0443, \u0435\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p>  \u041a\u043e\u0434 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0414\u0412\u0410:  <\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Admin;  use Sonata\\AdminBundle\\Admin\\Admin; use Sonata\\AdminBundle\\Datagrid\\ListMapper; use Sonata\\AdminBundle\\Datagrid\\DatagridMapper; use Sonata\\AdminBundle\\Form\\FormMapper; use Sonata\\AdminBundle\\Show\\ShowMapper;  class MenuTypeAdmin extends Admin{     protected function configureFormFields(FormMapper $formMapper)     {         $formMapper             -&gt;add('title', null, array())         ;     }      protected function configureDatagridFilters(DatagridMapper $datagridMapper)     {         $datagridMapper             -&gt;add('title', null, array())             -&gt;add('id', null, array())         ;     }      public function configureShowField(ShowMapper $showMapper){         $showMapper             -&gt;add('title', null, array())             -&gt;add('id', null, array())         ;     }      protected function configureListFields(ListMapper $listMapper)     {         $listMapper             -&gt;addIdentifier('title', null, array())             -&gt;add('id', null, array())         ;     } }  <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u043d\u0430\u0442\u0435, \u0447\u0442\u043e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430\u0448\u0443 \u043f\u0430\u043f\u043a\u0443 \u0438 \u043d\u0430\u0448\u0438 2 \u0444\u0430\u0439\u043b\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <b>MyFolder\/MenuBundle\/Resources\/config\/services.yml<\/b> \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u042f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u0432\u0441\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439:  <\/p>\n<pre><code class=\"php\">parameters:  services:     admin.menu:         class: MyFolder\\MenuBundle\\Admin\\MenuAdmin         tags:         - { name:  sonata.admin, manager_type: orm, group: \u041c\u0435\u043d\u044e, label: \u041c\u0435\u043d\u044e}         arguments: [null, MyFolder\\MenuBundle\\Entity\\Menu, SonataAdminBundle:CRUD]            admin.menu_type:           class: MyFolder\\MenuBundle\\Admin\\MenuTypeAdmin           tags:           - { name:  sonata.admin, manager_type: orm, group: \u041c\u0435\u043d\u044e \u0422\u0438\u043f, label: \u041c\u0435\u043d\u044e \u0422\u0438\u043f}           arguments: [null, MyFolder\\MenuBundle\\Entity\\MenuType, SonataAdminBundle:CRUD] <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0432 \u0430\u0434\u043c\u0438\u043d \u0447\u0430\u0441\u0442\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f 2 \u043f\u0443\u043d\u043a\u0442\u0430, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u043b\u0438 \u0431\u044b \u043e\u043d\u0438 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"http:\/\/www.easyfoto.ru\/20131113191315170.png\" alt=\"image\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0442\u0430\u043a \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u0435 (sin666m4a1fox@gmail.com), \u043e\u0445\u043e\u0442\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0443 \u043d\u0430 \u0432\u0430\u0448\u0438 \u043f\u0438\u0441\u044c\u043c\u0430.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c, \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u0430\u0448\u0438 \u043f\u0443\u043d\u043a\u0442\u044b \u043c\u0435\u043d\u044e. <\/p>\n<p>  \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0442\u0430\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435? \u041d\u0430\u0432\u0435\u0440\u043d\u043e \u0441 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u043b\u043e \u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0436 \u0442\u0430\u043a \u043c\u044b \u0442\u0443\u0442 \u0441 \u0432\u0430\u043c\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0435\u043d\u044e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432, \u0432\u044b\u0432\u043e\u0434 \u043e\u0431\u0449\u0435\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e\u2026 \u0438 \u043c\u043d\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. <\/p>\n<p>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0441\u043c\u0435\u043d\u044e \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0438\u043f \u043c\u0435\u043d\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u201c\u041c\u0435\u043d\u044e \u0422\u0438\u043f\u201d \u0438 \u0436\u043c\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u0441 \u043f\u043b\u044e\u0441\u0438\u043a\u043e\u043c. \u0422\u0430\u043a \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c. \u041e\u0434\u043d\u043e \u043f\u043e\u043b\u0435 \u2014 title (\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a). \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0422\u0438\u043f\u044b \u041c\u0435\u043d\u044e \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c, \u043f\u043e\u0437\u0436\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u041f\u0443\u043d\u043a\u0442\u044b \u043c\u0435\u043d\u044e. \u042f \u0441\u0434\u0435\u043b\u0430\u043b \u0434\u0432\u0430 \u0422\u0438\u043f\u0430 \u041c\u0435\u043d\u044e (\u201c\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u041c\u0435\u043d\u044e\u201d \u0438 \u201c\u041c\u0435\u043d\u044e \u0432 \u043f\u043e\u0434\u0432\u0430\u043b\u0435\u201d). \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u0430\u043c\u043e \u041c\u0435\u043d\u044e \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u043e\u0435. \u0412\u043e\u0442 \u0442\u0443\u0442 \u043f\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0439.<br \/>  <img decoding=\"async\" src=\"http:\/\/www.easyfoto.ru\/20131113191411090.png\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e Title \u044d\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0437\u0430\u0447\u0435\u043c, Route \u2014 \u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0439\u0434\u0435\u043c \u0432 KNPMenuBundle. Alias \u2014 \u044d\u0442\u043e \u043b\u0438\u0447\u043d\u043e \u043c\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0443\u043d\u043a\u0442. Static \u0447\u0435\u043a\u0431\u043e\u043a\u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0447\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u0438 \u0435\u0439 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 Action \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435. Menu Type Id \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0430\u043c \u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0442\u0435 \u043f\u0443\u043d\u043a\u0442\u044b \u043c\u0435\u043d\u044e \u0447\u0442\u043e \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0430\u0448\u0435. \u042d\u0442\u043e \u0442\u0430 \u0441\u0430\u043c\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043f\u0443\u043d\u043a\u0442 \u043c\u0435\u043d\u044e \u0432\u044b \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0445\u043e\u0434\u0438\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p>  \u041e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442. \u0412 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 JS \u043a\u043e\u0434.  <\/p>\n<pre><code class=\"javascript\">$(document).ready(function () {     $('input[id$=&quot;_static&quot;]').click(function(){         var $_thisRoute = $('input[id$=&quot;_route&quot;]'),             defaultValues = $_thisRoute.val().split('\/');         if($(this).is(':checked')) {             $_thisRoute.val('\/custom\/'+defaultValues[defaultValues.length -1]);         } else {             $_thisRoute.val('\/'+defaultValues[defaultValues.length -1]);         }     }) }); <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442 Static \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 about-us \u0442\u043e \u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \/custom\/about-us.<\/p>\n<p>  \u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 js \u0432 \u0430\u0434\u043c\u0438\u043d \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u043d\u0430\u0442\u044b \u043d\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u044d\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c, \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0443, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \ud83d\ude42<\/p>\n<p>  \u042f \u0441\u043e\u0437\u0434\u0430\u043b 7 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043c\u0435\u043d\u044e<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/www.easyfoto.ru\/20131113191507478.png\" alt=\"image\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0435\u0442\u0435 Route \u043f\u043e\u0447\u0442\u0438 \u0443 \u0432\u0441\u0435\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432 \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430. \u041f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0413\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u041c\u0435\u043d\u044e. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043a KNPMenuBundle.<\/p>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u0430\u043d\u0434\u043b\u0430 1.1 \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c 2.2 \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c 2.2 \u0441 \u0421\u043e\u043d\u0430\u0442\u043e\u0439 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0434\u0430 \u0438 \u0432 \u0421\u043e\u043d\u0430\u0442\u0435 \u0432 requirements \u0441\u0442\u043e\u0438\u0442 \u0432\u0435\u0440\u0441\u0438\u044f KNPMenuBundle 1.1 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u043c. <\/p>\n<p>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c. \u0412 \u043f\u0430\u043f\u043a\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c \u0431\u0430\u043d\u0434\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 Menu \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b Builder.php. \u0412\u043e\u0442 \u0435\u0433\u043e \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Menu;  use Knp\\Menu\\FactoryInterface; use Knp\\Menu\\ItemInterface; use Symfony\\Component\\DependencyInjection\\ContainerAware;  class Builder extends ContainerAware {      public function mainMenu(FactoryInterface $factory, array $options)     {         $menuItems = $this-&gt;container-&gt;get('menu')-&gt;getMainMenu();         $menu = $factory-&gt;createItem('root');          $this-&gt;setCurrentItem($menu);          $menu-&gt;setChildrenAttribute('class', 'nav');         $menu-&gt;setExtra('currentElement', 'active');          foreach($menuItems as $item) {             $menu-&gt;addChild($item-&gt;getTitle(), array('uri' =&gt; $item-&gt;getRoute()));         }          return $menu;     }      protected function setCurrentItem(ItemInterface $menu)     {         $menu-&gt;setCurrentUri($this-&gt;container-&gt;get('request')-&gt;getPathInfo());     } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0430\u043c Builder \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 ContainerAware \u0442\u043e \u0443 \u043d\u0430\u0441 \u044f\u0432\u043d\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c $this-&gt;container-&gt;get(), \u0430 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043c\u0435\u043d\u044e. \u0421\u043a\u0430\u0437\u0430\u043d\u043e \u2014 \u0441\u0434\u0435\u043b\u0430\u043d\u043e. <\/p>\n<p>  \u0412 \u043f\u0430\u043f\u043a\u0435 \u0431\u0430\u043d\u0434\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 Service \u0430 \u0432 \u043d\u0435\u0439 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b MenuService.php. \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043a\u043e\u0434, \u0434\u0430\u0432\u0430\u0439 \u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c, \u0442\u043e \u0435\u0441\u0442\u044c, \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b MyFolder\/MenuBundle\/Resources\/config\/services.yml \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0431\u044b \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043d\u0438\u0436\u0435\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"php\">parameters:  services:   menu:         class: MyFolder\\MenuBundle\\Service\\MenuService         arguments: [@service_container]    admin.menu:         class: MyFolder\\MenuBundle\\Admin\\MenuAdmin         tags:         - { name:  sonata.admin, manager_type: orm, group: \u041c\u0435\u043d\u044e, label: \u041c\u0435\u043d\u044e}         arguments: [null, MyFolder\\MenuBundle\\Entity\\Menu, SonataAdminBundle:CRUD]    admin.menu_type:           class: MyFolder\\MenuBundle\\Admin\\MenuTypeAdmin           tags:           - { name:  sonata.admin, manager_type: orm, group: \u041c\u0435\u043d\u044e \u0422\u0438\u043f, label: \u041c\u0435\u043d\u044e \u0422\u0438\u043f}           arguments: [null, MyFolder\\MenuBundle\\Entity\\MenuType, SonataAdminBundle:CRUD] <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 <b>MyFolder\/MenuBundle\/Service\/MenuService<\/b>  <\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Service;  use Symfony\\Component\\DependencyInjection\\Container;  class MenuService {     private $doctrine;     private $container;     private $menuRepository;      public function __construct(Container $container)     {         $this-&gt;container = $container;         $this-&gt;doctrine = $this-&gt;container-&gt;get('doctrine');         $this-&gt;menuRepository = $this-&gt;doctrine-&gt;getRepository('MenuBundle:Menu');     }      public function getMainMenu()     {         return $this-&gt;menuRepository-&gt;getMainMenu();     } } <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0438\u0437 Menu.php \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438<br \/>  <b>* <a href=\"http:\/\/habrahabr.ru\/users\/orm\/\" class=\"user_link\">ORM<\/a>\\Entity(repositoryClass=\u201cMyFolder\\MenuBundle\\Entity\\MenuRepository&quot;)<\/b><br \/>  \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b MenuRepository.php \u0438 \u043a\u043e\u0434 \u0432 \u043d\u0435\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"php\">namespace MyFolder\\MenuBundle\\Entity;  use Doctrine\\ORM\\EntityRepository;  use Doctrine\\ORM\\Query\\ResultSetMapping;  class MenuRepository extends EntityRepository {    public function getMainMenu()     {         return $this-&gt;findBy(array('menuTypeId' =&gt; 1));     } } <\/code><\/pre>\n<p>  \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0442\u0430 \u0441\u0430\u043c\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c \u0432\u0441\u0435 \u043f\u0443\u043d\u043a\u0442\u044b \u043c\u0435\u043d\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u201c\u0413\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u041c\u0435\u043d\u044e\u201d \u0442\u0438\u043f\u0443.<\/p>\n<p>  \u0417\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u043c: \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u043d\u044e, \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0435 twig \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443:  <\/p>\n<pre><code class=\"php\">{{ knp_menu_render('MenuBundle:Builder:mainMenu', { 'currentClass': 'active'}) }} <\/code><\/pre>\n<p>  CSS \u043a\u043b\u0430\u0441\u0441 active \u0431\u0443\u0434\u0435\u0442 \u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e. \u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u043c\u0435\u043d\u044e \u043a\u0430\u043a \u044f, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u043e\u0432 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434   <\/p>\n<pre><code class=\"php\">\/**      * @Template()      * @Route(&quot;\/custom\/{link}&quot;, name=&quot;_custom_page&quot;,  defaults={&quot;link&quot; = &quot;\/&quot;})      *\/     public function customAction($link)     {         return $this-&gt;render('CommonBundle:Default:commonPage.html.twig', array('page' =&gt; $link));     } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u043f\u0430\u043d\u0430\u0446\u0435\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440. \u0410 \u0432\u043e\u0442 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430 \u043c\u0435\u043d\u044e, \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0441\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442, \u0438 \u0435\u0441\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u043b\u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u043c\u043d\u043e\u0439, \u0438\u0431\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u0435\u0440\u043a\u0430, \u043c\u044b \u043b\u044e\u0431\u0438\u043c \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c. <\/p>\n<p>  P.S. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u044f\u0441\u043d\u0438\u043b \u0438\u043b\u0438 \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u044f\u0441\u043d\u0438\u043b, \u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443, \u043e\u0445\u043e\u0442\u043d\u043e \u0432\u0441\u0435\u043c \u043e\u0442\u0432\u0435\u0447\u0443. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/202072\/\"> http:\/\/habrahabr.ru\/post\/202072\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435. \u042f \u043b\u044e\u0431\u043b\u044e Symfony. \u041e\u043d\u0430 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0438 \u044f \u0435\u0435 \u043e\u0431\u043e\u0436\u0430\u044e. \u0415\u0449\u0435 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f SonataAdminBundle. \u0414\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u043c \u0438\u0437 \u0432\u0430\u0441 \u0442\u043e\u0436\u0435. \u0418\u0442\u0430\u043a, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u0430 \u043f\u0440\u0438 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 KNPMenuBundle + SonataAdminBundle. \u041f\u043e \u0441\u0443\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0435\u043d\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442 \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u043d\u0430 github\u2019e \u0441\u0430\u043c\u043e\u0433\u043e \u0431\u0430\u043d\u0434\u043b\u0430, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e \u0431\u044b \u043c\u0435\u043d\u044e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438? \u0417\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438\u0441\u044c? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-202072","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=202072"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202072\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}