Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function filterValue($value)
 {
     $return = array();
     $actions = $this->getOption('actions');
     foreach ($actions as $name => $options) {
         $options = $this->actionOptionsResolver->resolve((array) $options);
         $return[$name] = array();
         $parameters = array();
         $urlAttributes = $options['url_attr'];
         $content = $options['content'];
         if (isset($options['parameters_field_mapping'])) {
             foreach ($options['parameters_field_mapping'] as $parameterName => $mappingField) {
                 if ($mappingField instanceof \Closure) {
                     $parameters[$parameterName] = $mappingField($value, $this->getIndex());
                 } else {
                     $parameters[$parameterName] = $value[$mappingField];
                 }
             }
         }
         if (isset($options['additional_parameters'])) {
             foreach ($options['additional_parameters'] as $parameterValueName => $parameterValue) {
                 $parameters[$parameterValueName] = $parameterValue;
             }
         }
         if ($options['redirect_uri'] !== false) {
             if (is_string($options['redirect_uri'])) {
                 $parameters['redirect_uri'] = $options['redirect_uri'];
             }
             if ($options['redirect_uri'] === true) {
                 $parameters['redirect_uri'] = $this->container->get('request')->getRequestUri();
             }
         }
         if ($urlAttributes instanceof \Closure) {
             $urlAttributes = $urlAttributes($value, $this->getIndex());
             if (!is_array($urlAttributes)) {
                 throw new UnexpectedTypeException('url_attr option Clousure must return new array with url attributes.');
             }
         }
         $url = $this->router->generate($options['route_name'], $parameters, $options['absolute']);
         if (!isset($urlAttributes['href'])) {
             $urlAttributes['href'] = $url;
         }
         if (isset($content) && $content instanceof \Closure) {
             $content = (string) $content($value, $this->getIndex());
         }
         // $return[$name]['url'] is deprecated since 1.0 and will be removed in version 1.2
         $return[$name]['url'] = $url;
         $return[$name]['content'] = isset($content) ? $content : $name;
         $return[$name]['field_mapping_values'] = $value;
         $return[$name]['url_attr'] = $urlAttributes;
     }
     return $return;
 }
 /**
  * {@inheritdoc}
  */
 public function filterValue(ColumnTypeInterface $column, $value)
 {
     $this->validateOptions($column);
     $return = array();
     $actions = $column->getOption('actions');
     foreach ($actions as $name => $options) {
         $return[$name] = array('name' => $name, 'anchor' => $options['anchor']);
         $parameters = array();
         if (isset($options['parameters'])) {
             foreach ($options['parameters'] as $mappingField => $parameterName) {
                 $parameters[$parameterName] = $value[$mappingField];
             }
         }
         if (isset($options['parameters_values'])) {
             foreach ($options['parameters_values'] as $parameterValueName => $parameterValue) {
                 $parameters[$parameterValueName] = $parameterValue;
             }
         }
         $url = $this->router->generate($options['route_name'], $parameters, $options['absolute']);
         $return[$name]['url'] = $url;
     }
     return $return;
 }
 private function processRoutes($onDemand)
 {
     $this->context = new RequestContext();
     $this->context->fromRequest(Request::createFromGlobals());
     /* delete previous route cache if exists */
     @unlink(UbirimiContainer::get()['app.cacheDir'] . '/ProjectUrlMatcher.php');
     /* these are the routing yaml files that are loaded regardless of deployment context (onDemand, download) */
     $routingPaths = array(__DIR__ . '/../Yongo/Resources/config', __DIR__ . '/../Documentador/Resources/config', __DIR__ . '/../SvnHosting/Resources/config', __DIR__ . '/../Agile/Resources/config', __DIR__ . '/../HelpDesk/Resources/config', __DIR__ . '/../Calendar/Resources/config', __DIR__ . '/../GeneralSettings/Resources/config', __DIR__ . '/../QuickNotes/Resources/config', __DIR__ . '/../Api/Resources/config');
     /* for these two projects, the administration routes are in routing_administration files, so load them separately */
     $routingPathsAdministration = array(__DIR__ . '/../Yongo/Resources/config', __DIR__ . '/../SvnHosting/Resources/config');
     $options = array('cache_dir' => UbirimiContainer::get()['app.cacheDir']);
     $this->router = new Router(new YamlFileLoader(new FileLocator(__DIR__ . '/../Yongo/Resources/config')), 'routing.yml', $options, $this->context);
     $loader = new YamlFileLoader(new FileLocator(__DIR__ . '/../Frontend/Resources/config'));
     $this->router->getRouteCollection()->addCollection($routeCollection = $loader->load('routing.yml'));
     foreach ($routingPaths as $routingPath) {
         $loader = new YamlFileLoader(new FileLocator($routingPath));
         $this->router->getRouteCollection()->addCollection($routeCollection = $loader->load('routing.yml'));
     }
     foreach ($routingPathsAdministration as $routingPath) {
         $loader = new YamlFileLoader(new FileLocator($routingPath));
         $this->router->getRouteCollection()->addCollection($routeCollection = $loader->load('routing_administration.yml'));
     }
 }