-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05d22e6
Showing
10 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* Class Configuration | ||
* @package EzSystems\RESTAPIExtensionExampleBundle\DependencyInjection | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('ez_systems_restapi_extension_example'); | ||
return $treeBuilder; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
DependencyInjection/EzSystemsRESTAPIExtensionExampleExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* Class EzSystemsRESTAPIExtensionExampleExtension | ||
* @package EzSystems\RESTAPIExtensionExampleBundle\DependencyInjection | ||
*/ | ||
class EzSystemsRESTAPIExtensionExampleExtension extends Extension | ||
{ | ||
/** | ||
* @param array $configs | ||
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
/** | ||
* Class EzSystemsRESTAPIExtensionExampleBundle | ||
* @package EzSystems\RESTAPIExtensionExampleBundle | ||
*/ | ||
class EzSystemsRESTAPIExtensionExampleBundle extends Bundle | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ez_systems_restapi_extension_example_hello: | ||
path: /rest/example/hello/{name} | ||
defaults: | ||
_controller: ez_systems_restapi_extension_example.controller:hello | ||
methods: [GET] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
parameters: | ||
ez_systems_restapi_extension_example.controller.class: EzSystems\RESTAPIExtensionExampleBundle\Rest\Controller\RESTExampleController | ||
ez_systems_restapi_extension_example.value_object_visitor.class: EzSystems\RESTAPIExtensionExampleBundle\Rest\ValueObjectVisitor\Hello | ||
ez_systems_restapi_extension_example.input_parser.class: EzSystems\RESTAPIExtensionExampleBundle\Rest\InputParser\Hello | ||
services: | ||
ez_systems_restapi_extension_example.controller: | ||
class: %ez_systems_restapi_extension_example.controller.class% | ||
ez_systems_restapi_extension_example.value_object_visitor: | ||
parent: ezpublish_rest.output.value_object_visitor.base | ||
class: %ez_systems_restapi_extension_example.value_object_visitor.class% | ||
tags: | ||
- { name: ezpublish_rest.output.value_object_visitor, type: EzSystems\RESTAPIExtensionExampleBundle\Rest\Values\Hello } | ||
ez_systems_restapi_extension_example.input_parser: | ||
parent: ezpublish_rest.input.parser | ||
class: %ez_systems_restapi_extension_example.input_parser.class% | ||
tags: | ||
- { name: ezpublish_rest.input.parser, mediaType: application/vnd.ez.api.Hello } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle\Rest\Controller; | ||
|
||
use EzSystems\RESTAPIExtensionExampleBundle\Rest\Values\Hello; | ||
use eZ\Publish\Core\REST\Server\Controller; | ||
|
||
/** | ||
* Class RESTExampleController | ||
* @package EzSystems\RESTAPIExtensionExampleBundle\Rest\Controller | ||
*/ | ||
class RESTExampleController extends Controller | ||
{ | ||
/** | ||
* @param $name | ||
* @return \EzSystems\RESTAPIExtensionExampleBundle\Rest\Values\Hello | ||
*/ | ||
public function hello($name) | ||
{ | ||
return new Hello($name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle\Rest\InputParser; | ||
|
||
use eZ\Publish\Core\REST\Common\Input\BaseParser; | ||
use eZ\Publish\Core\REST\Common\Input\ParsingDispatcher; | ||
use eZ\Publish\Core\REST\Common\Exceptions; | ||
use EzSystems\RESTAPIExtensionExampleBundle\Rest\Values\Hello as HelloValue; | ||
|
||
/** | ||
* Class Hello | ||
* @package EzSystems\RESTAPIExtensionExampleBundle\Rest\InputParser | ||
*/ | ||
class Hello extends BaseParser | ||
{ | ||
/** | ||
* @param array $data | ||
* @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher | ||
* @return \EzSystems\RESTAPIExtensionExampleBundle\Rest\Values\Hello | ||
*/ | ||
public function parse(array $data, ParsingDispatcher $parsingDispatcher) | ||
{ | ||
if (!isset($data['name'])) { | ||
throw new Exceptions\Parser("Missing or ivalid 'name' element for Hello."); | ||
} | ||
return new HelloValue($data['name']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle\Rest\ValueObjectVisitor; | ||
|
||
use eZ\Publish\Core\REST\Common\Output\Generator; | ||
use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor; | ||
use eZ\Publish\Core\REST\Common\Output\Visitor; | ||
|
||
/** | ||
* Class Hello | ||
* @package EzSystems\RESTAPIExtensionExampleBundle\Rest\ValueObjectVisitor | ||
*/ | ||
class Hello extends ValueObjectVisitor | ||
{ | ||
/** | ||
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor | ||
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator | ||
* @param mixed $data | ||
*/ | ||
public function visit(Visitor $visitor, Generator $generator, $data) | ||
{ | ||
$generator->startHashElement("Hello"); | ||
$generator->startAttribute("name", $data->name); | ||
$generator->endAttribute("name"); | ||
$generator->endHashElement("Hello"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace EzSystems\RESTAPIExtensionExampleBundle\Rest\Values; | ||
|
||
use eZ\Publish\API\Repository\Values\ValueObject; | ||
|
||
/** | ||
* Class Hello | ||
* @package EzSystems\RESTAPIExtensionExampleBundle\Rest\Values | ||
*/ | ||
class Hello extends ValueObject | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* Hello constructor. | ||
* @param string $name | ||
*/ | ||
public function __construct(string $name) | ||
{ | ||
parent::__construct(); | ||
$this->name = $name; | ||
} | ||
} |