public function configureRoutes(RouteCollection $collection)
 {
     $collection->remove('edit');
     //remove all route except named ones
     //$collection->clearExcept(array('list', 'create', 'delete'));
     $collection->add('downloadFile', $this->getRouterIdParameter() . '/download');
 }
Esempio n. 2
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('appercu', $this->getRouterIdParameter() . '/appercu');
     $collection->add('sendtest', $this->getRouterIdParameter() . '/sendtest');
     $collection->add('send', $this->getRouterIdParameter() . '/send');
     $collection->add('ajaxsend', $this->getRouterIdParameter() . '/ajaxsend');
 }
 protected function configureRoutes(RouteCollection $collection)
 {
     // to remove a single route
     $collection->remove('delete');
     // OR remove all route except named ones
     $collection->clearExcept(array('list', 'show'));
 }
 /**
  * @param RouteCollection $collection
  *
  * @return \Sonata\AdminBundle\Route\RouteCollection
  */
 public function addCollection(RouteCollection $collection)
 {
     foreach ($collection->getElements() as $code => $route) {
         $this->elements[$code] = $route;
     }
     return $this;
 }
 protected function configureRoutes(RouteCollection $collection)
 {
     //$collection->remove('create');
     $collection->remove('delete');
     $collection->remove('export');
     $collection->remove('show');
 }
 public function testLoad()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $pool = $this->getMock('Sonata\\AdminBundle\\Admin\\Pool', array(), array($container, 'title', 'logoTitle'));
     $adminPoolLoader = new AdminPoolLoader($pool, array('foo_admin', 'bar_admin'), $container);
     $routeCollection1 = new RouteCollection('base.Code.Route.foo', 'baseRouteNameFoo', 'baseRoutePatternFoo', 'baseControllerNameFoo');
     $routeCollection2 = new RouteCollection('base.Code.Route.bar', 'baseRouteNameBar', 'baseRoutePatternBar', 'baseControllerNameBar');
     $routeCollection1->add('foo');
     $routeCollection2->add('bar');
     $routeCollection2->add('baz');
     $admin1 = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin1->expects($this->once())->method('getRoutes')->will($this->returnValue($routeCollection1));
     $admin2 = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin2->expects($this->once())->method('getRoutes')->will($this->returnValue($routeCollection2));
     $pool->expects($this->any())->method('getInstance')->will($this->returnCallback(function ($id) use($admin1, $admin2) {
         switch ($id) {
             case 'foo_admin':
                 return $admin1;
             case 'bar_admin':
                 return $admin2;
         }
         return;
     }));
     $collection = $adminPoolLoader->load('foo', 'sonata_admin');
     $this->assertInstanceOf('Symfony\\Component\\Routing\\RouteCollection', $collection);
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $collection->get('baseRouteNameFoo_foo'));
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $collection->get('baseRouteNameBar_bar'));
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $collection->get('baseRouteNameBar_bar'));
 }
 public function testBuildWithChildren()
 {
     $audit = $this->getMock('Sonata\\AdminBundle\\Model\\AuditManagerInterface');
     $audit->expects($this->once())->method('hasReader')->will($this->returnValue(true));
     $childRouteCollection1 = new RouteCollection('child1.Code.Route', 'child1RouteName', 'child1RoutePattern', 'child1ControllerName');
     $childRouteCollection1->add('foo');
     $childRouteCollection1->add('bar');
     $childRouteCollection2 = new RouteCollection('child2.Code.Route', 'child2RouteName', 'child2RoutePattern', 'child2ControllerName');
     $childRouteCollection2->add('baz');
     $child1 = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $child1->expects($this->once())->method('getRoutes')->will($this->returnValue($childRouteCollection1));
     $child2 = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $child2->expects($this->once())->method('getRoutes')->will($this->returnValue($childRouteCollection2));
     $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin->expects($this->once())->method('getParent')->will($this->returnValue(null));
     $admin->expects($this->once())->method('getChildren')->will($this->returnValue(array($child1, $child2)));
     $admin->expects($this->once())->method('isAclEnabled')->will($this->returnValue(true));
     $routeCollection = new RouteCollection('base.Code.Route', 'baseRouteName', 'baseRoutePattern', 'baseControllerName');
     $pathBuilder = new QueryStringBuilder($audit);
     $pathBuilder->build($admin, $routeCollection);
     $expectedRoutes = array('list', 'create', 'batch', 'edit', 'delete', 'show', 'export', 'history', 'history_view_revision', 'acl', 'child1.Code.Route.foo', 'child1.Code.Route.bar', 'child2.Code.Route.baz');
     $this->assertCount(count($expectedRoutes), $routeCollection->getElements());
     foreach ($expectedRoutes as $expectedRoute) {
         $this->assertTrue($routeCollection->has($expectedRoute), sprintf('Expected route: "%s" doesn`t exist.', $expectedRoute));
     }
 }
