Skip to content

Commit

Permalink
Merge 2d207f6 into c84a514
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodm committed Oct 21, 2014
2 parents c84a514 + 2d207f6 commit 753d690
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/Action/RequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,12 @@ protected function doForward($uri, \Symfony\Component\HttpFoundation\Request $re

// Consider using standard $_POST, $_FILES etc.
$subRequest = Request::create($uri, $request->getMethod(), $request->getMethod() == 'POST' ? $request->request->all() : $request->query->all(), $request->cookies->all(), $request->files->all(), $request->server->all());

// If it was a POST then ensure it also has any query parameters
if ($request->getMethod() == 'POST') {
$subRequest->query->add($request->query->all());
}

if ($request->getSession()) {
$subRequest->setSession($request->getSession());
}
Expand Down
26 changes: 18 additions & 8 deletions src/Util/RequestUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,23 @@ public static function populate($bean, $prefix, $suffix, \Symfony\Component\Http
$suffixLength = strlen($suffix);

// Build a list of revelant request parameters from this request
$properties = array ();
$names = $request->query->keys();
$properties = self::treatRequestProperties($request, $prefix, $suffix, $request->query->keys());
$properties = array_merge($properties, self::treatRequestProperties($request, $prefix, $suffix, $request->request->keys()));

// Set the corresponding properties of our bean
try {
\Phruts\Util\BeanUtils::populate($bean, $properties);
} catch (\Exception $e) {
throw new \Phruts\Exception('\Phruts\Util\BeanUtils->populate() - ' . $e->getMessage());
}
}

private static function treatRequestProperties(\Symfony\Component\HttpFoundation\Request $request, $prefix, $suffix, $names)
{
$prefixLength = strlen($prefix);
$suffixLength = strlen($suffix);

$properties = array();
foreach ($names as $name) {
$stripped = $name;
if ($prefix != '') {
Expand All @@ -205,12 +220,7 @@ public static function populate($bean, $prefix, $suffix, \Symfony\Component\Http
$properties[$stripped] = $request->get($name);
}

// Set the corresponding properties of our bean
try {
\Phruts\Util\BeanUtils::populate($bean, $properties);
} catch (\Exception $e) {
throw new \Phruts\Exception('\Phruts\Util\BeanUtils->populate() - ' . $e->getMessage());
}
return $properties;
}

/**
Expand Down

0 comments on commit 753d690

Please sign in to comment.