Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bashofmann committed Nov 18, 2011
0 parents commit 0aeefbb
Show file tree
Hide file tree
Showing 15 changed files with 2,056 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2011 ResearchGate GmbH

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.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
============
rg\injection
============

rg\injection is a sophisticated dependency injection container for PHP that was inspired by Guice.

25 changes: 25 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
backupStaticAttributes="false"
bootstrap="src/bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
strict="false"
verbose="false">
<testsuites>
<testsuite name="all">
<directory>test</directory>
</testsuite>
</testsuites>
</phpunit>
18 changes: 18 additions & 0 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*
* This file is part of rg\injection.
*
* (c) ResearchGate GmbH <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once(__DIR__ . '/../vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php');

$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => __DIR__ . '/../vendor',
'Zend' => __DIR__ . '/../vendor',
'rg' => __DIR__,
));
$loader->register();
54 changes: 54 additions & 0 deletions src/rg/injection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/*
* This file is part of rg\injection.
*
* (c) ResearchGate GmbH <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace rg\injection;

class Configuration {

/**
* @var array
*/
private $config = array();

/**
* @param string $configurationFilePath
*/
public function __construct($configurationFilePath) {
$this->loadConfigFile($configurationFilePath);
}

/**
* @param string $fullClassName
* @return array
*/
public function getClassConfig($fullClassName) {
if (! isset($this->config[$fullClassName])) {
return array();
}

return $this->config[$fullClassName];
}

/**
* @param string $fullClassName
* @param array $config
*/
public function setClassConfig($fullClassName, array $config) {
$this->config[$fullClassName] = $config;
}

/**
* @param string $configurationFilePath
*/
private function loadConfigFile($configurationFilePath) {
if ($configurationFilePath && file_exists($configurationFilePath)) {
$this->config = require $configurationFilePath;
}
}
}
Loading

0 comments on commit 0aeefbb

Please sign in to comment.