Exemplo n.º 1
0
 public function test()
 {
     // Test the factory
     $this->assertEquals('\\Phruts\\Util\\PropertyMessageResourcesFactory', \Phruts\Util\MessageResourcesFactory::getFactoryClass());
     $propertyMessageResourcesFactory = \Phruts\Util\PropertyMessageResourcesFactory::createFactory();
     $this->assertNotEmpty($propertyMessageResourcesFactory);
     // Create the resources
     $propertyMessageResources = $propertyMessageResourcesFactory->createResources(__DIR__ . '/Example');
     $this->assertNotEmpty($propertyMessageResources->getMessage(null, 'example'));
     $this->assertEquals('Example Response', $propertyMessageResources->getMessage(null, 'example'));
     $this->assertNotEmpty($propertyMessageResources->getMessage(null, 'example2'));
     $this->assertEquals('Hello Cam', $propertyMessageResources->getMessage(null, 'example2', array('Cam')));
     $this->assertTrue($propertyMessageResources->getReturnNull());
 }
Exemplo n.º 2
0
 protected function initModuleMessageResources(\Phruts\Config\ModuleConfig $config)
 {
     $mrcs = $config->findMessageResourcesConfigs();
     foreach ($mrcs as $mrc) {
         /* @var $mrc \Phruts\Config\MessageResourcesConfig */
         if (!empty($this->log)) {
             $this->log->debug('Initializing module "' . $config->getPrefix() . '" message resources from "' . $mrc->getParameter() . '"');
         }
         $factory = $mrc->getFactory();
         \Phruts\Util\MessageResourcesFactory::setFactoryClass($factory);
         $factoryObject = \Phruts\Util\MessageResourcesFactory::createFactory($factory);
         if (is_null($factoryObject)) {
             $msg = 'Cannot load resources from "' . $mrc->getParameter() . '"';
             if (!empty($this->log)) {
                 $this->log->error($msg);
             }
             throw new \Phruts\Exception($msg);
         }
         $resources = $factoryObject->createResources($mrc->getParameter());
         $resources->setReturnNull($mrc->getNull());
         $this->application[$mrc->getKey() . $config->getPrefix()] = $resources;
     }
 }