Changeset 808

Show
Ignore:
Timestamp:
08/13/07 21:05:39 (1 year ago)
Author:
schst
Message:

Moved stubInject annotation to new annotations sub-package, added first (very early draft) of the new IoC feature

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ioc/injection/injection.php

    r314 r808  
    22/** 
    33 * Injection handling bootstrap file. 
    4  *  
     4 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
    66 * @package     stubbles 
     
    1010                      'net.stubbles.ioc.injection.stubInjectionProvider', 
    1111                      'net.stubbles.ioc.injection.stubInjectionMap', 
    12                       'net.stubbles.ioc.injection.stubInjectAnnotation' 
     12                      'net.stubbles.ioc.injection.annotations.stubInjectAnnotation' 
    1313); 
    1414?> 
  • trunk/src/main/php/net/stubbles/stubClassLoader.php

    r777 r808  
    159159            self::$useStar = false; 
    160160        } 
    161          
     161 
    162162        self::$sourcePath = stubConfig::getSourcePath() . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR; 
    163163    } 
     
    188188            self::init(); 
    189189        } 
    190          
     190 
    191191        foreach ($classNames as $fqClassName) { 
    192192            $nqClassName = self::getNonQualifiedClassName($fqClassName); 
     
    210210            } 
    211211 
    212             if ((include $uri) == false) { 
     212            if ((@include $uri) == false) { 
    213213                throw new stubClassNotFoundException($fqClassName); 
    214214            } 
     
    232232            self::init(); 
    233233        } 
    234          
     234 
    235235        $dirName = self::$sourcePath . str_replace('.', DIRECTORY_SEPARATOR, $packageName); 
    236236        if (file_exists($dirName) == false) { 
    237237            return array(); 
    238238        } 
    239          
     239 
    240240        if (false === $recursive) { 
    241241            $dirIt = new DirectoryIterator($dirName); 
     
    243243            $dirIt = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName)); 
    244244        } 
    245          
     245 
    246246        $classes = array(); 
    247247        foreach ($dirIt as $file) { 
     
    249249                continue; 
    250250            } 
    251              
     251 
    252252            $classes[] = str_replace(DIRECTORY_SEPARATOR, '.', str_replace('.php', '', str_replace(self::$sourcePath, '', $file->getPathname()))); 
    253253        } 
    254          
     254 
    255255        if (true === self::$useStar) { 
    256256            $starClasses = StarClassRegistry::getClasses(); 
     
    259259                    continue; 
    260260                } 
    261                  
     261 
    262262                $nqClassName = self::getNonQualifiedClassName($fqClassName); 
    263263                if (str_replace($nqClassName, '', $fqClassName) != $packageName && false === $recursive) { 
    264264                    continue; 
    265265                } 
    266                  
     266 
    267267                $classes[] = $fqClassName; 
    268268            } 
    269269        } 
    270          
     270 
    271271        sort($classes); 
    272272        return $classes; 
     
    336336            } 
    337337        } 
    338          
     338 
    339339        return null; 
    340340    } 
  • trunk/src/test/php/net/stubbles/ioc/injection/stubInjectAnnotationTestCase.php

    r353 r808  
    11<?php 
    22/** 
    3  * Test for net.stubbles.ioc.injection.stubInjectAnnotation 
     3 * Test for net.stubbles.ioc.injection.annotations.stubInjectAnnotation 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    77 * @subpackage  ioc_injection_test 
    88 */ 
    9 stubClassLoader::load('net.stubbles.ioc.injection.stubInjectAnnotation'); 
     9stubClassLoader::load('net.stubbles.ioc.injection.annotations.stubInjectAnnotation'); 
    1010class TestInjection1 extends stubBaseObject {} 
    1111class TestInjection2 extends stubBaseObject {} 
     
    1414/** 
    1515 * class for testing injections 
    16  *  
     16 * 
    1717 * @Inject(TestInjection1:TestInjection2:TestInjection3) 
    1818 */ 
     
    2121    protected $TestInjection1; 
    2222    public $TestInjection2; 
    23      
     23 
    2424    public function setTestInjection1($i) 
    2525    { 
    2626        $this->TestInjection1 = $i; 
    2727    } 
    28      
     28 
    2929    public function getTestInjection1() 
    3030    { 
    3131        return $this->TestInjection1; 
    3232    } 
    33      
     33 
    3434    public function __set($name, $value) 
    3535    { 
     
    3939/** 
    4040 * class for testing injections 
    41  *  
     41 * 
    4242 * @Inject(TestInjection1:TestInjection2:TestInjection3) 
    4343 */ 
     
    5454    protected $TestInjection4; 
    5555    public $TestInjection5; 
    56      
     56 
    5757    public function setTestInjection4($i) 
    5858    { 
    5959        $this->TestInjection4 = $i; 
    6060    } 
    61      
     61 
    6262    public function getTestInjection4() 
    6363    { 
     
    6666} 
    6767/** 
    68  * Test for net.stubbles.ioc.injection.stubInjectAnnotation 
     68 * Test for net.stubbles.ioc.injection.annotations.stubInjectAnnotation 
    6969 * 
    7070 * @package     stubbles 
     
    7979     */ 
    8080    protected $injectionMap; 
    81      
     81 
    8282    /** 
    8383     * set up test environment 
     
    101101        $this->assertEqual($inject->getInjections(), array('TestInjection1', 'TestInjection2', 'TestInjection3')); 
    102102    } 
    103      
     103 
    104104    /** 
    105105     * check that the handling works as expected 
     
    113113        $this->assertReference($test1a, $test1b); 
    114114    } 
    115      
     115 
    116116    /** 
    117117     * check that the handling works as expected 
     
    123123        stubInjectAnnotation::factory(new stubInjectionMap(), $testInjectible); 
    124124    } 
    125      
     125 
    126126    /** 
    127127     * check that the handling works as expected 
     
    133133        stubInjectAnnotation::factory($this->injectionMap, $testInjectible); 
    134134    } 
    135      
     135 
    136136    /** 
    137137     * check that the handling works as expected 
     
    145145        stubInjectAnnotation::factory($this->injectionMap, $testInjectible); 
    146146    } 
    147      
     147 
    148148    /** 
    149149     * check that the handling works as expected 
     
    154154        stubInjectAnnotation::factory($this->injectionMap, 'foo'); 
    155155    } 
    156      
     156 
    157157    public function testStubPrefix() 
    158158    {