转载

Dao7 1.3.2 发布更新:引入 AOP 功能

解决大量的 memory leak 问题,支持多级命名空间视图的渲染,通过 Phalcon/Mvc/View::disableMultiNamespaceView 关闭该功能。

新增 Phalcon/Snowflake 类。

<?php

$snowflake = new Phalcon/Snowflake;
$id = $snowflake->nextId();
$desc = $snowflake->parse($id);

引用 AOP

<?php

class MyServices
{
	private $val = 0;
	public function doVal() {
		echo 'Myval='.$this->val.PHP_EOL;
		$this->val++;
		echo 'Myval='.$this->val.PHP_EOL;
	}
}

Phalcon/Aop::addBefore('read MyServices->val', function($obj){
	var_dump('before read');
	echo $obj->getPropertyName().'='.$obj->getPropertyValue().PHP_EOL;
});
Phalcon/Aop::addAfter('read MyServices->val', function($obj){
	var_dump('after read');
	echo $obj->getPropertyName().'='.$obj->getPropertyValue().PHP_EOL;
});
Phalcon/Aop::addBefore('write MyServices->val', function($obj){
	var_dump('before write');
	echo $obj->getPropertyName().'='.$obj->getPropertyValue().PHP_EOL;
	$obj->setAssignedValue(3);
});
Phalcon/Aop::addAfter('write MyServices->val', function($obj){
	var_dump('after write');
	echo $obj->getPropertyName().'='.$obj->getPropertyValue().PHP_EOL;
});
$services = new MyServices();
$services->doVal();
原文  https://www.oschina.net/news/98487/dao7-1-3-2-released
正文到此结束
Loading...