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 26 changed files with 563 additions and 195 deletions.
14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

19 changes: 13 additions & 6 deletions src/Configuration.php
Expand Up @@ -7,15 +7,16 @@

class Configuration
{
protected $data = array();

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

protected $data = array();
/**
* Constructor
*
* @param array|Traversable $options
* @throws Exception\InvalidArgumentException
*/
public function __construct($options)
{
Expand All @@ -30,7 +31,13 @@ public function __construct($options)
}
$this->data = $options;
}


/**
* Configure
*
* @param Di $di
* @return void
*/
public function configure(Di $di)
{
if (isset($this->data['definition'])) {
Expand Down
32 changes: 27 additions & 5 deletions src/Definition/Builder/PhpClass.php
Expand Up @@ -9,13 +9,24 @@ class PhpClass
protected $instantiator = '__construct';
protected $injectionMethods = array();
protected $superTypes = array();


/**
* Set name
*
* @param string $name
* @return PhpClass
*/
public function setName($name)
{
$this->name = $name;
return $this;
}


/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
Expand All @@ -31,18 +42,29 @@ public function getInstantiator()
{
return $this->instantiator;
}

public function addSuperType($superType)
{
$this->superTypes[] = $superType;
return $this;
}


/**
* Get super types
*
* @return array
*/
public function getSuperTypes()
{
return $this->superTypes;
}


/**
* Add injection method
*
* @param InjectionMethod $injectionMethod
* @return PhpClass
*/
public function addInjectionMethod(InjectionMethod $injectionMethod)
{
$this->injectionMethods[] = $injectionMethod;
Expand Down
88 changes: 75 additions & 13 deletions src/Definition/BuilderDefinition.php
Expand Up @@ -6,9 +6,22 @@

class BuilderDefinition implements DefinitionInterface
{
/**
* @var string
*/
protected $defaultClassBuilder = 'Zend\Di\Definition\Builder\PhpClass';

/**
* @var array
*/
protected $classes = array();

/**
* Create classes from array
*
* @param array $builderData
* @return void
*/
public function createClassesFromArray(array $builderData)
{
foreach ($builderData as $className => $classInfo) {
Expand Down Expand Up @@ -42,7 +55,13 @@ public function createClassesFromArray(array $builderData)
$this->addClass($class);
}
}


/**
* Add class
*
* @param Builder\PhpClass $phpClass
* @return BuilderDefinition
*/
public function addClass(Builder\PhpClass $phpClass)
{
$this->classes[] = $phpClass;
Expand Down Expand Up @@ -93,7 +112,10 @@ public function getClassBuilder()
{
return $this->defaultClassBuilder;
}


/**
* @return array
*/
public function getClasses()
{
$classNames = array();
Expand All @@ -102,7 +124,11 @@ public function getClasses()
}
return $classNames;
}


/**
* @param string $class
* @return bool
*/
public function hasClass($class)
{
foreach ($this->classes as $classObj) {
Expand All @@ -112,7 +138,11 @@ public function hasClass($class)
}
return false;
}


/**
* @param string $name
* @return bool
*/
protected function getClass($name)
{
foreach ($this->classes as $classObj) {
Expand All @@ -122,7 +152,12 @@ protected function getClass($name)
}
return false;
}


/**
* @param string $class
* @return array
* @throws Exception\RuntimeException
*/
public function getClassSupertypes($class)
{
$class = $this->getClass($class);
Expand All @@ -131,7 +166,12 @@ public function getClassSupertypes($class)
}
return $class->getSuperTypes();
}


/**
* @param string $class
* @return array|string
* @throws Exception\RuntimeException
*/
public function getInstantiator($class)
{
$class = $this->getClass($class);
Expand All @@ -140,17 +180,27 @@ public function getInstantiator($class)
}
return $class->getInstantiator();
}


/**
* @param string $class
* @return bool
* @throws Exception\RuntimeException
*/
public function hasMethods($class)
{
/* @var $class Zend\Di\Definition\Builder\PhpClass */
/* @var $class \Zend\Di\Definition\Builder\PhpClass */
$class = $this->getClass($class);
if ($class === false) {
throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
}
return (count($class->getInjectionMethods()) > 0);
}


/**
* @param string $class
* @return array
* @throws Exception\RuntimeException
*/
public function getMethods($class)
{
$class = $this->getClass($class);
Expand All @@ -164,7 +214,13 @@ public function getMethods($class)
}
return $methodNames;
}


/**
* @param string $class
* @param string $method
* @return bool
* @throws Exception\RuntimeException
*/
public function hasMethod($class, $method)
{
$class = $this->getClass($class);
Expand All @@ -181,8 +237,8 @@ public function hasMethod($class, $method)
}

/**
* @param $class
* @param $method
* @param string $class
* @param string $method
* @return bool
*/
public function hasMethodParameters($class, $method)
Expand All @@ -202,7 +258,13 @@ public function hasMethodParameters($class, $method)
}
return (count($method->getParameters()) > 0);
}


/**
* @param string $class
* @param string $method
* @return array
* @throws Exception\RuntimeException
*/
public function getMethodParameters($class, $method)
{
$class = $this->getClass($class);
Expand Down
6 changes: 6 additions & 0 deletions src/Definition/ClassDefinition.php
Expand Up @@ -29,6 +29,11 @@ public function setSupertypes(array $supertypes)
return $this;
}

/**
* @param string $method
* @param bool|null $isRequired
* @return ClassDefinition
*/
public function addMethod($method, $isRequired = null)
{
if ($isRequired === null) {
Expand All @@ -43,6 +48,7 @@ public function addMethod($method, $isRequired = null)
* @param $method
* @param $parameterName
* @param array $parameterInfo (keys: required, type)
* @return ClassDefinition
*/
public function addMethodParameter($method, $parameterName, array $parameterInfo)
{
Expand Down

0 comments on commit 9ce360b

Please sign in to comment.