Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 99 changed files with 2,398 additions and 772 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-di",
"description": "Zend\\Di component",
"description": " ",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,11 +9,11 @@
"homepage": "https://github.com/zendframework/zend-di",
"autoload": {
"psr-4": {
"Zend\\Di\\": "src/"
"Zend\\Di": "src/"
}
},
"require": {
"php": ">=5.3.23",
"php": ">=5.3.3",
"zendframework/zend-code": "self.version",
"zendframework/zend-stdlib": "self.version"
},
Expand Down
68 changes: 51 additions & 17 deletions src/Configuration.php → src/Config.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Di
*/

namespace Zend\Di;

use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Di\Definition\ArrayDefinition;
use Zend\Di\Definition\RuntimeDefinition;

class Configuration
/**
* Configures Di instances
*
* @category Zend
* @package Zend_Di
*/
class Config
{
protected $data = array();

/**
* @var Zend\Di\DependencyInjector
* @var array
*/
protected $di = null;
protected $data = array();

/**
* @param array|Traversable $options
* Constructor
*
* @param array|Traversable $options
* @throws Exception\InvalidArgumentException
*/
public function __construct($options)
{
Expand All @@ -25,12 +42,18 @@ public function __construct($options)

if (!is_array($options)) {
throw new Exception\InvalidArgumentException(
'Configuration data must be of type Traversable or an array'
'Config data must be of type Traversable or an array'
);
}
$this->data = $options;
}


/**
* Configure
*
* @param Di $di
* @return void
*/
public function configure(Di $di)
{
if (isset($this->data['definition'])) {
Expand All @@ -40,17 +63,21 @@ public function configure(Di $di)
if (isset($this->data['instance'])) {
$this->configureInstance($di, $this->data['instance']);
}

}

/**
* @param Di $di
* @param array $definition
*/
public function configureDefinition(Di $di, $definition)
{
foreach ($definition as $definitionType => $definitionData) {
switch ($definitionType) {
case 'compiler':
foreach ($definitionData as $filename) {
if (is_readable($filename)) {
$di->definitions()->addDefinition(new \Zend\Di\Definition\ArrayDefinition(include $filename), false);
$di->definitions()->addDefinition(new ArrayDefinition(include $filename), false);
}
}
break;
Expand All @@ -59,16 +86,18 @@ public function configureDefinition(Di $di, $definition)
// Remove runtime from definition list if not enabled
$definitions = array();
foreach ($di->definitions() as $definition) {
if (!$definition instanceof \Zend\Di\Definition\RuntimeDefinition) {
if (!$definition instanceof RuntimeDefinition) {
$definitions[] = $definition;
}
}
$definitions = new DefinitionList($definitions);
$di->setDefinitionList($definitions);
} elseif (isset($definitionData['use_annotations']) && $definitionData['use_annotations']) {
$di->definitions()->getDefinitionByType('\Zend\Di\Definition\RuntimeDefinition')
->getIntrospectionStrategy()
->setUseAnnotations(true);
/* @var $runtimeDefinition Definition\RuntimeDefinition */
$runtimeDefinition = $di
->definitions()
->getDefinitionByType('\Zend\Di\Definition\RuntimeDefinition');
$runtimeDefinition->getIntrospectionStrategy()->setUseAnnotations(true);
}
break;
case 'class':
Expand Down Expand Up @@ -121,11 +150,17 @@ public function configureDefinition(Di $di, $definition)
}

}


/**
* Configures a given Di instance
*
* @param Di $di
* @param $instanceData
*/
public function configureInstance(Di $di, $instanceData)
{
$im = $di->instanceManager();

foreach ($instanceData as $target => $data) {
switch (strtolower($target)) {
case 'aliases':
Expand Down Expand Up @@ -168,5 +203,4 @@ public function configureInstance(Di $di, $instanceData)

}


}
21 changes: 20 additions & 1 deletion src/Definition/Annotation/Inject.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Di
*/

namespace Zend\Di\Definition\Annotation;

use Zend\Code\Annotation\AnnotationInterface;

/**
* Annotation for injection endpoints for dependencies
*
* @category Zend
* @package Zend_Di
*/
class Inject implements AnnotationInterface
{

/**
* @var mixed
*/
protected $content = null;

/**
* {@inheritDoc}
*/
public function initialize($content)
{
$this->content = $content;
Expand Down
21 changes: 20 additions & 1 deletion src/Definition/Annotation/Instantiator.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Di
*/

namespace Zend\Di\Definition\Annotation;

use Zend\Code\Annotation\AnnotationInterface;

/**
* Annotation for instantiator
*
* @category Zend
* @package Zend_Di
*/
class Instantiator implements AnnotationInterface
{

/**
* @var mixed
*/
protected $content = null;

/**
* {@inheritDoc}
*/
public function initialize($content)
{
$this->content = $content;
Expand Down

0 comments on commit a95f940

Please sign in to comment.