Esempio n. 8
0
 /**
  * {@inheritdoc}
  */
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('createFromPage', 'create_from_page/root_id/{rootId}/page_id/{pageId}', array(), array('_method' => 'GET|POST', 'rootId', 'pageId'));
     $collection->add('ajaxController', 'ajax_navigation', array(), array('_method' => 'GET|POST'));
     $collection->add('newPlacement', 'new_placement/{newMenuItemId}/{menuItemId}', array(), array('_method' => 'GET|POST', 'newMenuItemId', 'menuItemId'));
     $collection->add('placement', 'placement', array(), array('_method' => 'GET|POST'));
 }
Esempio n. 9
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('import');
     // Action gets added automatically
     $collection->add('view', $this->getRouterIdParameter() . '/view');
     //        $collection->remove('create');
 }
Esempio n. 10
0
 public function configureRoutes(RouteCollection $collection)
 {
     $collection->add('ProductUpload');
     // add custom action name which you created in controller for which you want to generate route.
     $collection->remove('delete');
     //$collection->remove('list');
 }
Esempio n. 11
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('import');
     // Suffix Action gets added automatically eg. this becomes importAction
     $collection->add('view', $this->getRouterIdParameter() . '/view');
     $collection->add('importProcess');
 }
 protected function setUp()
 {
     $this->application = new Application();
     $command = new ExplainAdminCommand();
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $this->admin->expects($this->any())->method('getCode')->will($this->returnValue('foo'));
     $this->admin->expects($this->any())->method('getClass')->will($this->returnValue('Acme\\Entity\\Foo'));
     $this->admin->expects($this->any())->method('getBaseControllerName')->will($this->returnValue('SonataAdminBundle:CRUD'));
     $routeCollection = new RouteCollection('foo', 'fooBar', 'foo-bar', 'SonataAdminBundle:CRUD');
     $routeCollection->add('list');
     $routeCollection->add('edit');
     $this->admin->expects($this->any())->method('getRoutes')->will($this->returnValue($routeCollection));
     $fieldDescription1 = $this->getMock('Sonata\\AdminBundle\\Admin\\FieldDescriptionInterface');
     $fieldDescription1->expects($this->any())->method('getType')->will($this->returnValue('text'));
     $fieldDescription1->expects($this->any())->method('getTemplate')->will($this->returnValue('SonataAdminBundle:CRUD:foo_text.html.twig'));
     $fieldDescription2 = $this->getMock('Sonata\\AdminBundle\\Admin\\FieldDescriptionInterface');
     $fieldDescription2->expects($this->any())->method('getType')->will($this->returnValue('datetime'));
     $fieldDescription2->expects($this->any())->method('getTemplate')->will($this->returnValue('SonataAdminBundle:CRUD:bar_datetime.html.twig'));
     $this->admin->expects($this->any())->method('getListFieldDescriptions')->will($this->returnValue(array('fooTextField' => $fieldDescription1, 'barDateTimeField' => $fieldDescription2)));
     $this->admin->expects($this->any())->method('getFilterFieldDescriptions')->will($this->returnValue(array('fooTextField' => $fieldDescription1, 'barDateTimeField' => $fieldDescription2)));
     $this->admin->expects($this->any())->method('getFormTheme')->will($this->returnValue(array('FooBundle::bar.html.twig')));
     $this->admin->expects($this->any())->method('getFormFieldDescriptions')->will($this->returnValue(array('fooTextField' => $fieldDescription1, 'barDateTimeField' => $fieldDescription2)));
     $this->admin->expects($this->any())->method('isChild')->will($this->returnValue(true));
     // php 5.3 BC
     $adminParent = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $adminParent->expects($this->any())->method('getCode')->will($this->returnValue('foo_child'));
     $this->admin->expects($this->any())->method('getParent')->will($this->returnCallback(function () use($adminParent) {
         return $adminParent;
     }));
     // Prefer Symfony 2.x interfaces
     if (interface_exists('Symfony\\Component\\Validator\\MetadataFactoryInterface')) {
         $this->validatorFactory = $this->getMock('Symfony\\Component\\Validator\\MetadataFactoryInterface');
         $validator = $this->getMock('Symfony\\Component\\Validator\\ValidatorInterface');
         $validator->expects($this->any())->method('getMetadataFactory')->will($this->returnValue($this->validatorFactory));
     } else {
         $this->validatorFactory = $this->getMock('Symfony\\Component\\Validator\\Mapping\\Factory\\MetadataFactoryInterface');
         $validator = $this->getMock('Symfony\\Component\\Validator\\Validator\\ValidatorInterface');
         $validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($this->validatorFactory));
     }
     // php 5.3 BC
     $admin = $this->admin;
     $container->expects($this->any())->method('get')->will($this->returnCallback(function ($id) use($container, $admin, $validator) {
         switch ($id) {
             case 'sonata.admin.pool':
                 $pool = new Pool($container, '', '');
                 $pool->setAdminServiceIds(array('acme.admin.foo', 'acme.admin.bar'));
                 return $pool;
             case 'validator':
                 return $validator;
             case 'acme.admin.foo':
                 return $admin;
         }
         return;
     }));
     $command->setContainer($container);
     $this->application->add($command);
 }
 public function testRouteControllerService()
 {
     $routeCollection = new RouteCollection('baseCodeRoute', 'baseRouteName', 'baseRoutePattern', 'baseControllerServiceName');
     $routeCollection->add('view');
     $route = $routeCollection->get('view');
     $this->assertEquals('baseControllerServiceName:viewAction', $route->getDefault('_controller'));
     $this->assertEquals('baseCodeRoute', $route->getDefault('_sonata_admin'));
     $this->assertEquals('baseRouteName_view', $route->getDefault('_sonata_name'));
 }
