Phrozn\Registry\Dao\Serialized::read PHP Method

read() public method

Read registry data into container.
public read ( ) : Container
return Phrozn\Registry\Container
    public function read()
    {
        $path = $this->getProjectPath() . '/' . $this->getOutputFile();
        if (!is_readable($path)) {
            $this->getContainer()->setValues(null);
            return $this->getContainer();
        }
        $newContainer = unserialize(file_get_contents($path));
        return $newContainer;
    }

Usage Example

Example #1
0
 public function testNoRegistryFile()
 {
     $container = new Container();
     $arr = array(1, 2, 3);
     $container->set('template', $arr);
     $dao = new Dao($container);
     $dao->setOutputFile('not-found');
     $this->assertSame($arr, $container->get('template'));
     $dao->read();
     $this->assertNull($container->getValues());
     $this->assertNull($container->get('template'));
 }
Serialized