Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrofurtado committed Oct 23, 2018
0 parents commit 40701bc
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
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!
23 changes: 23 additions & 0 deletions composer.json
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" }
}
}
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;
}
}
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');
}
}
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', []);
}
}
9 changes: 9 additions & 0 deletions src/OrocrmFirstnameApi/Bundle/OrocrmFirstnameApiBundle.php
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 src/OrocrmFirstnameApi/Bundle/Resources/config/oro/api.yml
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundles:
- { name: OrocrmFirstnameApi\Bundle\OrocrmFirstnameApiBundle, priority: 800 }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#

0 comments on commit 40701bc

Please sign in to comment.