Esempio n. 14
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate');
     $collection->add('edit', $this->getRouterIdParameter() . '/edit');
     $collection->add('delete', $this->getRouterIdParameter() . '/delete');
     $collection->add('clearCache', 'clearcache');
     $collection->add('clearCacheProd', 'clearcacheprod');
     $collection->add('clearHTTPCache', 'clearhttpcache');
 }
Esempio n. 15
0
 protected function configureRoutes(RouteCollection $collection)
 {
     // on top
     $collection->add('crawl-indexes', 'crawl-indexes');
     $collection->add('crawl-links', 'crawl-links');
     $collection->add('crawl-url', 'crawl-url');
     // on list
     $collection->add('crawl-link', $this->getRouterIdParameter() . '/crawl');
 }
 protected function configureRoutes(RouteCollection $collection)
 {
     // get entity manager
     $em = $this->getConfigurationPool()->getContainer()->get('Doctrine')->getManager();
     // find all periods
     $periods = $em->getRepository('TmcycyitNotificationBundle:HistoryPeriod')->findAll();
     // remove create button, if there is one periods
     if (count($periods) >= 1) {
         $collection->remove('create');
     }
 }
Esempio n. 17
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('rrhhValorPagado');
     $collection->add('rrhhDistribucionHora');
     $collection->add('rrhhCostos');
     $collection->add('gaAf');
     $collection->add('gaCompromisosFinancieros');
     $collection->add('gaVariables');
     $collection->add('gaDistribucion');
     $collection->add('gaCostos');
     $collection->add('almacenDatos');
 }
