Skip to content

Commit

Permalink
init bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
welcoMattic committed Jan 11, 2016
1 parent c58a9b3 commit 0adf9e3
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
9 changes: 9 additions & 0 deletions ApacheTikaBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace welcoMattic\ApacheTikaBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class ApacheTikaBundle extends Bundle
{
}
44 changes: 44 additions & 0 deletions DependencyInjection/ApacheTikaExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace welcoMattic\ApacheTikaBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use welcoMattic\ApacheTikaBundle\DependencyInjection\Configuration;

class ApacheTikaExtension extends Extension
{
/**
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.yml');

$container->setParameter('apache_tika.config.tika_path', isset($config['tika_config']['tika_path']) ? $config['tika_config']['tika_path'] : null);
$container->setParameter('apache_tika.config.tika_host', $config['tika_config']['tika_host']);
$container->setParameter('apache_tika.config.tika_port', $config['tika_config']['tika_port']);
$clientClass = $container->getParameter('apache_tika.config.tika_path') ? 'Vaites\\ApacheTika\\Clients\\CliClient' : 'Vaites\\ApacheTika\\Clients\\WebClient';
$container->setParameter('apache_tika.config.tika_client_class', $clientClass);
}

/**
* @param array $config
* @param ContainerBuilder $container
* @return Configuration
*/
public function getConfiguration(array $config, ContainerBuilder $container)
{
return new Configuration($container->getParameter('apache_tika'));
}
}
36 changes: 36 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace welcoMattic\ApacheTikaBundle\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/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('apache_tika');

$rootNode
->children()
->arrayNode('tika_config')
->children()
->scalarNode('tika_path')->end()
->scalarNode('tika_host')->isRequired()->defaultValue('127.0.0.1')->end()
->scalarNode('tika_port')->isRequired()->defaultValue('9998')->end()
->end()
->end() // tika_config
->end()
;
return $treeBuilder;
}
}
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Installation
============

Step 1: Download the Bundle
---------------------------

Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:

```bash
$ composer require welcoMattic/apache-tika-bundle "~0.1"
```

This command requires you to have Composer installed globally, as explained
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.

Step 2: Enable the Bundle
-------------------------

Then, enable the bundle by adding it to the list of registered bundles
in the `app/AppKernel.php` file of your project:

```php
<?php

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new welcoMattic\ApacheTikaBundle(),
// ...
];
}
}
```

11 changes: 11 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
apache_tika:
tika_config:
tika_path: bin/tika-app.jar
tika_host: localhost
tika_port: 9998

services:
apache_tika.client:
class: %apache_tika.config.tika_client_class%

20 changes: 20 additions & 0 deletions Resources/meta/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 welcoMattic <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 14 additions & 5 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{
"name": "welcomattic/apache-tika-bundle",
"description": "Symfony Bundle for (php-apache-tika)[https://github.com/vaites/php-apache-tika]",
"require": {
"vaites/php-apache-tika": "^0.3.0"
},
"description": "Symfony Bundle for https://github.com/vaites/php-apache-tika",
"type": "symfony-bundle",
"keywords": ["apache", "tika", "pdf", "doc", "docx", "ppt", "pptx", "odt", "office", "documents", "ocr", "bundle", "symfony"],
"homepage": "https://github.com/welcoMattic/ApacheTikaBundle",
"version": "0.1.0",
"license": "MIT",
"authors": [
{
"name": "welcomattic",
"email": "[email protected]"
}
]
],
"require": {
"php": ">=5.4.0",
"vaites/php-apache-tika": "^0.3.0"
},
"autoload": {
"psr-0": { "welcoMattic\\ApacheTikaBundle": "" }
},
"target-dir": "welcoMattic/ApacheTikaBundle"
}
74 changes: 74 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0adf9e3

Please sign in to comment.