-
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 40701bc
Showing
9 changed files
with
156 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,22 @@ | ||
# OrocrmFirstnameApiBundle | ||
|
||
## Introduction | ||
Define Oro Contact 'firstName' field as filter and sorter in OroCRM REST JSON API. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ composer require pedrofurtado/orocrm-firstname-api-bundle | ||
``` | ||
|
||
# Commands | ||
After installation of this Oro Bundle, execute in root folder of oro project: | ||
|
||
```bash | ||
$ php app/console oro:api:cache:clear | ||
$ php app/console oro:api:doc:cache:clear | ||
$ php app/console cache:clear | ||
$ php app/console oro:migration:load --force --show-queries | ||
``` | ||
|
||
Then, restart the application, clear all caches, and enjoy it! |
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 @@ | ||
{ | ||
"name": "pedrofurtado/orocrm-firstname-api-bundle", | ||
"type": "symfony-bundle", | ||
"description": "Define Oro Contact 'firstName' field as filter and sorter in OroCRM JSON API.", | ||
"keywords": ["orocrm", "oroplatform", "oro"], | ||
"homepage": "https://github.com/pedrofurtado/orocrm-firstname-api-bundle", | ||
"license": "MIT", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"authors": [ | ||
{ | ||
"name": "Pedro Furtado", | ||
"email": "pedro.felipe.furtado@usp.br" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.1", | ||
"oro/crm": ">=2.6.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { "OrocrmFirstnameApi\\Bundle\\": "src/OrocrmFirstnameApi/Bundle" } | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/OrocrmFirstnameApi/Bundle/DependencyInjection/Configuration.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,29 @@ | ||
<?php | ||
|
||
namespace OrocrmFirstnameApi\Bundle\OrocrmFirstnameApiBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from your app/config files. | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html} | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('oro_firstname_api'); | ||
|
||
// Here you should define the parameters that are allowed to | ||
// configure your bundle. See the documentation linked above for | ||
// more information on that topic. | ||
|
||
return $treeBuilder; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/OrocrmFirstnameApi/Bundle/DependencyInjection/OroFirstnameApiExtension.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 OrocrmFirstnameApi\Bundle\OrocrmFirstnameApiBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* This is the class that loads and manages your bundle configuration. | ||
* | ||
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html | ||
*/ | ||
class OrocrmFirstnameApiExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
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'); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/OrocrmFirstnameApi/Bundle/Migrations/Schema/v1_0/CreateIndexForFirstName.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,27 @@ | ||
<?php | ||
|
||
namespace OrocrmFirstnameApi\Bundle\Migrations\Schema\v1_0; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension; | ||
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface; | ||
use Oro\Bundle\MigrationBundle\Migration\Migration; | ||
use Oro\Bundle\MigrationBundle\Migration\QueryBag; | ||
|
||
class CreateIndexForFirstName implements Migration, ExtendExtensionAwareInterface | ||
{ | ||
/** | ||
* @inheritdoc | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function setExtendExtension(ExtendExtension $extendExtension) | ||
{ | ||
$this->extendExtension = $extendExtension; | ||
} | ||
|
||
public function up(Schema $schema, QueryBag $queries) | ||
{ | ||
$table = $schema->getTable('orocrm_contact'); | ||
$table->addIndex(['first_name'], 'orocrm_contact_first_name_idx', []); | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace OrocrmFirstnameApi\Bundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class OrocrmFirstnameApiBundle extends Bundle | ||
{ | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OrocrmFirstnameApi/Bundle/Resources/config/oro/api.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,15 @@ | ||
api: | ||
entities: | ||
Oro\Bundle\ContactBundle\Entity\Contact: | ||
filters: | ||
fields: | ||
firstName: | ||
exclude: false | ||
data_type: string | ||
property_path: firstName | ||
description: "Filter records by 'firstName' field." | ||
sorters: | ||
fields: | ||
firstName: | ||
exclude: false | ||
property_path: firstName |
2 changes: 2 additions & 0 deletions
2
src/OrocrmFirstnameApi/Bundle/Resources/config/oro/bundles.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,2 @@ | ||
bundles: | ||
- { name: OrocrmFirstnameApi\Bundle\OrocrmFirstnameApiBundle, priority: 800 } |
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 @@ | ||
# |