Skip to content

Commit

Permalink
Removed FormAdvice, Added Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Jul 18, 2012
1 parent cbeb808 commit f54e28f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 146 deletions.
13 changes: 13 additions & 0 deletions src/Context/Engine.php
Expand Up @@ -122,6 +122,19 @@ public function addParamConverter(ParamConverter $converter)
$this->resolver->addConverter($converter);
}

/**
* Wrap service
*
* @param object $service
* @param array $options
*
* @return object
*/
public function wrap($service, array $options)
{
return new Proxy($this, $service, $options);
}

/**
* Execute a context from within the Engine.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Context/Plugins/Doctrine2/TransactionAdvice.php
Expand Up @@ -43,7 +43,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)

public function around(ContextInvocation $context)
{
if (!$context->getOption('tx')) {
if ( ! $context->getOption('tx')) {
return $context->invoke();
}

Expand Down
90 changes: 0 additions & 90 deletions src/Context/Plugins/Symfony2/FormAdvice.php

This file was deleted.

9 changes: 1 addition & 8 deletions src/Context/Plugins/Symfony2/Input/RequestInput.php
Expand Up @@ -27,14 +27,7 @@ public function hasData(array $options)

public function createData(array $options)
{
$contentType = $options['request']->headers->get('Content-Type');
$format = null;

if (strpos($contentType, "/xml") !== false) {
$format = "xml";
} else if (strpos($contentType, "application/json") !== false) {
$format = "json";
}
$format = $options['request']->getContentType();

$params = array_merge(
$options['request']->query->all(),
Expand Down
45 changes: 45 additions & 0 deletions src/Context/Proxy.php
@@ -0,0 +1,45 @@
<?php
/**
* Context
*
* LICENSE
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to kontakt@beberlei.de so I can send you a copy immediately.
*/

namespace Context;

use Context\Engine;

/**
* Context Engine Proxy
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class Proxy
{
private $engine;
private $delegatee;
private $options;

public function __construct(Engine $engine, $delegatee, array $options)
{
$this->engine = $engine;
$this->delegatee = $delegatee;
$this->options = $options;
}

public function __call($method, $args)
{
$options = $this->options;
$options['context'] = array($this->delegatee, $method);
$options['arguments'] = $args;

return $this->engine->execute($options);
}
}

47 changes: 0 additions & 47 deletions tests/Context/Tests/Plugins/Symfony2/FormAdviceTest.php

This file was deleted.

0 comments on commit f54e28f

Please sign in to comment.