Esempio n. 18
0
 /**
  * {@inheritdoc}
  */
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('translatePage', 'translate_page/{id}/locale/{locale}', array(), array('method' => 'POST'));
     $collection->add('parentPageList', 'parent_page/', array(), array('method' => 'GET'));
     $collection->add('link', 'link/{id}/locale/{locale}', array(), array('method' => 'GET'));
     $collection->add('draft', 'draft/{id}', array(), array('method' => 'GET'));
     $collection->add('review', 'review/{id}', array(), array('method' => 'GET'));
     $collection->add('publish', 'publish/{id}', array(), array('method' => 'GET'));
     $collection->add('cancelDraft', 'cancel_draft/{id}', array(), array('method' => 'GET'));
     $collection->add('getPath', 'get_path/', array(), array('method' => 'GET'));
     $collection->add('unlink', 'unlink/{id}/translation_id/{translationId}', array(), array('method' => 'GET|DELETE'));
 }
 /**
  * RouteBuilder that allows slashes in the ids.
  *
  * {@inheritDoc}
  */
 function build(AdminInterface $admin, RouteCollection $collection)
 {
     $collection->add('list');
     $collection->add('create');
     $collection->add('batch', null, array(), array('_method' => 'POST'));
     $collection->add('edit', $admin->getRouterIdParameter() . '/edit', array(), array('id' => '.+'));
     $collection->add('delete', $admin->getRouterIdParameter() . '/delete', array(), array('id' => '.+'));
     $collection->add('export');
     $collection->add('show', $admin->getRouterIdParameter() . '/show', array(), array('id' => '.+', '_method' => 'GET'));
     if ($admin->isAclEnabled()) {
         $collection->add('acl', $admin->getRouterIdParameter() . '/acl', array(), array('id' => '.+'));
     }
     // add children urls
     foreach ($admin->getChildren() as $children) {
         $collection->addCollection($children->getRoutes());
     }
 }
 /**
  * RouteBuilder that allowes slashes in the ids.
  *
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @param \Sonata\AdminBundle\Route\RouteCollection $collection
  */
 function build(AdminInterface $admin, RouteCollection $collection)
 {
     $collection->add('list');
     $collection->add('create');
     $collection->add('batch');
     $collection->add('edit', $admin->getRouterIdParameter() . '/edit', array(), array('id' => '.+'));
     $collection->add('delete', $admin->getRouterIdParameter() . '/delete', array(), array('id' => '.+'));
     $collection->add('show', $admin->getRouterIdParameter(), array(), array('id' => '.+', '_method' => 'GET'));
     // add children urls
     foreach ($admin->getChildren() as $children) {
         $collection->addCollection($children->getRoutes());
     }
 }
Esempio n. 21
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('create_stub', 'stub');
     $collection->add('importGame', 'import');
     $collection->add('priority', $this->getRouterIdParameter() . '/priority');
     $collection->add('statistic', $this->getRouterIdParameter() . '/statistic');
     $collection->add('exportGame', $this->getRouterIdParameter() . '/export');
 }
 /**
  * {@inheritdoc}
  */
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->remove('create');
     $collection->remove('show');
     $collection->remove('edit');
     $collection->remove('export');
     $collection->remove('batch');
 }
 /**
  * Gets named option from current route.
  *
  * @param string $name
  *
  * @return string|null
  */
 protected function getRoutingOption($name)
 {
     $option = null;
     if (!$this->routeCollection instanceof RouteCollection) {
         $this->routeCollection = $this->getRoutesCollection();
     }
     $route = $this->routeCollection->get($this->container->get('request')->get('_route'));
     if ($route instanceof Route) {
         $option = $route->getOption($name);
     }
     if (!$option && isset($this->redirectConf[$name])) {
         $option = $this->redirectConf[$name]['action'];
     }
     if (in_array($option, array(self::REDIRECT, self::REDIRECT_WITHOUT_PATH, self::NO_REDIRECT))) {
         return $option;
     }
     return null;
 }
Esempio n. 24
0
 protected function configureRoutes(RouteCollection $collection)
 {
     // to remove a single route
     $collection->remove('create');
     $collection->remove('delete');
 }
Esempio n. 25
0
 /**
  * @param RouteCollection $collection
  */
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('jsonTreeSource')->add('ajaxAdd')->add('ajaxRename')->add('ajaxDelete')->add('ajaxMove')->add('ajaxDetails');
 }
Esempio n. 26
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('showMessages', $this->getRouterIdParameter() . '/list');
 }
Esempio n. 27
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->remove('create');
 }
Esempio n. 28
0
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('clearCache');
 }
Esempio n. 29
-1
 protected function configureRoutes(RouteCollection $collection)
 {
     $collection->add('delivered');
     $collection->add('open');
     $collection->add('print');
     $collection->remove('create');
 }
 protected function configureRoutes(RouteCollection $collection)
 {
     if (!$this->isDevelopment()) {
         // Remove delete route in production env
         $collection->remove('delete');
     }
 }