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

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into string
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 102 changed files with 2,183 additions and 682 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -9,7 +9,7 @@
"homepage": "https://github.com/zendframework/zend-di",
"autoload": {
"psr-4": {
"Zend\\Di": "src/"
"Zend\\Di\\": "src/"
}
},
"require": {
Expand Down
55 changes: 41 additions & 14 deletions src/Configuration.php → src/Config.php
@@ -1,21 +1,37 @@
<?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
{
/**
* @var array
*/
protected $data = array();

/**
* Constructor
*
* @param array|Traversable $options
* @param array|Traversable $options
* @throws Exception\InvalidArgumentException
*/
public function __construct($options)
Expand All @@ -26,7 +42,7 @@ 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;
Expand All @@ -35,7 +51,7 @@ public function __construct($options)
/**
* Configure
*
* @param Di $di
* @param Di $di
* @return void
*/
public function configure(Di $di)
Expand All @@ -47,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 @@ -66,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 @@ -128,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 @@ -175,5 +203,4 @@ public function configureInstance(Di $di, $instanceData)

}


}
21 changes: 20 additions & 1 deletion src/Definition/Annotation/Inject.php
@@ -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
@@ -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 336bb38

Please sign in to comment.