コード例 #1
0
ファイル: GlueCode.php プロジェクト: hvasoares/phplombok
 public function getRegistry($registryWithConfig)
 {
     $r = new c\Registry($registryWithConfig);
     $annotationStrategy = new PublicMethodOverrideTemplate(new AnnotationStrategyDoctrine($r['phplombok_cachedir'], $supportCode = new SupportCodeChain(), $r['phplombok_debug']));
     $lombokLock = new c\JsonPersistentArray($r['phplombok_cachedir'] . "/phplombok.lock" . ($r['phplombok_debug'] ? time() : ""));
     if (!isset($lombokLock['classCache'])) {
         $lombokLock['classCache'] = $r['phplombok_cachedir'] . "/classCache" . time();
     }
     if (!isset($lombokLock['cacheFile'])) {
         $lombokLock['cacheFile'] = $r['phplombok_cachedir'] . "/cacheFile" . time();
     }
     $builder = new Builder(new c\JsonPersistentArray($lombokLock['classCache']));
     $builder->add(new PropertyAccessorConfig());
     $r['childClassGenerator'] = new ChildClassGenerator(new Cache($r['phplombok_cachedir'], new c\JsonPersistentArray($lombokLock['cacheFile'])), new Template($annotationStrategy), $builder);
     $supportCode->add($jqAnnot = new JqueryProperty(), $accessorTemplate = new PropertyAccessorTemplate());
     $annotationStrategy->setTemplateStrategy($jqAnnot, new JQPropertyTemplateStrategy($accessorTemplate));
     $annotationStrategy->setTemplateStrategy($delAnnot = new Delegate(), $delConfig = new DelegateConfig($r));
     $supportCode->add($delAnnot, new DelegatePropertyTemplate());
     $builder->add($delConfig);
     $r['delegateCallQueue'] = function ($r) {
         return new DelegateCallQueue();
     };
     $r['phplombok_annotationStrategy'] = $annotationStrategy;
     return $r;
 }
コード例 #2
0
ファイル: BuilderTest.php プロジェクト: hvasoares/phplombok
 public function testShouldPassTheNewObjectThroughTheChain()
 {
     $inst = new Builder(array());
     $inst->add($node1 = m::mock('chainnode1'));
     $inst->add($node2 = m::mock('chainnode2'));
     $oldClass = 'hvasoares\\phplombok\\' . 'testresources\\TestedClass';
     $newClass = 'hvasoares\\phplombok\\' . 'testresources\\SampleGeneratedClass';
     $inst->configure($oldClass, $newClass);
     $obj = new testresources\TestedClass();
     $node1->shouldReceive('configure')->with($obj, m::type($newClass))->andReturn('modifiedBy node1')->once();
     $node2->shouldReceive('configure')->with($obj, 'modifiedBy node1')->andReturn('modifiedBy node2')->once();
     $this->assertEquals($inst->get($obj), "modifiedBy node2");
 }