コード例 #1
0
 public function testHasNoSource()
 {
     $this->mapper = new FieldPresenceEnhancer(null, '_controller', 'cmf_content.controller:indexAction');
     $defaults = array('foo' => 'bar');
     $expected = array('foo' => 'bar', '_controller' => 'cmf_content.controller:indexAction');
     $this->assertEquals($expected, $this->mapper->enhance($defaults, $this->request));
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  *
  * The controller service string is added by the parent. This method will simply add the action method
  * depending on the given method.
  */
 public function enhance(array $defaults, Request $request)
 {
     $defaults = parent::enhance($defaults, $request);
     if (isset($defaults[$this->target])) {
         if (preg_match('/:/', $defaults[$this->target])) {
             return $defaults;
         }
         if (isset($defaults[$this->target]) && array_key_exists($request->getMethod(), $this->supportedMethods)) {
             $defaults[$this->target] .= ':' . $this->supportedMethods[$request->getMethod()];
         }
     }
     return $defaults;
 }